From: Cornelia Huck <cornelia.huck@de.ibm.com>
To: qemu-devel <qemu-devel@nongnu.org>
Cc: "Blue Swirl" <blauwirbel@gmail.com>,
"Anthony Liguori" <aliguori@us.ibm.com>,
"Aurélien Jarno" <aurelien@aurel32.net>
Subject: [Qemu-devel] [PATCH 2/2] virtio-ccw: Wire up virtio-rng.
Date: Tue, 12 Mar 2013 14:02:47 +0100 [thread overview]
Message-ID: <1363093367-506-3-git-send-email-cornelia.huck@de.ibm.com> (raw)
In-Reply-To: <1363093367-506-1-git-send-email-cornelia.huck@de.ibm.com>
Make virtio-rng devices available for s390-ccw-virtio machines.
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
---
hw/s390x/virtio-ccw.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++
hw/s390x/virtio-ccw.h | 2 ++
2 files changed, 62 insertions(+)
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index 06b9641..d4361f6 100644
--- a/hw/s390x/virtio-ccw.c
+++ b/hw/s390x/virtio-ccw.c
@@ -642,6 +642,30 @@ static int virtio_ccw_scsi_exit(VirtioCcwDevice *dev)
return virtio_ccw_exit(dev);
}
+static int virtio_ccw_rng_init(VirtioCcwDevice *dev)
+{
+ VirtIODevice *vdev;
+
+ if (dev->rng.rng == NULL) {
+ dev->rng.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
+ object_property_add_child(OBJECT(dev), "default-backend",
+ OBJECT(dev->rng.default_backend), NULL);
+ object_property_set_link(OBJECT(dev), OBJECT(dev->rng.default_backend),
+ "rng", NULL);
+ }
+ vdev = virtio_rng_init((DeviceState *)dev, &dev->rng);
+ if (!vdev) {
+ return -1;
+ }
+ return virtio_ccw_device_init(dev, vdev);
+}
+
+static int virtio_ccw_rng_exit(VirtioCcwDevice *dev)
+{
+ virtio_rng_exit(dev->vdev);
+ return virtio_ccw_exit(dev);
+}
+
/* DeviceState to VirtioCcwDevice. Note: used on datapath,
* be careful and test performance if you change this.
*/
@@ -831,6 +855,41 @@ static const TypeInfo virtio_ccw_scsi = {
.class_init = virtio_ccw_scsi_class_init,
};
+static void virtio_ccw_rng_initfn(Object *obj)
+{
+ VirtioCcwDevice *dev = VIRTIO_CCW_DEVICE(obj);
+
+ object_property_add_link(obj, "rng", TYPE_RNG_BACKEND,
+ (Object **)&dev->rng.rng, NULL);
+}
+
+static Property virtio_ccw_rng_properties[] = {
+ DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
+ DEFINE_VIRTIO_COMMON_FEATURES(VirtioCcwDevice, host_features[0]),
+ DEFINE_PROP_UINT64("max-bytes", VirtioCcwDevice, rng.max_bytes, INT64_MAX),
+ DEFINE_PROP_UINT32("period", VirtioCcwDevice, rng.period_ms, 1 << 16),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_ccw_rng_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
+
+ k->init = virtio_ccw_rng_init;
+ k->exit = virtio_ccw_rng_exit;
+ dc->reset = virtio_ccw_reset;
+ dc->props = virtio_ccw_rng_properties;
+}
+
+static const TypeInfo virtio_ccw_rng = {
+ .name = "virtio-rng-ccw",
+ .parent = TYPE_VIRTIO_CCW_DEVICE,
+ .instance_size = sizeof(VirtioCcwDevice),
+ .instance_init = virtio_ccw_rng_initfn,
+ .class_init = virtio_ccw_rng_class_init,
+};
+
static int virtio_ccw_busdev_init(DeviceState *dev)
{
VirtioCcwDevice *_dev = (VirtioCcwDevice *)dev;
@@ -953,6 +1012,7 @@ static void virtio_ccw_register(void)
type_register_static(&virtio_ccw_net);
type_register_static(&virtio_ccw_balloon);
type_register_static(&virtio_ccw_scsi);
+ type_register_static(&virtio_ccw_rng);
type_register_static(&virtual_css_bridge_info);
}
diff --git a/hw/s390x/virtio-ccw.h b/hw/s390x/virtio-ccw.h
index 48474b3..88c46c0 100644
--- a/hw/s390x/virtio-ccw.h
+++ b/hw/s390x/virtio-ccw.h
@@ -16,6 +16,7 @@
#include <hw/virtio-net.h>
#include <hw/virtio-serial.h>
#include <hw/virtio-scsi.h>
+#include <hw/virtio-rng.h>
#include <hw/virtio-bus.h>
#define VIRTUAL_CSSID 0xfe
@@ -77,6 +78,7 @@ struct VirtioCcwDevice {
virtio_serial_conf serial;
virtio_net_conf net;
VirtIOSCSIConf scsi;
+ VirtIORNGConf rng;
VirtioBusState bus;
/* Guest provided values: */
hwaddr indicators;
--
1.7.9.5
next prev parent reply other threads:[~2013-03-12 13:03 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-12 13:02 [Qemu-devel] [PULL 0/2] virtio-ccw patches 2012-03-12 Cornelia Huck
2013-03-12 13:02 ` [Qemu-devel] [PATCH 1/2] virtio-ccw: remove qdev_unparent in unplug routing Cornelia Huck
2013-03-12 13:02 ` Cornelia Huck [this message]
-- strict thread matches above, loose matches on Subject: below --
2013-03-11 15:52 [Qemu-devel] [PATCH 0/2] Pending virtio-ccw patches Cornelia Huck
2013-03-11 15:52 ` [Qemu-devel] [PATCH 2/2] virtio-ccw: Wire up virtio-rng Cornelia Huck
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=1363093367-506-3-git-send-email-cornelia.huck@de.ibm.com \
--to=cornelia.huck@de.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=aurelien@aurel32.net \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).