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 72 #define TYPE_XEN_BLOCK_DEVICE "xen-block" 73 OBJECT_DECLARE_TYPE(XenBlockDevice, XenBlockDeviceClass, XEN_BLOCK_DEVICE) 74 75 struct XenDiskDevice { 76 XenBlockDevice blockdev; 77 }; 78 79 #define TYPE_XEN_DISK_DEVICE "xen-disk" 80 OBJECT_DECLARE_SIMPLE_TYPE(XenDiskDevice, XEN_DISK_DEVICE) 81 82 struct XenCDRomDevice { 83 XenBlockDevice blockdev; 84 }; 85 86 #define TYPE_XEN_CDROM_DEVICE "xen-cdrom" 87 OBJECT_DECLARE_SIMPLE_TYPE(XenCDRomDevice, XEN_CDROM_DEVICE) 88 89 #endif /* HW_XEN_BLOCK_H */ 90