]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemuMonitorAddObject: Fix semantics of @alias
authorPeter Krempa <pkrempa@redhat.com>
Mon, 30 Nov 2020 15:21:18 +0000 (16:21 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 8 Jan 2021 08:17:25 +0000 (09:17 +0100)
The callers of qemuMonitorAddObject rely on the fact that @alias is
filled only when the object is added successfully. This is documented
but the code didn't behave like that.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
src/qemu/qemu_monitor.c

index 93527547bab912a816abdb8d8db70d577f4ec612..fc3df8943a6a00927a50d17cdb434eb014eed264 100644 (file)
@@ -3078,11 +3078,14 @@ qemuMonitorAddObject(qemuMonitorPtr mon,
     if (alias)
         tmp = g_strdup(id);
 
-    ret = qemuMonitorJSONAddObject(mon, props);
+    if (qemuMonitorJSONAddObject(mon, props) < 0)
+        goto cleanup;
 
     if (alias)
         *alias = g_steal_pointer(&tmp);
 
+    ret = 0;
+
  cleanup:
     VIR_FREE(tmp);
     virJSONValueFree(*props);