Add new function to manage adding the RNG device options to the
command line removing that task from the mainline qemuBuildCommandLine.
Also modify the qemuBuildRNGDevStr to use const virDomainDef instead
of virDomainDefPtr.
Signed-off-by: John Ferlan <jferlan(a)redhat.com>
---
src/qemu/qemu_command.c | 80 +++++++++++++++++++++++++++++--------------------
src/qemu/qemu_command.h | 2 +-
2 files changed, 48 insertions(+), 34 deletions(-)
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 7876d4f..69284b4 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -5153,7 +5153,7 @@ qemuBuildRNGBackendStr(virDomainRNGDefPtr rng,
char *
-qemuBuildRNGDevStr(virDomainDefPtr def,
+qemuBuildRNGDevStr(const virDomainDef *def,
virDomainRNGDefPtr dev,
virQEMUCapsPtr qemuCaps)
{
@@ -5205,6 +5205,50 @@ qemuBuildRNGDevStr(virDomainDefPtr def,
}
+static int
+qemuBuildRNGCommandLine(virCommandPtr cmd,
+ const virDomainDef *def,
+ virQEMUCapsPtr qemuCaps)
+{
+ size_t i;
+
+ for (i = 0; i < def->nrngs; i++) {
+ virDomainRNGDefPtr rng = def->rngs[i];
+ char *tmp;
+
+ if (!rng->info.alias) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("RNG device is missing alias"));
+ return -1;
+ }
+
+ /* possibly add character device for backend */
+ if (qemuBuildRNGBackendChrdevStr(rng, qemuCaps, &tmp) < 0)
+ return -1;
+
+ if (tmp) {
+ virCommandAddArgList(cmd, "-chardev", tmp, NULL);
+ VIR_FREE(tmp);
+ }
+
+ /* add the RNG source backend */
+ if (!(tmp = qemuBuildRNGBackendStr(rng, qemuCaps)))
+ return -1;
+
+ virCommandAddArgList(cmd, "-object", tmp, NULL);
+ VIR_FREE(tmp);
+
+ /* add the device */
+ if (!(tmp = qemuBuildRNGDevStr(def, rng, qemuCaps)))
+ return -1;
+ virCommandAddArgList(cmd, "-device", tmp, NULL);
+ VIR_FREE(tmp);
+ }
+
+ return 0;
+}
+
+
static char *qemuBuildSmbiosBiosStr(virSysinfoBIOSDefPtr def)
{
virBuffer buf = VIR_BUFFER_INITIALIZER;
@@ -9030,38 +9074,8 @@ qemuBuildCommandLine(virConnectPtr conn,
if (qemuBuildMemballoonCommandLine(cmd, def, qemuCaps) < 0)
goto error;
- for (i = 0; i < def->nrngs; i++) {
- virDomainRNGDefPtr rng = def->rngs[i];
- char *tmp;
-
- if (!rng->info.alias) {
- virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
- _("RNG device is missing alias"));
- goto error;
- }
-
- /* possibly add character device for backend */
- if (qemuBuildRNGBackendChrdevStr(rng, qemuCaps, &tmp) < 0)
- goto error;
-
- if (tmp) {
- virCommandAddArgList(cmd, "-chardev", tmp, NULL);
- VIR_FREE(tmp);
- }
-
- /* add the RNG source backend */
- if (!(tmp = qemuBuildRNGBackendStr(rng, qemuCaps)))
- goto error;
-
- virCommandAddArgList(cmd, "-object", tmp, NULL);
- VIR_FREE(tmp);
-
- /* add the device */
- if (!(tmp = qemuBuildRNGDevStr(def, rng, qemuCaps)))
- goto error;
- virCommandAddArgList(cmd, "-device", tmp, NULL);
- VIR_FREE(tmp);
- }
+ if (qemuBuildRNGCommandLine(cmd, def, qemuCaps) < 0)
+ goto error;
if (def->nvram) {
if (ARCH_IS_PPC64(def->os.arch) &&
diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h
index fb44a3c..cef5d6f 100644
--- a/src/qemu/qemu_command.h
+++ b/src/qemu/qemu_command.h
@@ -150,7 +150,7 @@ char *qemuBuildPCIHostdevDevStr(const virDomainDef *def,
const char *configfd,
virQEMUCapsPtr qemuCaps);
-char *qemuBuildRNGDevStr(virDomainDefPtr def,
+char *qemuBuildRNGDevStr(const virDomainDef *def,
virDomainRNGDefPtr dev,
virQEMUCapsPtr qemuCaps);
int qemuBuildRNGBackendProps(virDomainRNGDefPtr rng,
--
2.5.0