[PATCH 14/14] qemuBuildFloppyCommandLineControllerOptionsExplicit: Generate via JSON

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

 



QEMU declares the bootindex types as:

  bootindexA=<int32>
  bootindexB=<int32>

The driveA/driveB parameters were deprecated and removed in qemu-6.0.
We'll keep them for compatibility, but they are not used with -blockdev.

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

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 665cd739ec..3b2f88bcb9 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -2183,32 +2183,29 @@ qemuBuildFloppyCommandLineControllerOptionsImplicit(virCommand *cmd,
 }


-static void
+static int
 qemuBuildFloppyCommandLineControllerOptionsExplicit(virCommand *cmd,
                                                     unsigned int bootindexA,
                                                     unsigned int bootindexB,
                                                     const char *backendA,
-                                                    const char *backendB)
+                                                    const char *backendB,
+                                                    virQEMUCaps *qemuCaps)
 {
-    g_auto(virBuffer) fdc_opts = VIR_BUFFER_INITIALIZER;
-
-    virBufferAddLit(&fdc_opts, "isa-fdc,");
-
-    if (backendA)
-        virBufferAsprintf(&fdc_opts, "driveA=%s,", backendA);
-
-    if (bootindexA > 0)
-        virBufferAsprintf(&fdc_opts, "bootindexA=%u,", bootindexA);
+    g_autoptr(virJSONValue) props = NULL;

-    if (backendB)
-        virBufferAsprintf(&fdc_opts, "driveB=%s,", backendB);
+    if (virJSONValueObjectCreate(&props,
+                                 "s:driver", "isa-fdc",
+                                 "S:driveA", backendA,
+                                 "p:bootindexA", bootindexA,
+                                 "S:driveB", backendB,
+                                 "p:bootindexB", bootindexB,
+                                 NULL) < 0)
+        return -1;

-    if (bootindexB > 0)
-        virBufferAsprintf(&fdc_opts, "bootindexB=%u,", bootindexB);
+    if (qemuBuildDeviceCommandlineFromJSON(cmd, props, qemuCaps) < 0)
+        return -1;

-    virBufferTrim(&fdc_opts, ",");
-    virCommandAddArg(cmd, "-device");
-    virCommandAddArgBuffer(cmd, &fdc_opts);
+    return 0;
 }


@@ -2251,11 +2248,13 @@ qemuBuildFloppyCommandLineControllerOptions(virCommand *cmd,
         return 0;

     if (qemuDomainNeedsFDC(def)) {
-        qemuBuildFloppyCommandLineControllerOptionsExplicit(cmd,
-                                                            bootindexA,
-                                                            bootindexB,
-                                                            backendA,
-                                                            backendB);
+        if (qemuBuildFloppyCommandLineControllerOptionsExplicit(cmd,
+                                                                bootindexA,
+                                                                bootindexB,
+                                                                backendA,
+                                                                backendB,
+                                                                qemuCaps) < 0)
+            return -1;
     } else {
         qemuBuildFloppyCommandLineControllerOptionsImplicit(cmd,
                                                             bootindexA,
-- 
2.31.1




[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