[libvirt] "file '/dev/urandom' is not a supported random source"

Richard W.M. Jones rjones at redhat.com
Tue Mar 22 14:49:42 UTC 2016


I got this error when trying to use /dev/urandom as a backend for
virtio-rng.  Is there a reason for that?  Plain qemu allows you to
specify /dev/urandom and seems to work OK.

There's a tetchy bugzilla on this subject:

https://bugzilla.redhat.com/show_bug.cgi?id=1074464

but I think for cases where people don't care / throwaway appliances,
we should allow /dev/urandom.  The main reason is that it doesn't
block.

Patch attached.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
Fedora Windows cross-compiler. Compile Windows programs, test, and
build Windows installers. Over 100 libraries supported.
http://fedoraproject.org/wiki/MinGW
-------------- next part --------------
>From 28290b63adc7874ec4c78c8cc25996a111724abe Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones at redhat.com>
Date: Tue, 22 Mar 2016 14:41:13 +0000
Subject: [PATCH] domain: Allow /dev/urandom to be used as a backend source of
 randomness.

Signed-off-by: Richard W.M. Jones <rjones at redhat.com>
---
 docs/formatdomain.html.in | 6 ++++--
 src/conf/domain_conf.c    | 1 +
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 71ffe75..0a8ef5c 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6076,7 +6076,8 @@ qemu-kvm -net nic,model=? /dev/null
           <code>model</code> attribute. Supported source models are:
         </p>
         <ul>
-          <li>'random' — /dev/random (default) or /dev/hwrng
+          <li>'random' — /dev/random (default), /dev/urandom
+            or /dev/hwrng
             device as source (for now, no other sources are permitted)</li>
           <li>'egd' — a EGD protocol backend</li>
         </ul>
@@ -6085,7 +6086,8 @@ qemu-kvm -net nic,model=? /dev/null
       <dd>
         <p>
           This backend type expects a non-blocking character device as input.
-          The only accepted paths are /dev/random and /dev/hwrng. The file
+          The only accepted paths are /dev/random, /dev/urandom and
+          /dev/hwrng. The file
           name is specified as contents of the <code>backend</code> element.
           When no file name is specified the hypervisor default is used.
         </p>
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index d5d9ff7..77c268f 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11451,6 +11451,7 @@ virDomainRNGDefParseXML(xmlNodePtr node,
         def->source.file = virXPathString("string(./backend)", ctxt);
         if (def->source.file &&
             STRNEQ(def->source.file, "/dev/random") &&
+            STRNEQ(def->source.file, "/dev/urandom") &&
             STRNEQ(def->source.file, "/dev/hwrng")) {
             virReportError(VIR_ERR_XML_ERROR,
                            _("file '%s' is not a supported random source"),
-- 
2.7.4



More information about the libvir-list mailing list