Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 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 | |
| 10 | #ifndef BLOCKDEV_H |
| 11 | #define BLOCKDEV_H |
| 12 | |
Paolo Bonzini | 737e150 | 2012-12-17 18:19:44 +0100 | [diff] [blame] | 13 | #include "block/block.h" |
Paolo Bonzini | 1de7afc | 2012-12-17 18:20:00 +0100 | [diff] [blame] | 14 | #include "qemu/queue.h" |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 15 | |
Markus Armbruster | 4be7463 | 2014-10-07 13:59:18 +0200 | [diff] [blame] | 16 | void blockdev_mark_auto_del(BlockBackend *blk); |
| 17 | void blockdev_auto_del(BlockBackend *blk); |
Markus Armbruster | 14bafc5 | 2010-06-25 08:09:10 +0200 | [diff] [blame] | 18 | |
Markus Armbruster | 904ebff | 2011-01-28 11:21:38 +0100 | [diff] [blame] | 19 | typedef enum { |
Markus Armbruster | 2292dda | 2011-01-28 11:21:41 +0100 | [diff] [blame] | 20 | IF_DEFAULT = -1, /* for use with drive_add() only */ |
Christian Borntraeger | 2d0d283 | 2012-11-20 15:30:34 +0100 | [diff] [blame] | 21 | /* |
Markus Armbruster | a27fa28 | 2017-02-15 11:05:42 +0100 | [diff] [blame] | 22 | * IF_NONE must be zero, because we want MachineClass member |
| 23 | * block_default_type to default-initialize to IF_NONE |
Christian Borntraeger | 2d0d283 | 2012-11-20 15:30:34 +0100 | [diff] [blame] | 24 | */ |
Markus Armbruster | a27fa28 | 2017-02-15 11:05:42 +0100 | [diff] [blame] | 25 | IF_NONE = 0, |
| 26 | IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN, |
Markus Armbruster | 904ebff | 2011-01-28 11:21:38 +0100 | [diff] [blame] | 27 | IF_COUNT |
| 28 | } BlockInterfaceType; |
| 29 | |
Blue Swirl | 2446333 | 2010-08-24 15:22:24 +0000 | [diff] [blame] | 30 | struct DriveInfo { |
Cornelia Huck | 75f4cd2 | 2018-07-06 15:06:19 +0200 | [diff] [blame] | 31 | const char *devaddr; |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 32 | BlockInterfaceType type; |
| 33 | int bus; |
| 34 | int unit; |
Markus Armbruster | 14bafc5 | 2010-06-25 08:09:10 +0200 | [diff] [blame] | 35 | int auto_del; /* see blockdev_mark_auto_del() */ |
John Snow | a66c9dc | 2014-10-01 14:19:24 -0400 | [diff] [blame] | 36 | bool is_default; /* Added by default_drive() ? */ |
Markus Armbruster | 95b5edc | 2011-05-16 15:04:56 +0200 | [diff] [blame] | 37 | int media_cd; |
Cornelia Huck | 6703db1 | 2018-07-06 15:06:20 +0200 | [diff] [blame] | 38 | int cyls, heads, secs, trans; |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 39 | QemuOpts *opts; |
Cornelia Huck | 44e8b46 | 2018-07-06 15:06:18 +0200 | [diff] [blame] | 40 | char *serial; |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 41 | QTAILQ_ENTRY(DriveInfo) next; |
Blue Swirl | 2446333 | 2010-08-24 15:22:24 +0000 | [diff] [blame] | 42 | }; |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 43 | |
Markus Armbruster | 18e46a0 | 2014-10-07 13:59:06 +0200 | [diff] [blame] | 44 | DriveInfo *blk_legacy_dinfo(BlockBackend *blk); |
| 45 | DriveInfo *blk_set_legacy_dinfo(BlockBackend *blk, DriveInfo *dinfo); |
| 46 | BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo); |
| 47 | |
John Snow | 21dff8c | 2014-10-01 14:19:25 -0400 | [diff] [blame] | 48 | void override_max_devs(BlockInterfaceType type, int max_devs); |
| 49 | |
Stefan Weil | 6ea421f | 2010-09-23 20:47:32 +0200 | [diff] [blame] | 50 | DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit); |
Markus Armbruster | 720b8dc | 2017-02-15 11:05:46 +0100 | [diff] [blame] | 51 | void drive_check_orphaned(void); |
Markus Armbruster | f1bd51a | 2011-01-28 11:21:44 +0100 | [diff] [blame] | 52 | DriveInfo *drive_get_by_index(BlockInterfaceType type, int index); |
Stefan Weil | 6ea421f | 2010-09-23 20:47:32 +0200 | [diff] [blame] | 53 | int drive_get_max_bus(BlockInterfaceType type); |
John Snow | d8f94e1 | 2014-10-01 14:19:27 -0400 | [diff] [blame] | 54 | int drive_get_max_devs(BlockInterfaceType type); |
Markus Armbruster | 1383997 | 2011-01-28 11:21:37 +0100 | [diff] [blame] | 55 | DriveInfo *drive_get_next(BlockInterfaceType type); |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 56 | |
Markus Armbruster | 2292dda | 2011-01-28 11:21:41 +0100 | [diff] [blame] | 57 | QemuOpts *drive_def(const char *optstr); |
| 58 | QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file, |
Markus Armbruster | 5645b0f | 2011-01-31 11:50:09 +0100 | [diff] [blame] | 59 | const char *optstr); |
Markus Armbruster | 60e19e0 | 2014-06-06 14:50:58 +0200 | [diff] [blame] | 60 | DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type); |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 61 | |
| 62 | /* device-hotplug */ |
| 63 | |
Markus Armbruster | 3e5a50d | 2015-02-06 13:55:43 +0100 | [diff] [blame] | 64 | void hmp_commit(Monitor *mon, const QDict *qdict); |
Markus Armbruster | 072ebe6 | 2015-03-05 17:00:56 +0100 | [diff] [blame] | 65 | void hmp_drive_del(Monitor *mon, const QDict *qdict); |
Markus Armbruster | 666daa6 | 2010-06-02 18:48:27 +0200 | [diff] [blame] | 66 | #endif |