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

Eric Blake eblake at redhat.com
Mon May 18 14:39:37 UTC 2020


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 at redhat.com>
> ---
>   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 at redhat.com>

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




More information about the libvir-list mailing list