blockdev.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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/block.h"
  12. #include "qemu/queue.h"
  13. typedef enum {
  14. IF_DEFAULT = -1, /* for use with drive_add() only */
  15. /*
  16. * IF_NONE must be zero, because we want MachineClass member
  17. * block_default_type to default-initialize to IF_NONE
  18. */
  19. IF_NONE = 0,
  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. BlockInterfaceType type;
  25. int bus;
  26. int unit;
  27. int auto_del; /* see blockdev_mark_auto_del() */
  28. bool is_default; /* Added by default_drive() ? */
  29. int media_cd;
  30. QemuOpts *opts;
  31. QTAILQ_ENTRY(DriveInfo) next;
  32. };
  33. /*
  34. * Global state (GS) API. These functions run under the BQL.
  35. *
  36. * See include/block/block-global-state.h for more information about
  37. * the GS API.
  38. */
  39. void blockdev_mark_auto_del(BlockBackend *blk);
  40. void blockdev_auto_del(BlockBackend *blk);
  41. DriveInfo *blk_legacy_dinfo(BlockBackend *blk);
  42. DriveInfo *blk_set_legacy_dinfo(BlockBackend *blk, DriveInfo *dinfo);
  43. BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo);
  44. void override_max_devs(BlockInterfaceType type, int max_devs);
  45. DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
  46. void drive_check_orphaned(void);
  47. DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
  48. int drive_get_max_bus(BlockInterfaceType type);
  49. QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
  50. const char *optstr);
  51. DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
  52. Error **errp);
  53. #endif