virQEMUDriverConfigPtr can be auto-unref for the great majority
of the uses made in qemu_driver, sparing us a virObjectUnref()
call and sometimes a whole 'cleanup' label.
This patch changes virQEMUDriverConfigPtr declarations to
use VIR_AUTOUNREF(). 'cleanup' labels were deleted when
applicable.
This is the last part of this change. All but one* instance of
virQEMUDriverConfigPtr were changed to use VIR_AUTOUNREF().
'cleanup' labels were deleted when applicable.
* qemuStateInitialize: we can't auto-unref the pointer since we're
initializing the qemu_driver object with it.
Signed-off-by: Daniel Henrique Barboza <danielhb413(a)gmail.com>
---
src/qemu/qemu_driver.c | 57 ++++++++++++++----------------------------
1 file changed, 19 insertions(+), 38 deletions(-)
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index c7ed662ff1..bc2e2ccfc2 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -10209,7 +10209,7 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
virDomainDefPtr persistentDef;
virDomainObjPtr vm = NULL;
int ret = -1;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
qemuDomainObjPrivatePtr priv;
virBitmapPtr nodeset = NULL;
virDomainNumatuneMemMode config_mode;
@@ -10321,7 +10321,6 @@ qemuDomainSetNumaParameters(virDomainPtr dom,
cleanup:
virBitmapFree(nodeset);
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
@@ -10426,7 +10425,7 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
virQEMUDriverPtr driver = dom->conn->privateData;
size_t i;
virDomainObjPtr vm = NULL;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
qemuDomainObjPrivatePtr priv;
virDomainDefPtr def;
virDomainDefPtr persistentDef;
@@ -10518,7 +10517,6 @@ qemuDomainSetPerfEvents(virDomainPtr dom,
cleanup:
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
@@ -10705,7 +10703,7 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
long long value_l;
int ret = -1;
int rc;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv;
virObjectEventPtr event = NULL;
@@ -10999,7 +10997,6 @@ qemuDomainSetSchedulerParametersFlags(virDomainPtr dom,
if (eventNparams)
virTypedParamsFree(eventParams, eventNparams);
virObjectUnref(caps);
- virObjectUnref(cfg);
return ret;
}
#undef SCHED_RANGE_CHECK
@@ -11664,7 +11661,7 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
int ret = -1;
virDomainNetDefPtr net = NULL, persistentNet = NULL;
virNetDevBandwidthPtr bandwidth = NULL, newBandwidth = NULL;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
bool inboundSpecified = false, outboundSpecified = false;
int actualType;
bool qosSupported = true;
@@ -11859,7 +11856,6 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom,
virNetDevBandwidthFree(bandwidth);
virNetDevBandwidthFree(newBandwidth);
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
@@ -12121,7 +12117,7 @@ qemuDomainMemoryPeek(virDomainPtr dom,
char *tmp = NULL;
int fd = -1, ret = -1;
qemuDomainObjPrivatePtr priv;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCheckFlags(VIR_MEMORY_VIRTUAL | VIR_MEMORY_PHYSICAL, -1);
@@ -12192,7 +12188,6 @@ qemuDomainMemoryPeek(virDomainPtr dom,
unlink(tmp);
VIR_FREE(tmp);
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
@@ -12409,7 +12404,7 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
virDomainObjPtr vm;
int ret = -1;
virDomainDiskDefPtr disk;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
qemuBlockStatsPtr entry = NULL;
virCheckFlags(0, -1);
@@ -12498,7 +12493,6 @@ qemuDomainGetBlockInfo(virDomainPtr dom,
cleanup:
VIR_FREE(entry);
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
@@ -12970,7 +12964,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
unsigned int flags)
{
virQEMUDriverPtr driver = dconn->privateData;
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
virDomainDefPtr def = NULL;
const char *dom_xml = NULL;
const char *dname = NULL;
@@ -13044,7 +13038,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
VIR_FREE(migrate_disks);
VIR_FREE(origname);
virDomainDefFree(def);
- virObjectUnref(cfg);
return ret;
}
@@ -14614,7 +14607,7 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
virCommandPtr cmd = NULL;
const char *qemuImgPath;
virBitmapPtr created = NULL;
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
int ret = -1;
virBuffer buf = VIR_BUFFER_INITIALIZER;
virDomainSnapshotDefPtr snapdef = virDomainSnapshotObjGetDef(snap);
@@ -14702,7 +14695,6 @@ qemuDomainSnapshotCreateInactiveExternal(virQEMUDriverPtr driver,
}
}
virBitmapFree(created);
- virObjectUnref(cfg);
return ret;
}
@@ -15804,7 +15796,7 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
unsigned int parse_flags = VIR_DOMAIN_SNAPSHOT_PARSE_DISKS;
int align_location = VIR_DOMAIN_SNAPSHOT_LOCATION_INTERNAL;
bool align_match = true;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv;
virDomainSnapshotState state;
@@ -16094,7 +16086,6 @@ qemuDomainSnapshotCreateXML(virDomainPtr domain,
virDomainObjEndAPI(&vm);
VIR_FREE(xml);
virObjectUnref(caps);
- virObjectUnref(cfg);
return snapshot;
}
@@ -16505,7 +16496,7 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
int rc;
virDomainDefPtr config = NULL;
virDomainDefPtr inactiveConfig = NULL;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCapsPtr caps = NULL;
bool was_stopped = false;
qemuDomainSaveCookiePtr cookie;
@@ -16935,7 +16926,6 @@ qemuDomainRevertToSnapshot(virDomainSnapshotPtr snapshot,
virObjectEventStateQueue(driver->domainEventState, event2);
virDomainObjEndAPI(&vm);
virObjectUnref(caps);
- virObjectUnref(cfg);
virNWFilterUnlockFilterUpdates();
virCPUDefFree(origCPU);
virDomainDefFree(config);
@@ -16996,7 +16986,7 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
virQEMUMomentReparent rep;
bool metadata_only = !!(flags & VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY);
int external = 0;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN |
VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY |
@@ -17088,7 +17078,6 @@ qemuDomainSnapshotDelete(virDomainSnapshotPtr snapshot,
cleanup:
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
@@ -17216,7 +17205,7 @@ qemuDomainCheckpointCreateXML(virDomainPtr domain,
bool redefine = flags & VIR_DOMAIN_CHECKPOINT_CREATE_REDEFINE;
unsigned int parse_flags = 0;
virDomainMomentObjPtr other = NULL;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCapsPtr caps = NULL;
qemuDomainObjPrivatePtr priv;
virJSONValuePtr actions = NULL;
@@ -17358,7 +17347,6 @@ qemuDomainCheckpointCreateXML(virDomainPtr domain,
virDomainObjEndAPI(&vm);
VIR_FREE(xml);
virObjectUnref(caps);
- virObjectUnref(cfg);
return checkpoint;
}
@@ -17532,7 +17520,7 @@ qemuDomainCheckpointDelete(virDomainCheckpointPtr checkpoint,
virQEMUMomentRemove rem;
virQEMUMomentReparent rep;
bool metadata_only = !!(flags & VIR_DOMAIN_CHECKPOINT_DELETE_METADATA_ONLY);
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCheckFlags(VIR_DOMAIN_CHECKPOINT_DELETE_CHILDREN |
VIR_DOMAIN_CHECKPOINT_DELETE_METADATA_ONLY |
@@ -17622,7 +17610,6 @@ qemuDomainCheckpointDelete(virDomainCheckpointPtr checkpoint,
cleanup:
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
@@ -18017,7 +18004,7 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainDiskDefPtr disk = NULL;
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
bool pivot = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_PIVOT);
bool async = !!(flags & VIR_DOMAIN_BLOCK_JOB_ABORT_ASYNC);
qemuBlockJobDataPtr job = NULL;
@@ -18122,7 +18109,6 @@ qemuDomainBlockJobAbort(virDomainPtr dom,
cleanup:
virObjectUnref(job);
- virObjectUnref(cfg);
virDomainObjEndAPI(&vm);
return ret;
}
@@ -19393,7 +19379,7 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
bool supportMaxOptions = true;
bool supportGroupNameOption = true;
bool supportMaxLengthOptions = true;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virObjectEventPtr event = NULL;
virTypedParameterPtr eventParams = NULL;
int eventNparams = 0;
@@ -19714,7 +19700,6 @@ qemuDomainSetBlockIoTune(virDomainPtr dom,
virDomainObjEndAPI(&vm);
if (eventNparams)
virTypedParamsFree(eventParams, eventNparams);
- virObjectUnref(cfg);
return ret;
}
@@ -19964,7 +19949,7 @@ qemuDomainSetMetadata(virDomainPtr dom,
{
virQEMUDriverPtr driver = dom->conn->privateData;
virDomainObjPtr vm;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virCapsPtr caps = NULL;
int ret = -1;
@@ -20000,7 +19985,6 @@ qemuDomainSetMetadata(virDomainPtr dom,
cleanup:
virDomainObjEndAPI(&vm);
virObjectUnref(caps);
- virObjectUnref(cfg);
return ret;
}
@@ -21757,7 +21741,7 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
virHashTablePtr nodestats = NULL;
virJSONValuePtr nodedata = NULL;
qemuDomainObjPrivatePtr priv = dom->privateData;
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
bool blockdev = virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV);
bool fetchnodedata = virQEMUCapsGet(priv->qemuCaps,
QEMU_CAPS_QUERY_NAMED_BLOCK_NODES) &&
!blockdev;
@@ -21814,7 +21798,6 @@ qemuDomainGetStatsBlock(virQEMUDriverPtr driver,
virHashFree(stats);
virHashFree(nodestats);
virJSONValueFree(nodedata);
- virObjectUnref(cfg);
return ret;
}
@@ -22513,7 +22496,7 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
- virQEMUDriverConfigPtr cfg = NULL;
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = NULL;
virObjectEventPtr event_new = NULL;
virObjectEventPtr event_old = NULL;
int ret = -1;
@@ -22602,7 +22585,6 @@ qemuDomainRenameCallback(virDomainObjPtr vm,
VIR_FREE(new_dom_name);
virObjectEventStateQueue(driver->domainEventState, event_old);
virObjectEventStateQueue(driver->domainEventState, event_new);
- virObjectUnref(cfg);
return ret;
rollback:
@@ -23065,7 +23047,7 @@ qemuDomainSetLifecycleAction(virDomainPtr dom,
unsigned int flags)
{
virQEMUDriverPtr driver = dom->conn->privateData;
- virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
+ VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg = virQEMUDriverGetConfig(driver);
qemuDomainObjPrivatePtr priv;
virDomainObjPtr vm = NULL;
virDomainDefPtr def = NULL;
@@ -23122,7 +23104,6 @@ qemuDomainSetLifecycleAction(virDomainPtr dom,
cleanup:
virDomainObjEndAPI(&vm);
- virObjectUnref(cfg);
return ret;
}
--
2.21.0