xref: /openbmc/qemu/include/sysemu/blockdev.h (revision 34ffacb7)
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 
13 #include "block/block.h"
14 #include "qemu/queue.h"
15 
16 typedef enum {
17     IF_DEFAULT = -1,            /* for use with drive_add() only */
18     /*
19      * IF_NONE must be zero, because we want MachineClass member
20      * block_default_type to default-initialize to IF_NONE
21      */
22     IF_NONE = 0,
23     IF_IDE, IF_SCSI, IF_FLOPPY, IF_PFLASH, IF_MTD, IF_SD, IF_VIRTIO, IF_XEN,
24     IF_COUNT
25 } BlockInterfaceType;
26 
27 struct DriveInfo {
28     BlockInterfaceType type;
29     int bus;
30     int unit;
31     int auto_del;               /* see blockdev_mark_auto_del() */
32     bool is_default;            /* Added by default_drive() ?  */
33     int media_cd;
34     QemuOpts *opts;
35     QTAILQ_ENTRY(DriveInfo) next;
36 };
37 
38 /*
39  * Global state (GS) API. These functions run under the BQL.
40  *
41  * See include/block/block-global-state.h for more information about
42  * the GS API.
43  */
44 
45 void blockdev_mark_auto_del(BlockBackend *blk);
46 void blockdev_auto_del(BlockBackend *blk);
47 
48 DriveInfo *blk_legacy_dinfo(BlockBackend *blk);
49 DriveInfo *blk_set_legacy_dinfo(BlockBackend *blk, DriveInfo *dinfo);
50 BlockBackend *blk_by_legacy_dinfo(DriveInfo *dinfo);
51 
52 void override_max_devs(BlockInterfaceType type, int max_devs);
53 
54 DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
55 void drive_check_orphaned(void);
56 DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
57 int drive_get_max_bus(BlockInterfaceType type);
58 
59 QemuOpts *drive_add(BlockInterfaceType type, int index, const char *file,
60                     const char *optstr);
61 DriveInfo *drive_new(QemuOpts *arg, BlockInterfaceType block_default_type,
62                      Error **errp);
63 
64 #endif
65