xref: /qemu/include/hw/xen/xen-block.h (revision 8110fa1d)
1 /*
2  * Copyright (c) 2018  Citrix Systems Inc.
3  *
4  * This work is licensed under the terms of the GNU GPL, version 2 or later.
5  * See the COPYING file in the top-level directory.
6  */
7 
8 #ifndef HW_XEN_BLOCK_H
9 #define HW_XEN_BLOCK_H
10 
11 #include "hw/xen/xen-bus.h"
12 #include "hw/block/block.h"
13 #include "hw/block/dataplane/xen-block.h"
14 #include "sysemu/iothread.h"
15 #include "qom/object.h"
16 
17 typedef enum XenBlockVdevType {
18     XEN_BLOCK_VDEV_TYPE_INVALID,
19     XEN_BLOCK_VDEV_TYPE_DP,
20     XEN_BLOCK_VDEV_TYPE_XVD,
21     XEN_BLOCK_VDEV_TYPE_HD,
22     XEN_BLOCK_VDEV_TYPE_SD,
23     XEN_BLOCK_VDEV_TYPE__MAX
24 } XenBlockVdevType;
25 
26 typedef struct XenBlockVdev {
27     XenBlockVdevType type;
28     unsigned long disk;
29     unsigned long partition;
30     unsigned long number;
31 } XenBlockVdev;
32 
33 
34 typedef struct XenBlockProperties {
35     XenBlockVdev vdev;
36     BlockConf conf;
37     unsigned int max_ring_page_order;
38     IOThread *iothread;
39 } XenBlockProperties;
40 
41 typedef struct XenBlockDrive {
42     char *id;
43     char *node_name;
44 } XenBlockDrive;
45 
46 typedef struct XenBlockIOThread {
47     char *id;
48 } XenBlockIOThread;
49 
50 struct XenBlockDevice {
51     XenDevice xendev;
52     XenBlockProperties props;
53     const char *device_type;
54     unsigned int info;
55     XenBlockDataPlane *dataplane;
56     XenBlockDrive *drive;
57     XenBlockIOThread *iothread;
58 };
59 typedef struct XenBlockDevice XenBlockDevice;
60 
61 typedef void (*XenBlockDeviceRealize)(XenBlockDevice *blockdev, Error **errp);
62 typedef void (*XenBlockDeviceUnrealize)(XenBlockDevice *blockdev);
63 
64 struct XenBlockDeviceClass {
65     /*< private >*/
66     XenDeviceClass parent_class;
67     /*< public >*/
68     XenBlockDeviceRealize realize;
69     XenBlockDeviceUnrealize unrealize;
70 };
71 typedef struct XenBlockDeviceClass XenBlockDeviceClass;
72 
73 #define TYPE_XEN_BLOCK_DEVICE  "xen-block"
74 DECLARE_OBJ_CHECKERS(XenBlockDevice, XenBlockDeviceClass,
75                      XEN_BLOCK_DEVICE, TYPE_XEN_BLOCK_DEVICE)
76 
77 struct XenDiskDevice {
78     XenBlockDevice blockdev;
79 };
80 typedef struct XenDiskDevice XenDiskDevice;
81 
82 #define TYPE_XEN_DISK_DEVICE  "xen-disk"
83 DECLARE_INSTANCE_CHECKER(XenDiskDevice, XEN_DISK_DEVICE,
84                          TYPE_XEN_DISK_DEVICE)
85 
86 struct XenCDRomDevice {
87     XenBlockDevice blockdev;
88 };
89 typedef struct XenCDRomDevice XenCDRomDevice;
90 
91 #define TYPE_XEN_CDROM_DEVICE  "xen-cdrom"
92 DECLARE_INSTANCE_CHECKER(XenCDRomDevice, XEN_CDROM_DEVICE,
93                          TYPE_XEN_CDROM_DEVICE)
94 
95 #endif /* HW_XEN_BLOCK_H */
96