]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: Do not assume comma after object id
authorHan Han <hhan@redhat.com>
Thu, 9 Jan 2020 08:00:06 +0000 (16:00 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 24 Jan 2020 16:03:29 +0000 (17:03 +0100)
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@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virqemu.c

index f3a233af3d8d1c2caad569f395ca54830baedc8c..8d0429625d1a078f1ded466440db43627e92ad6a 100644 (file)
@@ -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;
 }