From: fred.konrad@greensocs.com
To: qemu-devel@nongnu.org, aliguori@us.ibm.com
Cc: peter.maydell@linaro.org, mark.burton@greensocs.com,
Alexander Graf <agraf@suse.de>,
cornelia.huck@de.ibm.com, fred.konrad@greensocs.com,
Richard Henderson <rth@twiddle.net>
Subject: [Qemu-devel] [PATCH v4 4/8] virtio-rng-s390: switch to the new API.
Date: Fri, 19 Apr 2013 15:57:31 +0200 [thread overview]
Message-ID: <1366379855-28649-5-git-send-email-fred.konrad@greensocs.com> (raw)
In-Reply-To: <1366379855-28649-1-git-send-email-fred.konrad@greensocs.com>
From: KONRAD Frederic <fred.konrad@greensocs.com>
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>
---
hw/s390x/s390-virtio-bus.c | 38 ++++++++++++++++++++++----------------
hw/s390x/s390-virtio-bus.h | 12 +++++++++++-
2 files changed, 33 insertions(+), 17 deletions(-)
diff --git a/hw/s390x/s390-virtio-bus.c b/hw/s390x/s390-virtio-bus.c
index ca0e301..4d9f2ec 100644
--- a/hw/s390x/s390-virtio-bus.c
+++ b/hw/s390x/s390-virtio-bus.c
@@ -239,16 +239,30 @@ 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;
+ VirtIORNGS390 *dev = VIRTIO_RNG_S390(s390_dev);
+ DeviceState *vdev = DEVICE(&dev->vdev);
- vdev = virtio_rng_init((DeviceState *)dev, &dev->rng);
- if (!vdev) {
+ qdev_set_parent_bus(vdev, BUS(&s390_dev->bus));
+ if (qdev_init(vdev) < 0) {
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)
@@ -500,14 +514,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);
@@ -516,10 +522,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/s390x/s390-virtio-bus.h b/hw/s390x/s390-virtio-bus.h
index 925ed2b..ba1fb85 100644
--- a/hw/s390x/s390-virtio-bus.h
+++ b/hw/s390x/s390-virtio-bus.h
@@ -90,7 +90,6 @@ struct VirtIOS390Device {
uint8_t feat_len;
VirtIODevice *vdev;
uint32_t host_features;
- VirtIORNGConf rng;
VirtioBusState bus;
};
@@ -160,4 +159,15 @@ typedef struct VirtIONetS390 {
VirtIONet vdev;
} VirtIONetS390;
+/* 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
--
1.7.11.7
next prev parent reply other threads:[~2013-04-19 13:58 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-19 13:57 [Qemu-devel] [PATCH v4 0/8] virtio-rng refactoring fred.konrad
2013-04-19 13:57 ` [Qemu-devel] [PATCH v4 1/8] virtio-rng: don't use pointer for configuration fred.konrad
2013-04-19 13:57 ` [Qemu-devel] [PATCH v4 2/8] virtio-rng: add virtio-rng device fred.konrad
2013-04-19 13:57 ` [Qemu-devel] [PATCH v4 3/8] virtio-rng-pci: switch to the new API fred.konrad
2013-04-19 13:57 ` fred.konrad [this message]
2013-04-19 13:57 ` [Qemu-devel] [PATCH v4 5/8] virtio-rng-ccw: " fred.konrad
2013-04-19 13:57 ` [Qemu-devel] [PATCH v4 6/8] virtio-rng: cleanup: init and exit functions fred.konrad
2013-04-19 13:57 ` [Qemu-devel] [PATCH v4 7/8] virtio-rng: cleanup: remove qdev field fred.konrad
2013-04-19 13:57 ` [Qemu-devel] [PATCH v4 8/8] virtio-rng: cleanup: use QOM casts fred.konrad
2013-04-24 18:25 ` [Qemu-devel] [PATCH v4 0/8] virtio-rng refactoring Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1366379855-28649-5-git-send-email-fred.konrad@greensocs.com \
--to=fred.konrad@greensocs.com \
--cc=agraf@suse.de \
--cc=aliguori@us.ibm.com \
--cc=cornelia.huck@de.ibm.com \
--cc=mark.burton@greensocs.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).