[PATCH 06/10] qemu: Reorganize qemuBuildDomainLoaderCommandLine call

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

 



Reorganize the module to put the function after the -cpu processing
to form a logical order of processing for qemuBuildCommandLine working
top down in the module.

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

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 9dbc4a3..70da921 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -790,6 +790,77 @@ qemuBuildCpuCommandLine(virCommandPtr cmd,
 }
 
 
+/** Start Domain Loader (-bios, file=%s,if=pflash) arguments */
+static int
+qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
+                                 const virDomainDef *def,
+                                 virQEMUCapsPtr qemuCaps)
+{
+    int ret = -1;
+    virDomainLoaderDefPtr loader = def->os.loader;
+    virBuffer buf = VIR_BUFFER_INITIALIZER;
+    int unit = 0;
+
+    if (!loader)
+        return 0;
+
+    switch ((virDomainLoader) loader->type) {
+    case VIR_DOMAIN_LOADER_TYPE_ROM:
+        virCommandAddArg(cmd, "-bios");
+        virCommandAddArg(cmd, loader->path);
+        break;
+
+    case VIR_DOMAIN_LOADER_TYPE_PFLASH:
+        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI) &&
+            def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
+            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                           _("ACPI must be enabled in order to use UEFI"));
+            goto cleanup;
+        }
+
+        virBufferAsprintf(&buf,
+                          "file=%s,if=pflash,format=raw,unit=%d",
+                          loader->path, unit);
+        unit++;
+
+        if (loader->readonly) {
+            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
+                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
+                               _("this qemu doesn't support passing "
+                                 "readonly attribute"));
+                goto cleanup;
+            }
+
+            virBufferAsprintf(&buf, ",readonly=%s",
+                              virTristateSwitchTypeToString(loader->readonly));
+        }
+
+        virCommandAddArg(cmd, "-drive");
+        virCommandAddArgBuffer(cmd, &buf);
+
+        if (loader->nvram) {
+            virBufferFreeAndReset(&buf);
+            virBufferAsprintf(&buf,
+                              "file=%s,if=pflash,format=raw,unit=%d",
+                              loader->nvram, unit);
+
+            virCommandAddArg(cmd, "-drive");
+            virCommandAddArgBuffer(cmd, &buf);
+        }
+        break;
+
+    case VIR_DOMAIN_LOADER_TYPE_LAST:
+        /* nada */
+        break;
+    }
+
+    ret = 0;
+ cleanup:
+    virBufferFreeAndReset(&buf);
+    return ret;
+}
+
+
 static int
 qemuBuildObjectCommandLinePropsInternal(const char *key,
                                         const virJSONValue *value,
@@ -6341,76 +6412,6 @@ qemuBuildChrDeviceCommandLine(virCommandPtr cmd,
     return 0;
 }
 
-static int
-qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
-                                 virDomainDefPtr def,
-                                 virQEMUCapsPtr qemuCaps)
-{
-    int ret = -1;
-    virDomainLoaderDefPtr loader = def->os.loader;
-    virBuffer buf = VIR_BUFFER_INITIALIZER;
-    int unit = 0;
-
-    if (!loader)
-        return 0;
-
-    switch ((virDomainLoader) loader->type) {
-    case VIR_DOMAIN_LOADER_TYPE_ROM:
-        virCommandAddArg(cmd, "-bios");
-        virCommandAddArg(cmd, loader->path);
-        break;
-
-    case VIR_DOMAIN_LOADER_TYPE_PFLASH:
-        if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI) &&
-            def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) {
-            virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                           _("ACPI must be enabled in order to use UEFI"));
-            goto cleanup;
-        }
-
-        virBufferAsprintf(&buf,
-                          "file=%s,if=pflash,format=raw,unit=%d",
-                          loader->path, unit);
-        unit++;
-
-        if (loader->readonly) {
-            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DRIVE_READONLY)) {
-                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
-                               _("this qemu doesn't support passing "
-                                 "readonly attribute"));
-                goto cleanup;
-            }
-
-            virBufferAsprintf(&buf, ",readonly=%s",
-                              virTristateSwitchTypeToString(loader->readonly));
-        }
-
-        virCommandAddArg(cmd, "-drive");
-        virCommandAddArgBuffer(cmd, &buf);
-
-        if (loader->nvram) {
-            virBufferFreeAndReset(&buf);
-            virBufferAsprintf(&buf,
-                              "file=%s,if=pflash,format=raw,unit=%d",
-                              loader->nvram, unit);
-
-            virCommandAddArg(cmd, "-drive");
-            virCommandAddArgBuffer(cmd, &buf);
-        }
-        break;
-
-    case VIR_DOMAIN_LOADER_TYPE_LAST:
-        /* nada */
-        break;
-    }
-
-    ret = 0;
- cleanup:
-    virBufferFreeAndReset(&buf);
-    return ret;
-}
-
-
 static char *
 qemuBuildTPMDevStr(const virDomainDef *def,
                    virQEMUCapsPtr qemuCaps,
-- 
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]