[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists |
Date: |
Fri, 26 Oct 2012 20:59:54 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 |
Il 26/10/2012 19:21, Anthony Liguori ha scritto:
> This allows you to specify:
>
> $ qemu -device virtio-rng-pci
>
> And things will Just Work with a reasonable default.
>
> Signed-off-by: Anthony Liguori <address@hidden>
> ---
> 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 0dc2a06..cfdb779 100644
> --- a/hw/virtio-pci.c
> +++ b/hw/virtio-pci.c
> @@ -885,6 +885,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 fbb0104..63ddb96 100644
> --- a/hw/virtio-rng.h
> +++ b/hw/virtio-rng.h
> @@ -13,12 +13,14 @@
> #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
>
> struct VirtIORNGConf {
> RngBackend *rng;
> + RndRandom *default_backend;
> };
>
> #endif
>
NACK. Starting a guest that runs rngd (or just a malicious guest) will
completely deprive the host of entropy.
If you make the default /dev/hwrng, however, that would be ok.
Paolo
[Qemu-devel] [PATCH 3/4] machine: add default_devices field to QEMUMachine, Anthony Liguori, 2012/10/26
[Qemu-devel] [PATCH 4/4] pc-1.3: add virtio-rng and virtio-balloon to the default machine, Anthony Liguori, 2012/10/26
[Qemu-devel] [PATCH 1/4] rng-random: split out header for rng-random, Anthony Liguori, 2012/10/26