From 49b45a1cf4d921e201989121e5ea343a769460e0 Mon Sep 17 00:00:00 2001 From: Andrea Bolognani Date: Fri, 15 Feb 2019 10:39:20 +0100 Subject: [PATCH] conf: Introduce virDomainRNGDefPostParse() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andrea Bolognani Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 74bb18d726..c25ee06e32 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4842,6 +4842,20 @@ 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 +4880,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) { -- GitLab