All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/4] Enable virtio-{rng,balloon} by default
@ 2012-10-26 17:21 Anthony Liguori
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 1/4] rng-random: split out header for rng-random Anthony Liguori
                   ` (3 more replies)
  0 siblings, 4 replies; 12+ messages in thread
From: Anthony Liguori @ 2012-10-26 17:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah, Paolo Bonzini, Andreas Faerber

This series depends on my virtio-rng series from earlier but goes quite a bit
further.

It creates a default backend for the virtio-rng-pci device that will be
available if the user doesn't explicitly set one.

It also creates a mechanism to provide a simple way to specify default devices
via QEMUMachine.

Finally, it adds virtio-rng and virtio-balloon to the default machine.

The principle here is to try and make a naive execution of qemu as useful as
possible.

When it comes to virtio-rng, I think it's a lot to ask of a user to try and
decide whether they need or not--so let's always make it available.

For virtio-balloon, there's really no harm in having it present and it enables
ballooning which is a feature most users expect and are aware of.

I would expect us to use a similar mechanism to expose a virtio-serial channel
for qemu-ga once we plumb guest agent actions through QMP.

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 1/4] rng-random: split out header for rng-random
  2012-10-26 17:21 [Qemu-devel] [PATCH 0/4] Enable virtio-{rng,balloon} by default Anthony Liguori
@ 2012-10-26 17:21 ` Anthony Liguori
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists Anthony Liguori
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2012-10-26 17:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah, Paolo Bonzini, Anthony Liguori, Andreas Faerber

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 backends/rng-random.c     |  8 +++-----
 include/qemu/rng-random.h | 22 ++++++++++++++++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)
 create mode 100644 include/qemu/rng-random.h

diff --git a/backends/rng-random.c b/backends/rng-random.c
index 6b6e4b4..8325686 100644
--- a/backends/rng-random.c
+++ b/backends/rng-random.c
@@ -10,14 +10,12 @@
  * See the COPYING file in the top-level directory.
  */
 
+#include "qemu/rng-random.h"
 #include "qemu/rng.h"
 #include "qerror.h"
 #include "main-loop.h"
 
-#define TYPE_RNG_RANDOM "rng-random"
-#define RNG_RANDOM(obj) OBJECT_CHECK(RndRandom, (obj), TYPE_RNG_RANDOM)
-
-typedef struct RndRandom
+struct RndRandom
 {
     RngBackend parent;
 
@@ -27,7 +25,7 @@ typedef struct RndRandom
     EntropyReceiveFunc *receive_func;
     void *opaque;
     size_t size;
-} RndRandom;
+};
 
 /**
  * A simple and incomplete backend to request entropy from /dev/random.
diff --git a/include/qemu/rng-random.h b/include/qemu/rng-random.h
new file mode 100644
index 0000000..6249290
--- /dev/null
+++ b/include/qemu/rng-random.h
@@ -0,0 +1,22 @@
+/*
+ * QEMU Random Number Generator Backend
+ *
+ * Copyright IBM, Corp. 2012
+ *
+ * Authors:
+ *  Anthony Liguori   <aliguori@us.ibm.com>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2 or later.
+ * See the COPYING file in the top-level directory.
+ */
+#ifndef QEMU_RNG_RANDOM_H
+#define QEMU_RNG_RANDOM_H
+
+#include "qemu/object.h"
+
+#define TYPE_RNG_RANDOM "rng-random"
+#define RNG_RANDOM(obj) OBJECT_CHECK(RndRandom, (obj), TYPE_RNG_RANDOM)
+
+typedef struct RndRandom RndRandom;
+
+#endif
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists
  2012-10-26 17:21 [Qemu-devel] [PATCH 0/4] Enable virtio-{rng,balloon} by default Anthony Liguori
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 1/4] rng-random: split out header for rng-random Anthony Liguori
@ 2012-10-26 17:21 ` Anthony Liguori
  2012-10-26 18:59   ` Paolo Bonzini
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 3/4] machine: add default_devices field to QEMUMachine Anthony Liguori
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 4/4] pc-1.3: add virtio-rng and virtio-balloon to the default machine Anthony Liguori
  3 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2012-10-26 17:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah, Paolo Bonzini, Anthony Liguori, Andreas Faerber

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 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
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 3/4] machine: add default_devices field to QEMUMachine
  2012-10-26 17:21 [Qemu-devel] [PATCH 0/4] Enable virtio-{rng,balloon} by default Anthony Liguori
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 1/4] rng-random: split out header for rng-random Anthony Liguori
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists Anthony Liguori
@ 2012-10-26 17:21 ` Anthony Liguori
  2012-11-05 12:27   ` Markus Armbruster
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 4/4] pc-1.3: add virtio-rng and virtio-balloon to the default machine Anthony Liguori
  3 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2012-10-26 17:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah, Paolo Bonzini, Anthony Liguori, Andreas Faerber

