blockdev.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * QEMU host block devices
  3. *
  4. * Copyright (c) 2003-2008 Fabrice Bellard
  5. *
  6. * This work is licensed under the terms of the GNU GPL, version 2 or
  7. * later. See the COPYING file in the top-level directory.
  8. */
  9. #ifndef BLOCKDEV_H
  10. #define BLOCKDEV_H
  11. #include "block.h"
  12. #include "error.h"
  13. #include "qemu-queue.h"
  14. void blockdev_mark_auto_del(BlockDriverState *bs);
  15. void blockdev_auto_del(BlockDriverState *bs);
  16. #define BLOCK_SERIAL_STRLEN 20
  17. typedef enum {
  18. IF_DEFAULT = -1, /* for use with drive_add() only */
  19. IF_NONE,
  20. IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
  21. IF_COUNT
  22. } BlockInterfaceType;
  23. struct DriveInfo {
  24. BlockDriverState *bdrv;
  25. char *id;
  26. const char *devaddr;
  27. BlockInterfaceType type;
  28. int bus;
  29. int unit;
  30. int auto_del; /* see blockdev_mark_auto_del() */
  31. int media_cd;
  32. QemuOpts *opts;
  33. char serial[BLOCK_SERIAL_STRLEN + 1];
  34. QTAILQ_ENTRY(DriveInfo) next;
  35. int refcount;
  36. };
  37. DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
  38. DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
  39. int drive_get_max_bus(BlockInterfaceType type);
  40. DriveInfo *drive_get_next(BlockInterfaceType type);
  41. void drive_get_ref(DriveInfo *dinfo);
  42. void drive_put_ref(DriveInfo *dinfo);
  43. DriveInfo *drive_get_by_blockdev(BlockDriverState *bs);
  44. QemuOpts *drive_def(const char *optstr);
  45. QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
  46. const char *optstr);
  47. DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi);
  48. /* device-hotplug */
  49. DriveInfo *add_init_drive(const char *opts);
  50. void qmp_change_blockdev(const char *device, const char *filename,
  51. bool has_format, const char *format, Error **errp);
  52. void do_commit(Monitor *mon, const QDict *qdict);
  53. int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
  54. #endif