[PATCH 1/6] qemu: command: Extract formatting of -drive for pflash

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

 



Extract the old way to instantiate pflash devices to hold the firmware
via -drive to a separate function so that it can later be conditionally
disabled when -blockdev will be used.

Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
 src/qemu/qemu_command.c | 72 +++++++++++++++++++++++------------------
 1 file changed, 40 insertions(+), 32 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index ca1bd12594..c82d13483e 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9416,53 +9416,61 @@ qemuBuildRedirdevCommandLine(virLogManagerPtr logManager,


 static void
-qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
-                                 virDomainDefPtr def)
+qemuBuldDomainLoaderPflashCommandLine(virCommandPtr cmd,
+                                      virDomainLoaderDefPtr loader)
 {
-    virDomainLoaderDefPtr loader = def->os.loader;
     g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
     int unit = 0;

-    if (!loader)
-        return;
+    if (loader->secure == VIR_TRISTATE_BOOL_YES) {
+        virCommandAddArgList(cmd,
+                             "-global",
+                             "driver=cfi.pflash01,property=secure,value=on",
+                             NULL);
+    }

-    switch ((virDomainLoader) loader->type) {
-    case VIR_DOMAIN_LOADER_TYPE_ROM:
-        virCommandAddArg(cmd, "-bios");
-        virCommandAddArg(cmd, loader->path);
-        break;
+    virBufferAddLit(&buf, "file=");
+    virQEMUBuildBufferEscapeComma(&buf, loader->path);
+    virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);
+    unit++;

-    case VIR_DOMAIN_LOADER_TYPE_PFLASH:
+    if (loader->readonly) {
+        virBufferAsprintf(&buf, ",readonly=%s",
+                          virTristateSwitchTypeToString(loader->readonly));
+    }

-        if (loader->secure == VIR_TRISTATE_BOOL_YES) {
-            virCommandAddArgList(cmd,
-                                 "-global",
-                                 "driver=cfi.pflash01,property=secure,value=on",
-                                 NULL);
-        }
+    virCommandAddArg(cmd, "-drive");
+    virCommandAddArgBuffer(cmd, &buf);

+    if (loader->nvram) {
+        virBufferFreeAndReset(&buf);
         virBufferAddLit(&buf, "file=");
-        virQEMUBuildBufferEscapeComma(&buf, loader->path);
+        virQEMUBuildBufferEscapeComma(&buf, loader->nvram);
         virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);
-        unit++;
-
-        if (loader->readonly) {
-            virBufferAsprintf(&buf, ",readonly=%s",
-                              virTristateSwitchTypeToString(loader->readonly));
-        }

         virCommandAddArg(cmd, "-drive");
         virCommandAddArgBuffer(cmd, &buf);
+    }
+}

-        if (loader->nvram) {
-            virBufferFreeAndReset(&buf);
-            virBufferAddLit(&buf, "file=");
-            virQEMUBuildBufferEscapeComma(&buf, loader->nvram);
-            virBufferAsprintf(&buf, ",if=pflash,format=raw,unit=%d", unit);

-            virCommandAddArg(cmd, "-drive");
-            virCommandAddArgBuffer(cmd, &buf);
-        }
+static void
+qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
+                                 virDomainDefPtr def)
+{
+    virDomainLoaderDefPtr loader = def->os.loader;
+
+    if (!loader)
+        return;
+
+    switch ((virDomainLoader) loader->type) {
+    case VIR_DOMAIN_LOADER_TYPE_ROM:
+        virCommandAddArg(cmd, "-bios");
+        virCommandAddArg(cmd, loader->path);
+        break;
+
+    case VIR_DOMAIN_LOADER_TYPE_PFLASH:
+        qemuBuldDomainLoaderPflashCommandLine(cmd, loader);
         break;

     case VIR_DOMAIN_LOADER_TYPE_NONE:
-- 
2.23.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]

  Powered by Linux