blockdev.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 "qemu-queue.h"
  13. void blockdev_mark_auto_del(BlockDriverState *bs);
  14. void blockdev_auto_del(BlockDriverState *bs);
  15. #define BLOCK_SERIAL_STRLEN 20
  16. typedef enum {
  17. IF_DEFAULT = -1, /* for use with drive_add() only */
  18. IF_NONE,
  19. IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
  20. IF_COUNT
  21. } BlockInterfaceType;
  22. struct DriveInfo {
  23. BlockDriverState *bdrv;
  24. char *id;
  25. const char *devaddr;
  26. BlockInterfaceType type;
  27. int bus;
  28. int unit;
  29. int auto_del; /* see blockdev_mark_auto_del() */
  30. int media_cd;
  31. QemuOpts *opts;
  32. char serial[BLOCK_SERIAL_STRLEN + 1];
  33. QTAILQ_ENTRY(DriveInfo) next;
  34. int refcount;
  35. };
  36. DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
  37. DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
  38. int drive_get_max_bus(BlockInterfaceType type);
  39. DriveInfo *drive_get_next(BlockInterfaceType type);
  40. void drive_get_ref(DriveInfo *dinfo);
  41. void drive_put_ref(DriveInfo *dinfo);
  42. DriveInfo *drive_get_by_blockdev(BlockDriverState *bs);
  43. QemuOpts *drive_def(const char *optstr);
  44. QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
  45. const char *optstr);
  46. DriveInfo *drive_init(QemuOpts *arg, int default_to_scsi);
  47. /* device-hotplug */
  48. DriveInfo *add_init_drive(const char *opts);
  49. void do_commit(Monitor *mon, const QDict *qdict);
  50. int do_eject(Monitor *mon, const QDict *qdict, QObject **ret_data);
  51. int do_block_set_passwd(Monitor *mon, const QDict *qdict, QObject **ret_data);
  52. int do_change_block(Monitor *mon, const char *device,
  53. const char *filename, const char *fmt);
  54. int do_drive_del(Monitor *mon, const QDict *qdict, QObject **ret_data);
  55. int do_snapshot_blkdev(Monitor *mon, const QDict *qdict, QObject **ret_data);
  56. int do_block_resize(Monitor *mon, const QDict *qdict, QObject **ret_data);
  57. #endif