[PATCH 5/5] Use virBufferTrim when generating boot options

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

 



Instead of tracking the number of added parameters,
add a comma at the end of each one unconditionally
and trim the trailing one at the end.
---
 src/qemu/qemu_command.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 0b5fb72..06a9e54 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -8210,7 +8210,6 @@ qemuBuildCommandLine(virConnectPtr conn,
     virBuffer boot_opts = VIR_BUFFER_INITIALIZER;
     virBuffer boot_order = VIR_BUFFER_INITIALIZER;
     char *boot_order_str = NULL, *boot_opts_str = NULL;
-    int boot_nparams = 0;
 
     VIR_DEBUG("conn=%p driver=%p def=%p mon=%p json=%d "
               "qemuCaps=%p migrateFrom=%s migrateFD=%d "
@@ -8782,13 +8781,10 @@ qemuBuildCommandLine(virConnectPtr conn,
 
     if (def->os.bootmenu) {
         if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU)) {
-            if (boot_nparams++)
-                virBufferAddChar(&boot_opts, ',');
-
             if (def->os.bootmenu == VIR_TRISTATE_BOOL_YES)
-                virBufferAddLit(&boot_opts, "menu=on");
+                virBufferAddLit(&boot_opts, "menu=on,");
             else
-                virBufferAddLit(&boot_opts, "menu=off");
+                virBufferAddLit(&boot_opts, "menu=off,");
         } else {
             /* We cannot emit an error when bootmenu is enabled but
              * unsupported because of backward compatibility */
@@ -8805,11 +8801,8 @@ qemuBuildCommandLine(virConnectPtr conn,
             goto error;
         }
 
-        if (boot_nparams++)
-            virBufferAddChar(&boot_opts, ',');
-
         virBufferAsprintf(&boot_opts,
-                          "reboot-timeout=%d",
+                          "reboot-timeout=%d,",
                           def->os.bios.rt_delay);
     }
 
@@ -8821,17 +8814,13 @@ qemuBuildCommandLine(virConnectPtr conn,
             goto error;
         }
 
-        if (boot_nparams++)
-            virBufferAddChar(&boot_opts, ',');
-
-        virBufferAsprintf(&boot_opts, "splash-time=%u", def->os.bm_timeout);
+        virBufferAsprintf(&boot_opts, "splash-time=%u,", def->os.bm_timeout);
     }
 
-    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_STRICT)) {
-        if (boot_nparams++)
-            virBufferAddChar(&boot_opts, ',');
-        virBufferAddLit(&boot_opts, "strict=on");
-    }
+    if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_STRICT))
+        virBufferAddLit(&boot_opts, "strict=on,");
+
+    virBufferTrim(&boot_opts, ",", -1);
 
     if (virBufferCheckError(&boot_opts) < 0)
         goto error;
-- 
2.0.5

--
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]