Re: [PATCH 08/21] virQEMUBuildCommandLineJSON: Add possibility for using 'on/off' instead of 'yes/no'

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

 



On 5/15/20 10:27 AM, Peter Krempa wrote:
In some cases we use 'on/off' for command line arguments. Add a switch
which will select the prefred spelling for a specific usage.

preferred


Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx>
---
  src/util/virqemu.c          | 44 ++++++++++++++++++++++++-------------
  src/util/virqemu.h          | 10 ++++++---
  tests/qemucommandutiltest.c |  2 +-
  3 files changed, 37 insertions(+), 19 deletions(-)


@@ -165,10 +170,17 @@ virQEMUBuildCommandLineJSONRecurse(const char *key,

      case VIR_JSON_TYPE_BOOLEAN:
          virJSONValueGetBoolean(value, &tmp);
-        if (tmp)
-            virBufferAsprintf(buf, "%s=yes,", key);
-        else
-            virBufferAsprintf(buf, "%s=no,", key);
+        if (onOff) {
+            if (tmp)
+                virBufferAsprintf(buf, "%s=on,", key);
+            else
+                virBufferAsprintf(buf, "%s=off,", key);
+        } else {
+            if (tmp)
+                virBufferAsprintf(buf, "%s=yes,", key);
+            else
+                virBufferAsprintf(buf, "%s=no,", key);
+        }

It would be nice if there were a single spelling we could use for all boolean CLI parameters across all supported qemu versions. But this is certainly the most conservative way to deal with the fact that some of the CLI parameters are ad hoc rather than sharing common code, and thus inconsistent on which spellings work where.

Reviewed-by: Eric Blake <eblake@xxxxxxxxxx>

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org




[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