From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:49458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTKqh-0006HD-Rr for qemu-devel@nongnu.org; Tue, 30 Oct 2012 19:03:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TTKqg-0004tt-PL for qemu-devel@nongnu.org; Tue, 30 Oct 2012 19:03:55 -0400 Received: from e28smtp07.in.ibm.com ([122.248.162.7]:51920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TTKqg-0004ob-2s for qemu-devel@nongnu.org; Tue, 30 Oct 2012 19:03:54 -0400 Received: from /spool/local by e28smtp07.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 31 Oct 2012 04:33:51 +0530 Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay05.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q9UN3VSf3867070 for ; Wed, 31 Oct 2012 04:33:31 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q9V4XMSd004476 for ; Wed, 31 Oct 2012 15:33:22 +1100 From: Anthony Liguori Date: Tue, 30 Oct 2012 18:02:58 -0500 Message-Id: <1351638178-15056-9-git-send-email-aliguori@us.ibm.com> In-Reply-To: <1351638178-15056-1-git-send-email-aliguori@us.ibm.com> References: <1351638178-15056-1-git-send-email-aliguori@us.ibm.com> Subject: [Qemu-devel] [PATCH 8/8] virtio-rng-pci: create a default backend if none exists List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Amit Shah , Paolo Bonzini , Anthony Liguori , Andreas Faerber , "H. Peter Anvin" This allows you to specify: $ qemu -device virtio-rng-pci And things will Just Work with a reasonable default. Signed-off-by: Anthony Liguori --- 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