aboutsummaryrefslogtreecommitdiff
path: root/hw/scsi-disk.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2011-12-15 14:50:08 -0600
committerAnthony Liguori <aliguori@us.ibm.com>2012-01-27 10:50:49 -0600
commitb9eea3e6a435a79fe308212157e0875442b760e4 (patch)
tree72820942672405937d8cb864f6cc9fa22dcfeed2 /hw/scsi-disk.c
parentd148211c6d64b6e59181a5b9c89117c541419cab (diff)
scsi: convert to QEMU Object Model
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/scsi-disk.c')
-rw-r--r--hw/scsi-disk.c159
1 files changed, 96 insertions, 63 deletions
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index 11cfe73df8..2be6b67e69 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1712,75 +1712,108 @@ static SCSIRequest *scsi_block_new_request(SCSIDevice *d, uint32_t tag,
DEFINE_PROP_STRING("ver", SCSIDiskState, version), \
DEFINE_PROP_STRING("serial", SCSIDiskState, serial)
-static SCSIDeviceInfo scsi_disk_info[] = {
- {
- .qdev.name = "scsi-hd",
- .qdev.fw_name = "disk",
- .qdev.desc = "virtual SCSI disk",
- .qdev.size = sizeof(SCSIDiskState),
- .qdev.reset = scsi_disk_reset,
- .init = scsi_hd_initfn,
- .destroy = scsi_destroy,
- .alloc_req = scsi_new_request,
- .unit_attention_reported = scsi_disk_unit_attention_reported,
- .qdev.props = (Property[]) {
- DEFINE_SCSI_DISK_PROPERTIES(),
- DEFINE_PROP_BIT("removable", SCSIDiskState, removable, 0, false),
- DEFINE_PROP_END_OF_LIST(),
- }
- },{
- .qdev.name = "scsi-cd",
- .qdev.fw_name = "disk",
- .qdev.desc = "virtual SCSI CD-ROM",
- .qdev.size = sizeof(SCSIDiskState),
- .qdev.reset = scsi_disk_reset,
- .init = scsi_cd_initfn,
- .destroy = scsi_destroy,
- .alloc_req = scsi_new_request,
- .unit_attention_reported = scsi_disk_unit_attention_reported,
- .qdev.props = (Property[]) {
- DEFINE_SCSI_DISK_PROPERTIES(),
- DEFINE_PROP_END_OF_LIST(),
- },
+static void scsi_hd_class_initfn(ObjectClass *klass, void *data)
+{
+ 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;
+}
+
+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 void scsi_cd_class_initfn(ObjectClass *klass, void *data)
+{
+ 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;
+}
+
+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(),
+ },
+};
+
#ifdef __linux__
- },{
- .qdev.name = "scsi-block",
- .qdev.fw_name = "disk",
- .qdev.desc = "SCSI block device passthrough",
- .qdev.size = sizeof(SCSIDiskState),
- .qdev.reset = scsi_disk_reset,
- .init = scsi_block_initfn,
- .destroy = scsi_destroy,
- .alloc_req = scsi_block_new_request,
- .qdev.props = (Property[]) {
- DEFINE_SCSI_DISK_PROPERTIES(),
- DEFINE_PROP_END_OF_LIST(),
- },
+static void scsi_block_class_initfn(ObjectClass *klass, void *data)
+{
+ SCSIDeviceClass *sc = SCSI_DEVICE_CLASS(klass);
+
+ sc->init = scsi_block_initfn;
+ sc->destroy = scsi_destroy;
+ sc->alloc_req = scsi_block_new_request;
+}
+
+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(),
+ },
+};
#endif
- },{
- .qdev.name = "scsi-disk", /* legacy -device scsi-disk */
- .qdev.fw_name = "disk",
- .qdev.desc = "virtual SCSI disk or CD-ROM (legacy)",
- .qdev.size = sizeof(SCSIDiskState),
- .qdev.reset = scsi_disk_reset,
- .init = scsi_disk_initfn,
- .destroy = scsi_destroy,
- .alloc_req = scsi_new_request,
- .unit_attention_reported = scsi_disk_unit_attention_reported,
- .qdev.props = (Property[]) {
- 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)
+{
+ 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;
+}
+
+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 void scsi_disk_register_devices(void)
{
- int i;
-
- for (i = 0; i < ARRAY_SIZE(scsi_disk_info); i++) {
- scsi_qdev_register(&scsi_disk_info[i]);
- }
+ scsi_qdev_register(&scsi_hd_info);
+ scsi_qdev_register(&scsi_cd_info);
+#ifdef __linux__
+ scsi_qdev_register(&scsi_block_info);
+#endif
+ scsi_qdev_register(&scsi_disk_info);
}
device_init(scsi_disk_register_devices)