aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2015-02-27 14:55:37 +0100
committerChristian Borntraeger <borntraeger@de.ibm.com>2015-03-10 09:26:23 +0100
commitf35dd5665142022ae9e8c2749db774da275549c2 (patch)
treeed956985abf9032007608e032d61cb03cb132450
parente3e300d24c4131060c6b3d3e20c890eb92f18597 (diff)
downloadqemu-f35dd5665142022ae9e8c2749db774da275549c2.zip
qemu-f35dd5665142022ae9e8c2749db774da275549c2.tar.gz
qemu-f35dd5665142022ae9e8c2749db774da275549c2.tar.bz2
virtio-s390: Convert to realize()
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <1425045337-20138-3-git-send-email-armbru@redhat.com> Acked-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
-rw-r--r--hw/s390x/s390-virtio-bus.c80
-rw-r--r--hw/s390x/s390-virtio-bus.h2
2 files changed, 47 insertions, 35 deletions
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index f69ff11..55a5581 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -138,22 +138,24 @@ static void s390_virtio_device_init(VirtIOS390Device *dev,
}
}
-static int s390_virtio_net_init(VirtIOS390Device *s390_dev)
+static void s390_virtio_net_realize(VirtIOS390Device *s390_dev, Error **errp)
{
DeviceState *qdev = DEVICE(s390_dev);
VirtIONetS390 *dev = VIRTIO_NET_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
+ Error *err = NULL;
virtio_net_set_config_size(&dev->vdev, s390_dev->host_features);
virtio_net_set_netclient_name(&dev->vdev, qdev->id,
object_get_typename(OBJECT(qdev)));
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
- if (qdev_init(vdev) < 0) {
- return -1;
+ object_property_set_bool(OBJECT(vdev), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
}
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
- return 0;
}
static void s390_virtio_net_instance_init(Object *obj)
@@ -166,16 +168,19 @@ static void s390_virtio_net_instance_init(Object *obj)
"bootindex", &error_abort);
}
-static int s390_virtio_blk_init(VirtIOS390Device *s390_dev)
+static void s390_virtio_blk_realize(VirtIOS390Device *s390_dev, Error **errp)
{
VirtIOBlkS390 *dev = VIRTIO_BLK_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
+ Error *err = NULL;
+
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
- if (qdev_init(vdev) < 0) {
- return -1;
+ object_property_set_bool(OBJECT(vdev), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
}
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
- return 0;
}
static void s390_virtio_blk_instance_init(Object *obj)
@@ -190,13 +195,13 @@ static void s390_virtio_blk_instance_init(Object *obj)
"bootindex", &error_abort);
}
-static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
+static void s390_virtio_serial_realize(VirtIOS390Device *s390_dev, Error **errp)
{
VirtIOSerialS390 *dev = VIRTIO_SERIAL_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *qdev = DEVICE(s390_dev);
+ Error *err = NULL;
VirtIOS390Bus *bus;
- int r;
char *bus_name;
bus = DO_UPCAST(VirtIOS390Bus, bus, qdev->parent_bus);
@@ -212,13 +217,14 @@ static int s390_virtio_serial_init(VirtIOS390Device *s390_dev)
}
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
- if (qdev_init(vdev) < 0) {
- return -1;
+ object_property_set_bool(OBJECT(vdev), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
}
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
bus->console = s390_dev;
- return 0;
}
static void s390_virtio_serial_instance_init(Object *obj)
@@ -229,11 +235,12 @@ static void s390_virtio_serial_instance_init(Object *obj)
TYPE_VIRTIO_SERIAL);
}
-static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
+static void s390_virtio_scsi_realize(VirtIOS390Device *s390_dev, Error **errp)
{
VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
DeviceState *qdev = DEVICE(s390_dev);
+ Error *err = NULL;
char *bus_name;
/*
@@ -247,12 +254,13 @@ static int s390_virtio_scsi_init(VirtIOS390Device *s390_dev)
}
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
- if (qdev_init(vdev) < 0) {
- return -1;
+ object_property_set_bool(OBJECT(vdev), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
}
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
- return 0;
}
static void s390_virtio_scsi_instance_init(Object *obj)
@@ -264,18 +272,20 @@ static void s390_virtio_scsi_instance_init(Object *obj)
}
#ifdef CONFIG_VHOST_SCSI
-static int s390_vhost_scsi_init(VirtIOS390Device *s390_dev)
+static void s390_vhost_scsi_realize(VirtIOS390Device *s390_dev, Error **errp)
{
VHostSCSIS390 *dev = VHOST_SCSI_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
+ Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
- if (qdev_init(vdev) < 0) {
- return -1;
+ object_property_set_bool(OBJECT(vdev), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
}
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
- return 0;
}
static void s390_vhost_scsi_instance_init(Object *obj)
@@ -288,14 +298,17 @@ static void s390_vhost_scsi_instance_init(Object *obj)
#endif
-static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
+static void s390_virtio_rng_realize(VirtIOS390Device *s390_dev, Error **errp)
{
VirtIORNGS390 *dev = VIRTIO_RNG_S390(s390_dev);
DeviceState *vdev = DEVICE(&dev->vdev);
+ Error *err = NULL;
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
- if (qdev_init(vdev) < 0) {
- return -1;
+ object_property_set_bool(OBJECT(vdev), true, "realized", &err);
+ if (err) {
+ error_propagate(errp, err);
+ return;
}
object_property_set_link(OBJECT(dev),
@@ -303,7 +316,6 @@ static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
NULL);
s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
- return 0;
}
static void s390_virtio_rng_instance_init(Object *obj)
@@ -510,7 +522,7 @@ static void s390_virtio_net_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
- k->init = s390_virtio_net_init;
+ k->realize = s390_virtio_net_realize;
dc->props = s390_virtio_net_properties;
}
@@ -526,7 +538,7 @@ static void s390_virtio_blk_class_init(ObjectClass *klass, void *data)
{
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
- k->init = s390_virtio_blk_init;
+ k->realize = s390_virtio_blk_realize;
}
static const TypeInfo s390_virtio_blk = {
@@ -546,7 +558,7 @@ static void s390_virtio_serial_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
- k->init = s390_virtio_serial_init;
+ k->realize = s390_virtio_serial_realize;
dc->props = s390_virtio_serial_properties;
}
@@ -568,7 +580,7 @@ static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
- k->init = s390_virtio_rng_init;
+ k->realize = s390_virtio_rng_realize;
dc->props = s390_virtio_rng_properties;
}
@@ -580,14 +592,14 @@ static const TypeInfo s390_virtio_rng = {
.class_init = s390_virtio_rng_class_init,
};
-static int s390_virtio_busdev_init(DeviceState *dev)
+static void s390_virtio_busdev_realize(DeviceState *dev, Error **errp)
{
VirtIOS390Device *_dev = (VirtIOS390Device *)dev;
VirtIOS390DeviceClass *_info = VIRTIO_S390_DEVICE_GET_CLASS(dev);
virtio_s390_bus_new(&_dev->bus, sizeof(_dev->bus), _dev);
- return _info->init(_dev);
+ _info->realize(_dev, errp);
}
static void s390_virtio_busdev_reset(DeviceState *dev)
@@ -601,7 +613,7 @@ static void virtio_s390_device_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- dc->init = s390_virtio_busdev_init;
+ dc->realize = s390_virtio_busdev_realize;
dc->bus_type = TYPE_S390_VIRTIO_BUS;
dc->reset = s390_virtio_busdev_reset;
}
@@ -626,7 +638,7 @@ static void s390_virtio_scsi_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
- k->init = s390_virtio_scsi_init;
+ k->realize = s390_virtio_scsi_realize;
dc->props = s390_virtio_scsi_properties;
}
@@ -649,7 +661,7 @@ static void s390_vhost_scsi_class_init(ObjectClass *klass, void *data)
DeviceClass *dc = DEVICE_CLASS(klass);
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
- k->init = s390_vhost_scsi_init;
+ k->realize = s390_vhost_scsi_realize;
dc->props = s390_vhost_scsi_properties;
}
diff --git a/hw/s390x/s390-virtio-bus.h b/hw/s390x/s390-virtio-bus.h
index 92aa9d0..810a6ef 100644
--- a/hw/s390x/s390-virtio-bus.h
+++ b/hw/s390x/s390-virtio-bus.h
@@ -83,7 +83,7 @@ typedef struct VirtIOS390Device VirtIOS390Device;
typedef struct VirtIOS390DeviceClass {
DeviceClass qdev;
- int (*init)(VirtIOS390Device *dev);
+ void (*realize)(VirtIOS390Device *dev, Error **errp);
} VirtIOS390DeviceClass;
struct VirtIOS390Device {