[libvirt] [PATCH 2/7] util: Do not assume comma after object id

Peter Krempa pkrempa at redhat.com
Mon Jan 6 09:57:54 UTC 2020


On Wed, Jan 01, 2020 at 13:06:32 +0800, Han Han wrote:
> From: Han Han <hanhanzhiyeqianke at gmail.com>
> 
> For qemu object like rng-builtin, there are no properties after id
> property. We should always set comma after object id. Otherwise it will
> cause trailing comma on object:
>     -object rng-builtin,id=ID,
> 
> Signed-off-by: Han Han <hhan at redhat.com>
> ---
>  src/util/virqemu.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
> 
> diff --git a/src/util/virqemu.c b/src/util/virqemu.c
> index f3a233af..72151e43 100644
> --- a/src/util/virqemu.c
> +++ b/src/util/virqemu.c
> @@ -239,12 +239,13 @@ virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf,
>          return -1;
>      }
>  
> -    virBufferAsprintf(buf, "%s,id=%s,", type, alias);
> -
> -    if (props &&
> -        virQEMUBuildCommandLineJSON(props, buf,
> -                                    virQEMUBuildCommandLineJSONArrayBitmap) < 0)
> -        return -1;
> +    virBufferAsprintf(buf, "%s,id=%s", type, alias);

Keep the newline here.

> +    if (props) {
> +        virBufferAsprintf(buf, ",");

Use vir BufferAddLit instead.

> +        if (virQEMUBuildCommandLineJSON(props, buf,
> +                                virQEMUBuildCommandLineJSONArrayBitmap) < 0)
> +            return -1;
> +    }
>  
>      return 0;
>  }
> -- 
> 2.23.0
> 
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list




More information about the libvir-list mailing list