diff options
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r-- | hw/scsi-disk.c | 116 |
1 files changed, 66 insertions, 50 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c index 2be6b67e69..399e51e494 100644 --- a/hw/scsi-disk.c +++ b/hw/scsi-disk.c @@ -1712,108 +1712,124 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag, DEFINE_PROP_STRING("ver", SCSIDiskState, version), \ DEFINE_PROP_STRING("serial", SCSIDiskState, serial) +static Property scsi_hd_properties[] = { + DEFINE_SCSI_DISK_PROPERTIES(), + DEFINE_PROP_BIT("removable", SCSIDiskState, removable, 0, false), + DEFINE_PROP_END_OF_LIST(), +}; + static void scsi_hd_class_initfn(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass); sc->init = scsi_hd_initfn; sc->destroy = scsi_destroy; sc->alloc_req = scsi_new_request; sc->unit_attention_reported = scsi_disk_unit_attention_reported; + dc->fw_name = "disk"; + dc->desc = "virtual SCSI disk"; + dc->reset = scsi_disk_reset; + dc->props = scsi_hd_properties; } -static DeviceInfo scsi_hd_info = { - .name = "scsi-hd", - .fw_name = "disk", - .desc = "virtual SCSI disk", - .size = sizeof(SCSIDiskState), - .reset = scsi_disk_reset, - .class_init = scsi_hd_class_initfn, - .props = (Property[]) { - DEFINE_SCSI_DISK_PROPERTIES(), - DEFINE_PROP_BIT("removable", SCSIDiskState, removable, 0, false), - DEFINE_PROP_END_OF_LIST(), - }, +static TypeInfo scsi_hd_info = { + .name = "scsi-hd", + .parent = TYPE_SCSI_DEVICE, + .instance_size = sizeof(SCSIDiskState), + .class_init = scsi_hd_class_initfn, +}; + +static Property scsi_cd_properties[] = { + DEFINE_SCSI_DISK_PROPERTIES(), + DEFINE_PROP_END_OF_LIST(), }; static void scsi_cd_class_initfn(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass); sc->init = scsi_cd_initfn; sc->destroy = scsi_destroy; sc->alloc_req = scsi_new_request; sc->unit_attention_reported = scsi_disk_unit_attention_reported; + dc->fw_name = "disk"; + dc->desc = "virtual SCSI CD-ROM"; + dc->reset = scsi_disk_reset; + dc->props = scsi_cd_properties; } -static DeviceInfo scsi_cd_info = { - .name = "scsi-cd", - .fw_name = "disk", - .desc = "virtual SCSI CD-ROM", - .size = sizeof(SCSIDiskState), - .reset = scsi_disk_reset, - .class_init = scsi_cd_class_initfn, - .props = (Property[]) { - DEFINE_SCSI_DISK_PROPERTIES(), - DEFINE_PROP_END_OF_LIST(), - }, +static TypeInfo scsi_cd_info = { + .name = "scsi-cd", + .parent = TYPE_SCSI_DEVICE, + .instance_size = sizeof(SCSIDiskState), + .class_init = scsi_cd_class_initfn, }; #ifdef __linux__ +static Property scsi_block_properties[] = { + DEFINE_SCSI_DISK_PROPERTIES(), + DEFINE_PROP_END_OF_LIST(), +}; + static void scsi_block_class_initfn(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass); sc->init = scsi_block_initfn; sc->destroy = scsi_destroy; sc->alloc_req = scsi_block_new_request; + dc->fw_name = "disk"; + dc->desc = "SCSI block device passthrough"; + dc->reset = scsi_disk_reset; + dc->props = scsi_block_properties; } -static DeviceInfo scsi_block_info = { - .name = "scsi-block", - .fw_name = "disk", - .desc = "SCSI block device passthrough", - .size = sizeof(SCSIDiskState), - .reset = scsi_disk_reset, - .class_init = scsi_block_class_initfn, - .props = (Property[]) { - DEFINE_SCSI_DISK_PROPERTIES(), - DEFINE_PROP_END_OF_LIST(), - }, +static TypeInfo scsi_block_info = { + .name = "scsi-block", + .parent = TYPE_SCSI_DEVICE, + .instance_size = sizeof(SCSIDiskState), + .class_init = scsi_block_class_initfn, }; #endif +static Property scsi_disk_properties[] = { + DEFINE_SCSI_DISK_PROPERTIES(), + DEFINE_PROP_BIT("removable", SCSIDiskState, removable, 0, false), + DEFINE_PROP_END_OF_LIST(), +}; + static void scsi_disk_class_initfn(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass); sc->init = scsi_disk_initfn; sc->destroy = scsi_destroy; sc->alloc_req = scsi_new_request; sc->unit_attention_reported = scsi_disk_unit_attention_reported; + dc->fw_name = "disk"; + dc->desc = "virtual SCSI disk or CD-ROM (legacy)"; + dc->reset = scsi_disk_reset; + dc->props = scsi_disk_properties; } -static DeviceInfo scsi_disk_info = { - .name = "scsi-disk", /* legacy -device scsi-disk */ - .fw_name = "disk", - .desc = "virtual SCSI disk or CD-ROM (legacy)", - .size = sizeof(SCSIDiskState), - .reset = scsi_disk_reset, - .class_init = scsi_disk_class_initfn, - .props = (Property[]) { - DEFINE_SCSI_DISK_PROPERTIES(), - DEFINE_PROP_BIT("removable", SCSIDiskState, removable, 0, false), - DEFINE_PROP_END_OF_LIST(), - } +static TypeInfo scsi_disk_info = { + .name = "scsi-disk", + .parent = TYPE_SCSI_DEVICE, + .instance_size = sizeof(SCSIDiskState), + .class_init = scsi_disk_class_initfn, }; static void scsi_disk_register_devices(void) { - scsi_qdev_register(&scsi_hd_info); - scsi_qdev_register(&scsi_cd_info); + type_register_static(&scsi_hd_info); + type_register_static(&scsi_cd_info); #ifdef __linux__ - scsi_qdev_register(&scsi_block_info); + type_register_static(&scsi_block_info); #endif - scsi_qdev_register(&scsi_disk_info); + type_register_static(&scsi_disk_info); } device_init(scsi_disk_register_devices) |