diff options
author | Cornelia Huck <cornelia.huck@de.ibm.com> | 2015-04-21 16:36:55 +0200 |
---|---|---|
committer | Cornelia Huck <cornelia.huck@de.ibm.com> | 2015-05-08 10:36:02 +0200 |
commit | 1fa755234e24697cc76f326782edbb09bd0a3a53 (patch) | |
tree | df89f5737993aeb9268dc60f9b0322e83b633493 /hw/s390x | |
parent | 77ae0b2a6e731ab7b97e9fae401c579397edb31c (diff) |
virtio-ccw: change realization sequence
virtio-ccw has an odd sequence of realizing devices: first the
device-specific relization (net, block, ...), then the generic
realization. It feels less odd to have the generic realization
callback trigger the device-specific realization instead (and this
also matches what virtio-pci does).
One thing to note: We need to defer initializing the cu model in the
sense id data until after the device-specific realization has been
performed, as we need to refer to the virtio device's device_id.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Message-Id: <1429627016-30656-2-git-send-email-cornelia.huck@de.ibm.com>
Diffstat (limited to 'hw/s390x')
-rw-r--r-- | hw/s390x/virtio-ccw.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index c1d8288b71..1c2bd9de34 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -642,8 +642,7 @@ static int virtio_ccw_cb(SubchDev *sch, CCW1 ccw) return ret; } -static void virtio_ccw_device_realize(VirtioCcwDevice *dev, - VirtIODevice *vdev, Error **errp) +static void virtio_ccw_device_realize(VirtioCcwDevice *dev, Error **errp) { unsigned int cssid = 0; unsigned int ssid = 0; @@ -654,6 +653,9 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, SubchDev *sch; int num; DeviceState *parent = DEVICE(dev); + Error *err = NULL; + VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_GET_CLASS(dev); + VirtIODevice *vdev; sch = g_malloc0(sizeof(SubchDev)); @@ -766,6 +768,18 @@ static void virtio_ccw_device_realize(VirtioCcwDevice *dev, memset(&sch->id, 0, sizeof(SenseId)); sch->id.reserved = 0xff; sch->id.cu_type = VIRTIO_CCW_CU_TYPE; + + if (k->realize) { + k->realize(dev, &err); + } + if (err) { + error_propagate(errp, err); + css_subch_assign(cssid, ssid, schid, devno, NULL); + goto out_err; + } + + /* device_id is only set after vdev has been realized */ + vdev = virtio_ccw_get_vdev(sch); sch->id.cu_model = vdev->device_id; /* Only the first 32 feature bits are used. */ @@ -813,10 +827,7 @@ static void virtio_ccw_net_realize(VirtioCcwDevice *ccw_dev, Error **errp) object_property_set_bool(OBJECT(vdev), true, "realized", &err); if (err) { error_propagate(errp, err); - return; } - - virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp); } static void virtio_ccw_net_instance_init(Object *obj) @@ -839,10 +850,7 @@ static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp) object_property_set_bool(OBJECT(vdev), true, "realized", &err); if (err) { error_propagate(errp, err); - return; } - - virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp); } static void virtio_ccw_blk_instance_init(Object *obj) @@ -879,10 +887,7 @@ static void virtio_ccw_serial_realize(VirtioCcwDevice *ccw_dev, Error **errp) object_property_set_bool(OBJECT(vdev), true, "realized", &err); if (err) { error_propagate(errp, err); - return; } - - virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp); } @@ -904,10 +909,7 @@ static void virtio_ccw_balloon_realize(VirtioCcwDevice *ccw_dev, Error **errp) object_property_set_bool(OBJECT(vdev), true, "realized", &err); if (err) { error_propagate(errp, err); - return; } - - virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp); } static void balloon_ccw_stats_get_all(Object *obj, struct Visitor *v, @@ -972,10 +974,7 @@ static void virtio_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp) object_property_set_bool(OBJECT(vdev), true, "realized", &err); if (err) { error_propagate(errp, err); - return; } - - virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp); } static void virtio_ccw_scsi_instance_init(Object *obj) @@ -999,10 +998,7 @@ static void vhost_ccw_scsi_realize(VirtioCcwDevice *ccw_dev, Error **errp) object_property_set_bool(OBJECT(vdev), true, "realized", &err); if (err) { error_propagate(errp, err); - return; } - - virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp); } static void vhost_ccw_scsi_instance_init(Object *obj) @@ -1030,8 +1026,6 @@ static void virtio_ccw_rng_realize(VirtioCcwDevice *ccw_dev, Error **errp) object_property_set_link(OBJECT(dev), OBJECT(dev->vdev.conf.rng), "rng", NULL); - - virtio_ccw_device_realize(ccw_dev, VIRTIO_DEVICE(vdev), errp); } /* DeviceState to VirtioCcwDevice. Note: used on datapath, @@ -1640,10 +1634,9 @@ static const TypeInfo virtio_ccw_rng = { static void virtio_ccw_busdev_realize(DeviceState *dev, Error **errp) { VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev; - VirtIOCCWDeviceClass *_info = VIRTIO_CCW_DEVICE_GET_CLASS(dev); virtio_ccw_bus_new(&_dev->bus, sizeof(_dev->bus), _dev); - _info->realize(_dev, errp); + virtio_ccw_device_realize(_dev, errp); } static int virtio_ccw_busdev_exit(DeviceState *dev) |