[PATCH 24/25] qemu: Introduce qemuBuildNVRAMCommandLine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add new function to manage adding the NVRAM device options to the
command line removing that task from the mainline qemuBuildCommandLine.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 61 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 38 insertions(+), 23 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 69284b4..2a6bd5e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3467,6 +3467,42 @@ qemuBuildNVRAMDevStr(virDomainNVRAMDefPtr dev)
     return NULL;
 }
 
+
+static int
+qemuBuildNVRAMCommandLine(virCommandPtr cmd,
+                          const virDomainDef *def,
+                          virQEMUCapsPtr qemuCaps)
+{
+    if (!def->nvram)
+        return 0;
+
+    if (ARCH_IS_PPC64(def->os.arch) &&
+        STRPREFIX(def->os.machine, "pseries")) {
+        if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVRAM)) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("nvram device is not supported by "
+                             "this QEMU binary"));
+            return -1;
+        }
+
+        char *optstr;
+        virCommandAddArg(cmd, "-global");
+        optstr = qemuBuildNVRAMDevStr(def->nvram);
+        if (!optstr)
+            return -1;
+        if (optstr)
+            virCommandAddArg(cmd, optstr);
+        VIR_FREE(optstr);
+    } else {
+        virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                      _("nvram device is only supported for PPC64"));
+        return -1;
+    }
+
+    return 0;
+}
+
+
 static char *
 qemuBuildVirtioInputDevStr(const virDomainDef *def,
                            virDomainInputDefPtr dev,
@@ -9077,30 +9113,9 @@ qemuBuildCommandLine(virConnectPtr conn,
     if (qemuBuildRNGCommandLine(cmd, def, qemuCaps) < 0)
         goto error;
 
-    if (def->nvram) {
-        if (ARCH_IS_PPC64(def->os.arch) &&
-            STRPREFIX(def->os.machine, "pseries")) {
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_NVRAM)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("nvram device is not supported by "
-                                 "this QEMU binary"));
-                goto error;
-            }
+    if (qemuBuildNVRAMCommandLine(cmd, def, qemuCaps) < 0)
+        goto error;
 
-            char *optstr;
-            virCommandAddArg(cmd, "-global");
-            optstr = qemuBuildNVRAMDevStr(def->nvram);
-            if (!optstr)
-                goto error;
-            if (optstr)
-                virCommandAddArg(cmd, optstr);
-            VIR_FREE(optstr);
-        } else {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                          _("nvram device is only supported for PPC64"));
-            goto error;
-        }
-    }
     if (snapshot)
         virCommandAddArgList(cmd, "-loadvm", snapshot->def->name, NULL);
 
-- 
2.5.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]