xref: /qemu/include/hw/xen/xen-block.h (revision a81df1b6)
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 
16 typedef enum XenBlockVdevType {
17     XEN_BLOCK_VDEV_TYPE_INVALID,
18     XEN_BLOCK_VDEV_TYPE_DP,
19     XEN_BLOCK_VDEV_TYPE_XVD,
20     XEN_BLOCK_VDEV_TYPE_HD,
21     XEN_BLOCK_VDEV_TYPE_SD,
22     XEN_BLOCK_VDEV_TYPE__MAX
23 } XenBlockVdevType;
24 
25 typedef struct XenBlockVdev {
26     XenBlockVdevType type;
27     unsigned long disk;
28     unsigned long partition;
29     unsigned long number;
30 } XenBlockVdev;
31 
32 
33 typedef struct XenBlockProperties {
34     XenBlockVdev vdev;
35     BlockConf conf;
36     unsigned int max_ring_page_order;
37     IOThread *iothread;
38 } XenBlockProperties;
39 
40 typedef struct XenBlockDrive {
41     char *id;
42     char *node_name;
43 } XenBlockDrive;
44 
45 typedef struct XenBlockIOThread {
46     char *id;
47 } XenBlockIOThread;
48 
49 typedef struct XenBlockDevice {
50     XenDevice xendev;
51     XenBlockProperties props;
52     const char *device_type;
53     unsigned int info;
54     XenBlockDataPlane *dataplane;
55     XenBlockDrive *drive;
56     XenBlockIOThread *iothread;
57 } XenBlockDevice;
58 
59 typedef void (*XenBlockDeviceRealize)(XenBlockDevice *blockdev, Error **errp);
60 typedef void (*XenBlockDeviceUnrealize)(XenBlockDevice *blockdev);
61 
62 typedef struct XenBlockDeviceClass {
63     /*< private >*/
64     XenDeviceClass parent_class;
65     /*< public >*/
66     XenBlockDeviceRealize realize;
67     XenBlockDeviceUnrealize unrealize;
68 } XenBlockDeviceClass;
69 
70 #define TYPE_XEN_BLOCK_DEVICE  "xen-block"
71 #define XEN_BLOCK_DEVICE(obj) \
72      OBJECT_CHECK(XenBlockDevice, (obj), TYPE_XEN_BLOCK_DEVICE)
73 #define XEN_BLOCK_DEVICE_CLASS(class) \
74      OBJECT_CLASS_CHECK(XenBlockDeviceClass, (class), TYPE_XEN_BLOCK_DEVICE)
75 #define XEN_BLOCK_DEVICE_GET_CLASS(obj) \
76      OBJECT_GET_CLASS(XenBlockDeviceClass, (obj), TYPE_XEN_BLOCK_DEVICE)
77 
78 typedef struct XenDiskDevice {
79     XenBlockDevice blockdev;
80 } XenDiskDevice;
81 
82 #define TYPE_XEN_DISK_DEVICE  "xen-disk"
83 #define XEN_DISK_DEVICE(obj) \
84      OBJECT_CHECK(XenDiskDevice, (obj), TYPE_XEN_DISK_DEVICE)
85 
86 typedef struct XenCDRomDevice {
87     XenBlockDevice blockdev;
88 } XenCDRomDevice;
89 
90 #define TYPE_XEN_CDROM_DEVICE  "xen-cdrom"
91 #define XEN_CDROM_DEVICE(obj) \
92      OBJECT_CHECK(XenCDRomDevice, (obj), TYPE_XEN_CDROM_DEVICE)
93 
94 #endif /* HW_XEN_BLOCK_H */
95