[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH V3 30/44] virtio-rng-s390: switch to the new API.
From: |
fred . konrad |
Subject: |
[Qemu-devel] [PATCH V3 30/44] virtio-rng-s390: switch to the new API. |
Date: |
Tue, 15 Jan 2013 15:09:44 +0100 |
From: KONRAD Frederic <address@hidden>
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 <address@hidden>
---
hw/s390-virtio-bus.c | 35 ++++++++++++++++++-----------------
hw/s390-virtio-bus.h | 13 ++++++++++++-
2 files changed, 30 insertions(+), 18 deletions(-)
diff --git a/hw/s390-virtio-bus.c b/hw/s390-virtio-bus.c
index 1c6a40e..0610594 100644
--- a/hw/s390-virtio-bus.c
+++ b/hw/s390-virtio-bus.c
@@ -229,16 +229,25 @@ static void s390_virtio_scsi_instance_init(Object *obj)
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
}
-static int s390_virtio_rng_init(VirtIOS390Device *dev)
+static int s390_virtio_rng_init(VirtIOS390Device *s390_dev)
{
- VirtIODevice *vdev;
-
- vdev = virtio_rng_init((DeviceState *)dev, &dev->rng);
- if (!vdev) {
+ VirtIORNGS390 *dev = VIRTIO_RNG_S390(s390_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
+ virtio_rng_set_conf(vdev, &(dev->rng));
+ qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
+ if (qdev_init(vdev) < 0) {
return -1;
}
+ return s390_virtio_device_init(s390_dev, VIRTIO_DEVICE(vdev));
+}
- return s390_virtio_device_init(dev, 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->rng.rng, NULL);
}
static uint64_t s390_virtio_device_vq_token(VirtIOS390Device *dev, int vq)
@@ -498,14 +507,6 @@ static const TypeInfo s390_virtio_serial = {
.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)
{
VirtIOS390DeviceClass *k = VIRTIO_S390_DEVICE_CLASS(klass);
@@ -514,10 +515,10 @@ static void s390_virtio_rng_class_init(ObjectClass
*klass, void *data)
}
static const TypeInfo s390_virtio_rng = {
- .name = "virtio-rng-s390",
+ .name = TYPE_VIRTIO_RNG_S390,
.parent = TYPE_VIRTIO_S390_DEVICE,
- .instance_size = sizeof(VirtIOS390Device),
- .instance_init = s390_virtio_rng_initfn,
+ .instance_size = sizeof(VirtIORNGS390),
+ .instance_init = s390_virtio_rng_instance_init,
.class_init = s390_virtio_rng_class_init,
};
diff --git a/hw/s390-virtio-bus.h b/hw/s390-virtio-bus.h
index 2d63485..1efef2e 100644
--- a/hw/s390-virtio-bus.h
+++ b/hw/s390-virtio-bus.h
@@ -91,7 +91,6 @@ struct VirtIOS390Device {
VirtIODevice *vdev;
uint32_t host_features;
virtio_serial_conf serial;
- VirtIORNGConf rng;
VirtioBusState bus;
};
@@ -153,5 +152,17 @@ typedef struct VirtIOSCSIS390 {
VirtIOSCSIConf scsi;
} VirtIOSCSIS390;
+/* 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;
+ VirtIORNGConf rng;
+} VirtIORNGS390;
+
#endif
--
1.7.11.7
- [Qemu-devel] [PATCH V3 06/44] virtio-blk: cleanup: use QOM cast., (continued)
- [Qemu-devel] [PATCH V3 06/44] virtio-blk: cleanup: use QOM cast., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 36/44] virtio-serial-pci: switch to the new API., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 19/44] virtio-scsi-s390: switch to the new API., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 26/44] virtio-balloon: cleanup: QOM casts., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 34/44] virtio-rng.c: cleanup: use QOM casts., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 27/44] virtio-balloon: cleanup: remove qdev field., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 29/44] virtio-rng: add virtio-rng device., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 42/44] virtio-9p-pci: switch to the new API., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 21/44] virtio-scsi: cleanup: init and exit functions., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 30/44] virtio-rng-s390: switch to the new API.,
fred . konrad <=
- [Qemu-devel] [PATCH V3 35/44] virtio-serial: add the virtio-serial device., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 43/44] virtio-9p: cleanup: init function., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 24/44] virtio-balloon-pci: switch to the new API., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 23/44] virtio-balloon: add the virtio-balloon device., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 28/44] virtio-rng: don't use pointer for configuration., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 25/44] virtio-balloon: cleanup: init and exit function., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 16/44] virtio-scsi: moving host_features from properties to transport properties., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 37/44] virtio-serial-s390: switch to the new API., fred . konrad, 2013/01/15
- [Qemu-devel] [PATCH V3 38/44] virtio-serial: cleanup: init and exit functions., fred . konrad, 2013/01/15