aboutsummaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2013-03-15 10:47:00 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2013-03-15 10:47:00 -0500
commitd4d7682484f339d70355b165a15f8f5e83638e40 (patch)
tree285ee8c912a0d7a461c38cd36ac37037f207a443 /hw
parent4f306496183d81aed4b43762cf3bfd6e054de767 (diff)
parent2362ecc5c6f4073f7f4c9c3f45c335aa8a2261bb (diff)
Merge remote-tracking branch 'cohuck/virtio-ccw-upstr' into staging
# By Christian Borntraeger (1) and Cornelia Huck (1) # Via Cornelia Huck * cohuck/virtio-ccw-upstr: virtio-ccw: Wire up virtio-rng. virtio-ccw: remove qdev_unparent in unplug routing
Diffstat (limited to 'hw')
-rw-r--r--hw/s390x/virtio-ccw.c61
-rw-r--r--hw/s390x/virtio-ccw.h2
2 files changed, 62 insertions, 1 deletions
diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c
index a9cf703d53..d4361f6e3e 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;
@@ -865,7 +924,6 @@ static int virtio_ccw_busdev_unplug(DeviceState *dev)
css_generate_sch_crws(sch->cssid, sch->ssid, sch->schid, 1, 0);
- object_unparent(OBJECT(dev));
qdev_free(dev);
return 0;
}
@@ -954,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 48474b31ab..88c46c081b 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;