This allows a machine to describe default devices that are only available
when -nodefaults is not present.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/boards.h |  6 ++++++
 vl.c        | 13 +++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/hw/boards.h b/hw/boards.h
index 813d0e5..85b2887 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -18,6 +18,11 @@ typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args);
 
 typedef void QEMUMachineResetFunc(void);
 
+typedef struct DeviceDescription {
+    const char *description;
+} DeviceDescription;
+
+
 typedef struct QEMUMachine {
     const char *name;
     const char *alias;
@@ -37,6 +42,7 @@ typedef struct QEMUMachine {
     GlobalProperty *compat_props;
     struct QEMUMachine *next;
     const char *hw_version;
+    DeviceDescription *default_devices;
 } QEMUMachine;
 
 int qemu_register_machine(QEMUMachine *m);
diff --git a/vl.c b/vl.c
index ffadbb6..f1285b8 100644
--- a/vl.c
+++ b/vl.c
@@ -276,6 +276,7 @@ static int default_floppy = 1;
 static int default_cdrom = 1;
 static int default_sdcard = 1;
 static int default_vga = 1;
+static int nodefaults = 0;
 
 static struct {
     const char *driver;
@@ -3275,6 +3276,7 @@ int main(int argc, char **argv, char **envp)
                 default_cdrom = 0;
                 default_sdcard = 0;
                 default_vga = 0;
+                nodefaults = 1;
                 break;
             case QEMU_OPTION_xen_domid:
                 if (!(xen_available())) {
@@ -3692,6 +3694,17 @@ int main(int argc, char **argv, char **envp)
     }
     qemu_add_globals();
 
+    if (!nodefaults && machine->default_devices) {
+        int i;
+
+        for (i = 0; machine->default_devices[i].description; i++) {
+            if (!qemu_opts_parse(qemu_find_opts("device"),
+                                 machine->default_devices[i].description, 1)) {
+                exit(1);
+            }
+        }
+    }
+
     qdev_machine_init();
 
     QEMUMachineInitArgs args = { .ram_size = ram_size,
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Qemu-devel] [PATCH 4/4] pc-1.3: add virtio-rng and virtio-balloon to the default machine
  2012-10-26 17:21 [Qemu-devel] [PATCH 0/4] Enable virtio-{rng,balloon} by default Anthony Liguori
                   ` (2 preceding siblings ...)
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 3/4] machine: add default_devices field to QEMUMachine Anthony Liguori
@ 2012-10-26 17:21 ` Anthony Liguori
  3 siblings, 0 replies; 12+ messages in thread
From: Anthony Liguori @ 2012-10-26 17:21 UTC (permalink / raw)
  To: qemu-devel; +Cc: Amit Shah, Paolo Bonzini, Anthony Liguori, Andreas Faerber

The default machine should be useful so add the virtio-rng and
virtio-balloon devices by default to enable these features.

These are protected by -nodefaults so they will only be added if you're
executing from the command line (not if you're using libvirt).

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
---
 hw/pc_piix.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 47ebc1a..65d0889 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -352,6 +352,11 @@ static QEMUMachine pc_machine_v1_3 = {
     .init = pc_init_pci,
     .max_cpus = 255,
     .is_default = 1,
+    .default_devices = (DeviceDescription[]){
+        { "virtio-rng-pci" },
+        { "virtio-balloon-pci" },
+        { },
+    },
 };
 
 #define PC_COMPAT_1_2 \
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists Anthony Liguori
@ 2012-10-26 18:59   ` Paolo Bonzini
  2012-10-26 19:51     ` Anthony Liguori
  2012-10-26 19:53     ` Paolo Bonzini
  0 siblings, 2 replies; 12+ messages in thread
From: Paolo Bonzini @ 2012-10-26 18:59 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, qemu-devel, Andreas Faerber

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 <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 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

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists
  2012-10-26 18:59   ` Paolo Bonzini
@ 2012-10-26 19:51     ` Anthony Liguori
  2012-10-26 20:20       ` Paolo Bonzini
  2012-10-26 19:53     ` Paolo Bonzini
  1 sibling, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2012-10-26 19:51 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Amit Shah, qemu-devel, Andreas Faerber

Paolo Bonzini <pbonzini@redhat.com> writes:

> 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 <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 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.

That's why this is a separate series...  Still don't understand what the
default entropy source should be.

> If you make the default /dev/hwrng, however, that would be ok.

/dev/hwrng may be (and stay) empty which seems unfortunate.

I was thinking /dev/urandom would be a good pragmatic choice though.

Regards,

Anthony Liguori
>
> Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists
  2012-10-26 18:59   ` Paolo Bonzini
  2012-10-26 19:51     ` Anthony Liguori
@ 2012-10-26 19:53     ` Paolo Bonzini
  2012-10-26 20:16       ` Anthony Liguori
  1 sibling, 1 reply; 12+ messages in thread
From: Paolo Bonzini @ 2012-10-26 19:53 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, qemu-devel, Andreas Faerber

Il 26/10/2012 20:59, Paolo Bonzini ha scritto:
> 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 <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 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.

Also, does this break non-Linux?  What if the default was changed to
/dev/hwrng but an older Linux distro didn't have the device file at all?

Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists
  2012-10-26 19:53     ` Paolo Bonzini
@ 2012-10-26 20:16       ` Anthony Liguori
  2012-10-26 20:22         ` Paolo Bonzini
  0 siblings, 1 reply; 12+ messages in thread
From: Anthony Liguori @ 2012-10-26 20:16 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: Amit Shah, qemu-devel, Andreas Faerber

Paolo Bonzini <pbonzini@redhat.com> writes:

> Il 26/10/2012 20:59, Paolo Bonzini ha scritto:
>> 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 <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 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.
>
> Also, does this break non-Linux?

It should fail gracefully.

If you do:

qemu -device virtio-rng-pci

Before this series you'd get:

qemu: Invalid value for parameter 'rng', expects a valid object

Now on !Linux you would get:

qemu -device virtio-rng-pci

qemu: Failed to open /dev/random

So it's still a failure, just a different message.

But this does suggest that we shouldn't add it to the default machine on
!Linux because we don't want the default machine failing.

Perhaps we can find better default backends on !Linux...

> What if the default was changed to /dev/hwrng but an older Linux
> distro didn't have the device file at all?

It would throw an error gracefully.

Regards,

Anthony Liguori

>
> Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists
  2012-10-26 19:51     ` Anthony Liguori
@ 2012-10-26 20:20       ` Paolo Bonzini
  0 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2012-10-26 20:20 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, qemu-devel, Andreas Faerber

Il 26/10/2012 21:51, Anthony Liguori ha scritto:
>> > If you make the default /dev/hwrng, however, that would be ok.
> /dev/hwrng may be (and stay) empty which seems unfortunate.

Unfortunate, but at least not wrong.

> I was thinking /dev/urandom would be a good pragmatic choice though.

No.

/dev/urandom is actively wrong because it provides the guest with the
illusion of an infinite source of entropy, while the guest is really
being fed with an infinite source of pseudo-random numbers.

/dev/random as a default is bad because on hosts without neither hwrng
nor rdrand it completely depletes the host's entropy pool.  Thus it
denies access to entropy to other programs running in the host.

I thought /dev/random with some throttling would be good, especially if
somehow the guest can be told to run rngd in skip-test mode, e.g. via a
virtio-rng feature bit.  Peter's last messages make me wonder if this is
correct.  If it is, the throttling can be implemented either in QEMU or
outside it (via a daemon that speaks the same protocol as egd).

/dev/random might be good in the special case where rngd is being run in
the host, and there is an hwrng or rdrand to feed rngd.  In this case
the guest can also be run in skip-test mode.  However, I don't have a
machine at hand (it's Friday evening here) to test whether rngd could
keep up, or a malicious guest would instead also deplete the host's
entropy tool too badly.

/dev/null makes the guest behave exactly as if no virtio-rng-pci is
present, so it is at least not wrong.

rdrand and /dev/hwrng seem to be the best choice at least to me.  Peter
seemed to agree initially, then said "This is surreal.  Output from
/dev/hwrng turns into output for /dev/random... it us guaranteed worse;
period, end of story".  I'm confused.

I hope the above is not too inaccurate and at least a decent way to
reset the discussion.

Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists
  2012-10-26 20:16       ` Anthony Liguori
@ 2012-10-26 20:22         ` Paolo Bonzini
  0 siblings, 0 replies; 12+ messages in thread
From: Paolo Bonzini @ 2012-10-26 20:22 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, qemu-devel, Andreas Faerber

Il 26/10/2012 22:16, Anthony Liguori ha scritto:
> So it's still a failure, just a different message.
> 
> But this does suggest that we shouldn't add it to the default machine on
> !Linux because we don't want the default machine failing.

We need to add it to all machines, because the machine signature should
not depend on the host OS.  However, it does suggest we need a null
backend as a fallback.

> Perhaps we can find better default backends on !Linux...

Yes, rdrand would be one.

>> > What if the default was changed to /dev/hwrng but an older Linux
>> > distro didn't have the device file at all?
> It would throw an error gracefully.

Perhaps the default backend can be created with a function that tries
multiple things and at worst settles on rng-null.

Paolo

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [Qemu-devel] [PATCH 3/4] machine: add default_devices field to QEMUMachine
  2012-10-26 17:21 ` [Qemu-devel] [PATCH 3/4] machine: add default_devices field to QEMUMachine Anthony Liguori
@ 2012-11-05 12:27   ` Markus Armbruster
  0 siblings, 0 replies; 12+ messages in thread
From: Markus Armbruster @ 2012-11-05 12:27 UTC (permalink / raw)
  To: Anthony Liguori; +Cc: Amit Shah, Paolo Bonzini, qemu-devel, Andreas Faerber

Anthony Liguori <aliguori@us.ibm.com> writes:

> This allows a machine to describe default devices that are only available
> when -nodefaults is not present.
>
> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
> ---
>  hw/boards.h |  6 ++++++
>  vl.c        | 13 +++++++++++++
>  2 files changed, 19 insertions(+)
>
> diff --git a/hw/boards.h b/hw/boards.h
> index 813d0e5..85b2887 100644
> --- a/hw/boards.h
> +++ b/hw/boards.h
> @@ -18,6 +18,11 @@ typedef void QEMUMachineInitFunc(QEMUMachineInitArgs *args);
>  
>  typedef void QEMUMachineResetFunc(void);
>  
> +typedef struct DeviceDescription {
> +    const char *description;
> +} DeviceDescription;

A comment explaning syntax of @description (just like argument of
-device, as far as I can tell) would be nice.

Not sure wrapping in a struct is worth it.

> +
> +
>  typedef struct QEMUMachine {
>      const char *name;
>      const char *alias;
> @@ -37,6 +42,7 @@ typedef struct QEMUMachine {
>      GlobalProperty *compat_props;
>      struct QEMUMachine *next;
>      const char *hw_version;
> +    DeviceDescription *default_devices;
>  } QEMUMachine;
>  
>  int qemu_register_machine(QEMUMachine *m);
[...]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2012-11-05 12:27 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-26 17:21 [Qemu-devel] [PATCH 0/4] Enable virtio-{rng,balloon} by default Anthony Liguori
2012-10-26 17:21 ` [Qemu-devel] [PATCH 1/4] rng-random: split out header for rng-random Anthony Liguori
2012-10-26 17:21 ` [Qemu-devel] [PATCH 2/4] virtio-rng-pci: create a default backend if none exists Anthony Liguori
2012-10-26 18:59   ` Paolo Bonzini
2012-10-26 19:51     ` Anthony Liguori
2012-10-26 20:20       ` Paolo Bonzini
2012-10-26 19:53     ` Paolo Bonzini
2012-10-26 20:16       ` Anthony Liguori
2012-10-26 20:22         ` Paolo Bonzini
2012-10-26 17:21 ` [Qemu-devel] [PATCH 3/4] machine: add default_devices field to QEMUMachine Anthony Liguori
2012-11-05 12:27   ` Markus Armbruster
2012-10-26 17:21 ` [Qemu-devel] [PATCH 4/4] pc-1.3: add virtio-rng and virtio-balloon to the default machine Anthony Liguori

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.