virtio-rng-s390: switch to the new API.
Here the virtio-rng-s390 is modified for the new API. The device virtio-rng-s390 extends virtio-s390-device as before. It creates and connects a virtio-rng during the init. The properties are not modified. Signed-off-by: KONRAD Frederic <fred.konrad@greensocs.com> Tested-by: Cornelia Huck <cornelia.huck@de.ibm.com> Acked-by: Amit Shah <amit.shah@redhat.com> Message-id: 1366790881-3026-5-git-send-email-fred.konrad@greensocs.com Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
parent
59ccd20a9a
commit
0bca1f5313
|
@ -262,16 +262,31 @@ static void s390_vhost_scsi_instance_init(Object *obj)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int s390_virtio_rng_init(VirtIOS390Device *dev)
|
|
||||||
{
|
|
||||||
VirtIODevice *vdev;
|
|
||||||
|
|
||||||
vdev = virtio_rng_init((DeviceState *)dev, &dev->rng);
|
static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
|
||||||
if (!vdev) {
|
{
|
||||||
|
VirtIORNGS390 *dev = VIRTIO_RNG_S390(s390_dev);
|
||||||
|
DeviceState *vdev = DEVICE(&dev->vdev);
|
||||||
|
|
||||||
|
qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
|
||||||
|
if (qdev_init(vdev) < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s390_virtio_device_init(dev, vdev);
|
object_property_set_link(OBJECT(dev),
|
||||||
|
OBJECT(dev->vdev.conf.default_backend), "rng",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void s390_virtio_rng_instance_init(Object *obj)
|
||||||
|
{
|
||||||
|
VirtIORNGS390 *dev = VIRTIO_RNG_S390(obj);
|
||||||
|
object_initialize(OBJECT(&dev->vdev), TYPE_VIRTIO_RNG);
|
||||||
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
||||||
|
(Object **)&dev->vdev.conf.rng, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t s390_virtio_device_vq_token(VirtIOS390Device *dev, int vq)
|
static uint64_t s390_virtio_device_vq_token(VirtIOS390Device *dev, int vq)
|
||||||
|
@ -523,14 +538,6 @@ static const TypeInfo s390_virtio_serial = {
|
||||||
.class_init = s390_virtio_serial_class_init,
|
.class_init = s390_virtio_serial_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void s390_virtio_rng_initfn(Object *obj)
|
|
||||||
{
|
|
||||||
VirtIOS390Device *dev = VIRTIO_S390_DEVICE(obj);
|
|
||||||
|
|
||||||
object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
|
|
||||||
(Object **)&dev->rng.rng, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
|
static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
|
||||||
{
|
{
|
||||||
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
|
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
|
||||||
|
@ -539,10 +546,10 @@ static void s390_virtio_rng_class_init(ObjectClass *klass, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo s390_virtio_rng = {
|
static const TypeInfo s390_virtio_rng = {
|
||||||
.name = "virtio-rng-s390",
|
.name = TYPE_VIRTIO_RNG_S390,
|
||||||
.parent = TYPE_VIRTIO_S390_DEVICE,
|
.parent = TYPE_VIRTIO_S390_DEVICE,
|
||||||
.instance_size = sizeof(VirtIOS390Device),
|
.instance_size = sizeof(VirtIORNGS390),
|
||||||
.instance_init = s390_virtio_rng_initfn,
|
.instance_init = s390_virtio_rng_instance_init,
|
||||||
.class_init = s390_virtio_rng_class_init,
|
.class_init = s390_virtio_rng_class_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -93,7 +93,6 @@ struct VirtIOS390Device {
|
||||||
uint8_t feat_len;
|
uint8_t feat_len;
|
||||||
VirtIODevice *vdev;
|
VirtIODevice *vdev;
|
||||||
uint32_t host_features;
|
uint32_t host_features;
|
||||||
VirtIORNGConf rng;
|
|
||||||
VirtioBusState bus;
|
VirtioBusState bus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -176,4 +175,15 @@ typedef struct VHostSCSIS390 {
|
||||||
} VHostSCSIS390;
|
} VHostSCSIS390;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* virtio-rng-s390 */
|
||||||
|
|
||||||
|
#define TYPE_VIRTIO_RNG_S390 "virtio-rng-s390"
|
||||||
|
#define VIRTIO_RNG_S390(obj) \
|
||||||
|
OBJECT_CHECK(VirtIORNGS390, (obj), TYPE_VIRTIO_RNG_S390)
|
||||||
|
|
||||||
|
typedef struct VirtIORNGS390 {
|
||||||
|
VirtIOS390Device parent_obj;
|
||||||
|
VirtIORNG vdev;
|
||||||
|
} VirtIORNGS390;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue