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


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

Patch attached.


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

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:
-          <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>
@@ -6085,7 +6086,8 @@ qemu-kvm -net nic,model=? /dev/null
           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.
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")) {
                            _("file '%s' is not a supported random source"),

More information about the libvir-list mailing list