From bc858f46823dddf82023ba8c7a3970d8d20861ef Mon Sep 17 00:00:00 2001
From: Cole Robinson
Date: Wed, 13 Apr 2016 15:09:30 -0400
Subject: [PATCH] conf: Drop restrictions on rng backend path
Currently we only allow /dev/random and /dev/hwrng as host input
for device. This was added after
various upstream discussions in commit 4932ef45
However this restriction has generated quite a few complaints over
the years, so a new discussion was initiated:
http://www.redhat.com/archives/libvir-list/2016-April/msg00987.html
Several people suggested removing the restriction, and nobody really
spoke up to defend it. So this patch drops the path restriction
entirely
https://bugzilla.redhat.com/show_bug.cgi?id=1074464
(cherry picked from commit 67f2b72723c242969c5282fcb9acf00cc01f2a54)
---
docs/formatdomain.html.in | 45 +++++++++----------
docs/schemas/domaincommon.rng | 3 +-
src/conf/domain_conf.c | 8 ----
.../qemuxml2argv-virtio-rng-random.args | 2 +-
.../qemuxml2argv-virtio-rng-random.xml | 2 +-
.../qemuxml2xmlout-virtio-rng-random.xml | 2 +-
6 files changed, 25 insertions(+), 37 deletions(-)
diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in
index 33b6105f96..53ae840da7 100644
--- a/docs/formatdomain.html.in
+++ b/docs/formatdomain.html.in
@@ -6116,31 +6116,28 @@ qemu-kvm -net nic,model=? /dev/null
to be used for the domain. The source model is configured using the
model
attribute. Supported source models are:
-
- - 'random' — /dev/random (default) or /dev/hwrng
- device as source (for now, no other sources are permitted)
- - 'egd' — a EGD protocol backend
-
+
+ random
+ -
+
+ This backend type expects a non-blocking character device as
+ input. The file name is specified as contents of the
+ backend
element. When no file name is specified
+ the hypervisor default is used. For qemu, the default is
+ /dev/random
+
+
+ egd
+ -
+
+ This backend connects to a source using the EGD protocol.
+ The source is specified as a character device. Refer to
+ character device host interface
+ for more information.
+
+
+
- backend model='random'
-
-
- This backend type expects a non-blocking character device as input.
- The only accepted paths are /dev/random and /dev/hwrng. The file
- name is specified as contents of the backend
element.
- When no file name is specified the hypervisor default is used.
-
-
- backend model='egd'
-
-
- This backend connects to a source using the EGD protocol.
- The source is specified as a character device. Refer to
- character device host interface
- for more information.
-
-
-
diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng
index 54c149dd52..6ae30440ad 100644
--- a/docs/schemas/domaincommon.rng
+++ b/docs/schemas/domaincommon.rng
@@ -4671,8 +4671,7 @@
random
- /dev/random
- /dev/hwrng
+
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 836e2864b5..2b16e9b46d 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -11463,14 +11463,6 @@ virDomainRNGDefParseXML(xmlNodePtr node,
switch ((virDomainRNGBackend) def->backend) {
case VIR_DOMAIN_RNG_BACKEND_RANDOM:
def->source.file = virXPathString("string(./backend)", ctxt);
- if (def->source.file &&
- STRNEQ(def->source.file, "/dev/random") &&
- STRNEQ(def->source.file, "/dev/hwrng")) {
- virReportError(VIR_ERR_XML_ERROR,
- _("file '%s' is not a supported random source"),
- def->source.file);
- goto error;
- }
break;
case VIR_DOMAIN_RNG_BACKEND_EGD:
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
index ba97c1e8ee..5a4d47be97 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.args
@@ -18,6 +18,6 @@ QEMU_AUDIO_DRV=none \
-boot c \
-usb \
-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x3 \
--object rng-random,id=objrng0,filename=/dev/hwrng \
+-object rng-random,id=objrng0,filename=/dev/urandom \
-device virtio-rng-pci,rng=objrng0,id=rng0,max-bytes=123,period=1234,bus=pci.0,\
addr=0x4
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml
index 71bd21a65c..a6e91fff3e 100644
--- a/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-virtio-rng-random.xml
@@ -21,7 +21,7 @@
- /dev/hwrng
+ /dev/urandom
diff --git a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-rng-random.xml b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-rng-random.xml
index e8a047866b..0bdefdef44 100644
--- a/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-rng-random.xml
+++ b/tests/qemuxml2xmloutdata/qemuxml2xmlout-virtio-rng-random.xml
@@ -25,7 +25,7 @@
- /dev/hwrng
+ /dev/urandom