[PATCH 07/24] qemuMonitorAddObject: Fix semantics of @alias

Peter Krempa pkrempa at redhat.com
Mon Nov 30 18:55:20 UTC 2020


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 at redhat.com>
---
 src/qemu/qemu_monitor.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index 7f58c16987..c4fa111836 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -3104,11 +3104,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);
-- 
2.28.0




More information about the libvir-list mailing list