summary refs log tree commit diff stats
path: root/hw/virtio-pci.c
diff options
context:
space:
mode:
authorAnthony Liguori <aliguori@us.ibm.com>2012-10-26 12:05:49 -0500
committerAnthony Liguori <aliguori@us.ibm.com>2012-11-16 08:36:14 -0600
commit500054f161c29ff9db125c0b872809191ad6920b (patch)
tree6857931a231d99a94f8245d7479e24354c22b813 /hw/virtio-pci.c
parent904d6f588063fb5ad2b61998acdf1e73fb465067 (diff)
downloadfocaccia-qemu-500054f161c29ff9db125c0b872809191ad6920b.tar.gz
focaccia-qemu-500054f161c29ff9db125c0b872809191ad6920b.zip
virtio-rng-pci: create a default backend if none exists
This allows you to specify:

  $ qemu -device virtio-rng-pci

And things will Just Work with a reasonable default.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'hw/virtio-pci.c')
-rw-r--r--hw/virtio-pci.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index f90296d672..71f4fb5dc6 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -857,6 +857,19 @@ static int virtio_rng_init_pci(PCIDevice *pci_dev)
     VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
     VirtIODevice *vdev;
 
+    if (proxy->rng.rng == NULL) {
+        proxy->rng.default_backend = RNG_RANDOM(object_new(TYPE_RNG_RANDOM));
+
+        object_property_add_child(OBJECT(pci_dev),
+                                  "default-backend",
+                                  OBJECT(proxy->rng.default_backend),
+                                  NULL);
+
+        object_property_set_link(OBJECT(pci_dev),
+                                 OBJECT(proxy->rng.default_backend),
+                                 "rng", NULL);
+    }
+
     vdev = virtio_rng_init(&pci_dev->qdev, &proxy->rng);
     if (!vdev) {
         return -1;