From 527da4ce9b7620c07c62807da264e4f363753edc Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Wed, 20 Feb 2019 09:51:06 +0100 Subject: [PATCH] qemu: Use refcounting for priv->monConfig MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use refcounting for priv->monConfig instead of asymmetric freeing. Signed-off-by: Marc Hartmayer Reviewed-by: Boris Fiuczynski Reviewed-by: Ján Tomko Signed-off-by: Ján Tomko --- src/qemu/qemu_driver.c | 5 +---- src/qemu/qemu_process.c | 6 +++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index fe1b7801e9..010d7e2853 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17026,21 +17026,18 @@ static virDomainPtr qemuDomainQemuAttach(virConnectPtr conn, if (qemuProcessAttach(conn, driver, vm, pid, pidfile, monConfig, monJSON) < 0) { - monConfig = NULL; qemuDomainRemoveInactive(driver, vm); qemuDomainObjEndJob(driver, vm); goto cleanup; } - monConfig = NULL; - dom = virGetDomain(conn, vm->def->name, vm->def->uuid, vm->def->id); qemuDomainObjEndJob(driver, vm); cleanup: virDomainDefFree(def); - virDomainChrSourceDefFree(monConfig); + virObjectUnref(monConfig); virDomainObjEndAPI(&vm); VIR_FREE(pidfile); virObjectUnref(caps); diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 85952b9975..f06fe62f99 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7528,8 +7528,7 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, goto error; VIR_DEBUG("Preparing monitor state"); - priv->monConfig = monConfig; - monConfig = NULL; + priv->monConfig = virObjectRef(monConfig); priv->monJSON = monJSON; /* Attaching to running QEMU so we need to detect whether it was started @@ -7648,7 +7647,8 @@ int qemuProcessAttach(virConnectPtr conn ATTRIBUTE_UNUSED, VIR_FREE(sec_managers); if (seclabelgen) virSecurityLabelDefFree(seclabeldef); - virDomainChrSourceDefFree(monConfig); + virObjectUnref(priv->monConfig); + priv->monConfig = NULL; virObjectUnref(cfg); virObjectUnref(caps); return -1;