mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-20 07:59:00 +00:00
ch: Correctly ref and close the virCHMonitor in virCHMonitorNew
In virCHMontiorNew the monitor object was referenced an additional time incorrectly preventing it from being disposed of, and wasn't always closed properly on failure. Signed-off-by: William Douglas <william.douglas@intel.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
5abf5949c1
commit
bfaac4c2b1
@ -468,7 +468,7 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir)
|
||||
if (!vm->def) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("VM is not defined"));
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
/* prepare to launch Cloud-Hypervisor socket */
|
||||
@ -502,12 +502,13 @@ virCHMonitorNew(virDomainObj *vm, const char *socketdir)
|
||||
mon->handle = curl_easy_init();
|
||||
|
||||
/* now has its own reference */
|
||||
virObjectRef(mon);
|
||||
mon->vm = virObjectRef(vm);
|
||||
|
||||
ret = mon;
|
||||
mon = NULL;
|
||||
|
||||
cleanup:
|
||||
virCHMonitorClose(mon);
|
||||
virCommandFree(cmd);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user