From: Han Han Date: Thu, 9 Jan 2020 08:00:06 +0000 (+0800) Subject: util: Do not assume comma after object id X-Git-Tag: v6.1.0-rc1~437 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1bd17918b63225ef19ab85fb364c27ed88254503;p=thirdparty%2Flibvirt.git util: Do not assume comma after object id 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 Reviewed-by: Michal Privoznik --- diff --git a/src/util/virqemu.c b/src/util/virqemu.c index f3a233af3d..8d0429625d 100644 --- a/src/util/virqemu.c +++ b/src/util/virqemu.c @@ -239,12 +239,14 @@ virQEMUBuildObjectCommandlineFromJSONInternal(virBufferPtr buf, return -1; } - virBufferAsprintf(buf, "%s,id=%s,", type, alias); + virBufferAsprintf(buf, "%s,id=%s", type, alias); - if (props && - virQEMUBuildCommandLineJSON(props, buf, - virQEMUBuildCommandLineJSONArrayBitmap) < 0) - return -1; + if (props) { + virBufferAddLit(buf, ","); + if (virQEMUBuildCommandLineJSON(props, buf, + virQEMUBuildCommandLineJSONArrayBitmap) < 0) + return -1; + } return 0; }