qemuMonitorAddObject: Fix semantics of @alias

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>
This commit is contained in:
Peter Krempa 2020-11-30 16:21:18 +01:00
parent 83e1d8fb97
commit 64cf9b0fa7

View 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);