From: Anthony Liguori <aliguori@us.ibm.com>
To: qemu-devel@nongnu.org
Cc: Amit Shah <amit.shah@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Andreas Faerber <afaerber@suse.de>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: [Qemu-devel] [PATCH 8/8] virtio-rng-pci: create a default backend if none exists
Date: Wed, 31 Oct 2012 17:00:34 -0500 [thread overview]
Message-ID: <1351720834-22805-9-git-send-email-aliguori@us.ibm.com> (raw)
In-Reply-To: <1351720834-22805-1-git-send-email-aliguori@us.ibm.com>
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>
---
hw/virtio-pci.c | 13 +++++++++++++
hw/virtio-rng.h | 2 ++
2 files changed, 15 insertions(+)
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index f90296d..71f4fb5 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;
diff --git a/hw/virtio-rng.h b/hw/virtio-rng.h
index 7324d0a..f42d748 100644
--- a/hw/virtio-rng.h
+++ b/hw/virtio-rng.h
@@ -13,6 +13,7 @@
#define _QEMU_VIRTIO_RNG_H
#include "qemu/rng.h"
+#include "qemu/rng-random.h"
/* The Virtio ID for the virtio rng device */
#define VIRTIO_ID_RNG 4
@@ -21,6 +22,7 @@ struct VirtIORNGConf {
RngBackend *rng;
uint64_t max_bytes;
uint32_t period_ms;
+ RndRandom *default_backend;
};
#endif
--
1.8.0
next prev parent reply other threads:[~2012-10-31 22:01 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-31 22:00 [Qemu-devel] [PATCH 0/8] add paravirtualization hwrng support (v3) Anthony Liguori
2012-10-31 22:00 ` [Qemu-devel] [PATCH 1/8] vl: add -object option to create QOM objects from the command line Anthony Liguori
2012-10-31 22:00 ` [Qemu-devel] [PATCH 2/8] object: add object_property_add_bool (v2) Anthony Liguori
2012-10-31 22:00 ` [Qemu-devel] [PATCH 3/8] rng: add RndBackend abstract object class Anthony Liguori
2012-10-31 22:00 ` [Qemu-devel] [PATCH 4/8] rng-random: add an RNG backend that uses /dev/random (v3) Anthony Liguori
2012-10-31 22:00 ` [Qemu-devel] [PATCH 5/8] rng-egd: introduce EGD compliant RNG backend Anthony Liguori
2012-10-31 22:00 ` [Qemu-devel] [PATCH 6/8] virtio-rng: hardware random number generator device Anthony Liguori
2012-10-31 22:00 ` [Qemu-devel] [PATCH 7/8] virtio-rng: add rate limiting support Anthony Liguori
2012-10-31 22:00 ` Anthony Liguori [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-10-30 23:02 [Qemu-devel] [PATCH 0/8] add paravirtualization hwrng support (v2) Anthony Liguori
2012-10-30 23:02 ` [Qemu-devel] [PATCH 8/8] virtio-rng-pci: create a default backend if none exists 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=1351720834-22805-9-git-send-email-aliguori@us.ibm.com \
--to=aliguori@us.ibm.com \
--cc=afaerber@suse.de \
--cc=amit.shah@redhat.com \
--cc=hpa@zytor.com \
--cc=pbonzini@redhat.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).