xref: /qemu/include/hw/xen/xen-block.h (revision 1a72d9ae31517b2f83ec7923c820daf1887fde50)
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 
13 typedef enum XenBlockVdevType {
14     XEN_BLOCK_VDEV_TYPE_INVALID,
15     XEN_BLOCK_VDEV_TYPE_DP,
16     XEN_BLOCK_VDEV_TYPE_XVD,
17     XEN_BLOCK_VDEV_TYPE_HD,
18     XEN_BLOCK_VDEV_TYPE_SD,
19     XEN_BLOCK_VDEV_TYPE__MAX
20 } XenBlockVdevType;
21 
22 typedef struct XenBlockVdev {
23     XenBlockVdevType type;
24     unsigned long disk;
25     unsigned long partition;
26     unsigned long number;
27 } XenBlockVdev;
28 
29 typedef struct XenBlockProperties {
30     XenBlockVdev vdev;
31 } XenBlockProperties;
32 
33 typedef struct XenBlockDevice {
34     XenDevice xendev;
35     XenBlockProperties props;
36 } XenBlockDevice;
37 
38 typedef void (*XenBlockDeviceRealize)(XenBlockDevice *blockdev, Error **errp);
39 typedef void (*XenBlockDeviceUnrealize)(XenBlockDevice *blockdev, Error **errp);
40 
41 typedef struct XenBlockDeviceClass {
42     /*< private >*/
43     XenDeviceClass parent_class;
44     /*< public >*/
45     XenBlockDeviceRealize realize;
46     XenBlockDeviceUnrealize unrealize;
47 } XenBlockDeviceClass;
48 
49 #define TYPE_XEN_BLOCK_DEVICE  "xen-block"
50 #define XEN_BLOCK_DEVICE(obj) \
51      OBJECT_CHECK(XenBlockDevice, (obj), TYPE_XEN_BLOCK_DEVICE)
52 #define XEN_BLOCK_DEVICE_CLASS(class) \
53      OBJECT_CLASS_CHECK(XenBlockDeviceClass, (class), TYPE_XEN_BLOCK_DEVICE)
54 #define XEN_BLOCK_DEVICE_GET_CLASS(obj) \
55      OBJECT_GET_CLASS(XenBlockDeviceClass, (obj), TYPE_XEN_BLOCK_DEVICE)
56 
57 typedef struct XenDiskDevice {
58     XenBlockDevice blockdev;
59 } XenDiskDevice;
60 
61 #define TYPE_XEN_DISK_DEVICE  "xen-disk"
62 #define XEN_DISK_DEVICE(obj) \
63      OBJECT_CHECK(XenDiskDevice, (obj), TYPE_XEN_DISK_DEVICE)
64 
65 typedef struct XenCDRomDevice {
66     XenBlockDevice blockdev;
67 } XenCDRomDevice;
68 
69 #define TYPE_XEN_CDROM_DEVICE  "xen-cdrom"
70 #define XEN_CDROM_DEVICE(obj) \
71      OBJECT_CHECK(XenCDRomDevice, (obj), TYPE_XEN_CDROM_DEVICE)
72 
73 #endif /* HW_XEN_BLOCK_H */
74