Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
src/conf/domain_conf.c | 22 +++++++++++++++-------
1 file changed, 15 insertions(+), 7 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 74bb18d726..99319578f7 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -4842,6 +4842,19 @@ virDomainChrDefPostParse(virDomainChrDefPtr chr,
}
+static int
+virDomainRNGDefPostParse(virDomainRNGDefPtr rng)
+{
+ /* set default path for virtio-rng "random" backend to /dev/random */
+ if (rng->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM &&
+ !rng->source.file) {
+ if (VIR_STRDUP(rng->source.file, "/dev/random") < 0)
+ return -1;
+ }
+
+ return 0;
+}
+
static int
virDomainVsockDefPostParse(virDomainVsockDefPtr vsock)
{
@@ -4866,13 +4879,8 @@ virDomainDeviceDefPostParseCommon(virDomainDeviceDefPtr dev,
if (dev->type == VIR_DOMAIN_DEVICE_CHR)
return virDomainChrDefPostParse(dev->data.chr, def);
- /* set default path for virtio-rng "random" backend to /dev/random */
- if (dev->type == VIR_DOMAIN_DEVICE_RNG &&
- dev->data.rng->backend == VIR_DOMAIN_RNG_BACKEND_RANDOM &&
- !dev->data.rng->source.file) {
- if (VIR_STRDUP(dev->data.rng->source.file, "/dev/random") <
0)
- return -1;
- }
+ if (dev->type == VIR_DOMAIN_DEVICE_RNG)
+ return virDomainRNGDefPostParse(dev->data.rng);
/* verify disk source */
if (dev->type == VIR_DOMAIN_DEVICE_DISK) {
--
2.20.1