From: KONRAD Frederic <fred.kon...@greensocs.com> Here the virtio-scsi-ccw is modified for the new API. The device virtio-scsi-ccw extends virtio-ccw-device as before. It creates and connects a virtio-scsi during the init. The properties are not modified.
Signed-off-by: KONRAD Frederic <fred.kon...@greensocs.com> --- hw/s390x/virtio-ccw.c | 27 +++++++++++++++------------ hw/s390x/virtio-ccw.h | 12 +++++++++++- 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index f852721..bbe92f5 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -626,22 +626,24 @@ static int virtio_ccw_balloon_exit(VirtioCcwDevice *dev) return virtio_ccw_exit(dev); } -static int virtio_ccw_scsi_init(VirtioCcwDevice *dev) +static int virtio_ccw_scsi_init(VirtioCcwDevice *ccw_dev) { - VirtIODevice *vdev; + VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(ccw_dev); + DeviceState *vdev = DEVICE(&dev->vdev); - vdev = virtio_scsi_init((DeviceState *)dev, &dev->scsi); - if (!vdev) { + qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); + if (qdev_init(vdev) < 0) { return -1; } - return virtio_ccw_device_init(dev, vdev); + return virtio_ccw_device_init(ccw_dev, VIRTIO_DEVICE(vdev)); } -static int virtio_ccw_scsi_exit(VirtioCcwDevice *dev) +static void virtio_ccw_scsi_instance_init(Object *obj) { - virtio_scsi_exit(dev->vdev); - return virtio_ccw_exit(dev); + VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj); + object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_SCSI); + object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL); } static int virtio_ccw_rng_init(VirtioCcwDevice *dev) @@ -836,7 +838,7 @@ static const TypeInfo virtio_ccw_balloon = { static Property virtio_ccw_scsi_properties[] = { DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id), - DEFINE_VIRTIO_SCSI_PROPERTIES(VirtioCcwDevice, scsi), + DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSICcw, vdev.conf), DEFINE_VIRTIO_SCSI_FEATURES(VirtioCcwDevice, host_features[0]), DEFINE_PROP_END_OF_LIST(), }; @@ -847,15 +849,16 @@ static void virtio_ccw_scsi_class_init(ObjectClass *klass, void *data) VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); k->init = virtio_ccw_scsi_init; - k->exit = virtio_ccw_scsi_exit; + k->exit = virtio_ccw_exit; dc->reset = virtio_ccw_reset; dc->props = virtio_ccw_scsi_properties; } static const TypeInfo virtio_ccw_scsi = { - .name = "virtio-scsi-ccw", + .name = TYPE_VIRTIO_SCSI_CCW, .parent = TYPE_VIRTIO_CCW_DEVICE, - .instance_size = sizeof(VirtioCcwDevice), + .instance_size = sizeof(VirtIOSCSICcw), + .instance_init = virtio_ccw_scsi_instance_init, .class_init = virtio_ccw_scsi_class_init, }; diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h index 3993bc5..d9f7399 100644 --- a/hw/s390x/virtio-ccw.h +++ b/hw/s390x/virtio-ccw.h @@ -76,7 +76,6 @@ struct VirtioCcwDevice { uint32_t host_features[VIRTIO_CCW_FEATURE_SIZE]; virtio_serial_conf serial; virtio_net_conf net; - VirtIOSCSIConf scsi; VirtIORNGConf rng; VirtioBusState bus; /* Guest provided values: */ @@ -93,6 +92,17 @@ typedef struct VirtualCssBus { #define VIRTUAL_CSS_BUS(obj) \ OBJECT_CHECK(VirtualCssBus, (obj), TYPE_VIRTUAL_CSS_BUS) +/* virtio-scsi-ccw */ + +#define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw" +#define VIRTIO_SCSI_CCW(obj) \ + OBJECT_CHECK(VirtIOSCSICcw, (obj), TYPE_VIRTIO_SCSI_CCW) + +typedef struct VirtIOSCSICcw { + VirtioCcwDevice parent_obj; + VirtIOSCSI vdev; +} VirtIOSCSICcw; + /* virtio-blk-ccw */ #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw" -- 1.7.11.7