Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
---
tests/qemuagenttest.c | 7 ++-----
tests/qemublocktest.c | 2 +-
tests/qemucapabilitiestest.c | 9 +++------
tests/qemucaps2xmltest.c | 7 ++-----
tests/qemuhotplugtest.c | 6 ++----
tests/qemumemlocktest.c | 7 ++-----
tests/qemumigparamstest.c | 24 ++++++++----------------
tests/qemumonitortestutils.c | 9 +++------
tests/qemuxml2argvtest.c | 9 +++------
tests/qemuxml2xmltest.c | 3 +--
10 files changed, 27 insertions(+), 56 deletions(-)
diff --git a/tests/qemuagenttest.c b/tests/qemuagenttest.c
index 347438c14a..607bd97b5c 100644
--- a/tests/qemuagenttest.c
+++ b/tests/qemuagenttest.c
@@ -175,7 +175,7 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOptionPtr xmlopt,
int ret = -1;
g_autofree char *domain_filename = NULL;
qemuMonitorTestPtr ret_test = NULL;
- virDomainDefPtr ret_def = NULL;
+ g_autoptr(virDomainDef) ret_def = NULL;
if (!test || !def)
return -1;
@@ -235,8 +235,6 @@ testQemuAgentGetFSInfoCommon(virDomainXMLOptionPtr xmlopt,
cleanup:
if (ret_test)
qemuMonitorTestFree(ret_test);
- virDomainDefFree(ret_def);
-
return ret;
}
@@ -400,7 +398,7 @@ qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test,
const char *cmdstr)
{
struct qemuAgentShutdownTestData *data;
- virJSONValuePtr val = NULL;
+ g_autoptr(virJSONValue) val = NULL;
virJSONValuePtr args;
const char *cmdname;
const char *mode;
@@ -447,7 +445,6 @@ qemuAgentShutdownTestMonitorHandler(qemuMonitorTestPtr test,
ret = 0;
cleanup:
- virJSONValueFree(val);
return ret;
}
diff --git a/tests/qemublocktest.c b/tests/qemublocktest.c
index 025e96ab4b..fb5319d7bd 100644
--- a/tests/qemublocktest.c
+++ b/tests/qemublocktest.c
@@ -987,7 +987,7 @@ mymain(void)
struct testQemuBlockBitmapBlockcopyData blockbitmapblockcopydata;
struct testQemuBlockBitmapBlockcommitData blockbitmapblockcommitdata;
char *capslatest_x86_64 = NULL;
- virQEMUCapsPtr caps_x86_64 = NULL;
+ g_autoptr(virQEMUCaps) caps_x86_64 = NULL;
g_autoptr(virHashTable) qmp_schema_x86_64 = NULL;
virJSONValuePtr qmp_schemaroot_x86_64_blockdev_add = NULL;
g_autoptr(virStorageSource) bitmapSourceChain = NULL;
diff --git a/tests/qemucapabilitiestest.c b/tests/qemucapabilitiestest.c
index be8741dd5f..81f29c6493 100644
--- a/tests/qemucapabilitiestest.c
+++ b/tests/qemucapabilitiestest.c
@@ -74,7 +74,7 @@ testQemuCaps(const void *opaque)
g_autofree char *repliesFile = NULL;
g_autofree char *capsFile = NULL;
qemuMonitorTestPtr mon = NULL;
- virQEMUCapsPtr capsActual = NULL;
+ g_autoptr(virQEMUCaps) capsActual = NULL;
g_autofree char *binary = NULL;
g_autofree char *actual = NULL;
unsigned int fakeMicrocodeVersion = 0;
@@ -134,7 +134,6 @@ testQemuCaps(const void *opaque)
ret = 0;
cleanup:
qemuMonitorTestFree(mon);
- virObjectUnref(capsActual);
return ret;
}
@@ -145,8 +144,8 @@ testQemuCapsCopy(const void *opaque)
int ret = -1;
const testQemuData *data = opaque;
g_autofree char *capsFile = NULL;
- virQEMUCapsPtr orig = NULL;
- virQEMUCapsPtr copy = NULL;
+ g_autoptr(virQEMUCaps) orig = NULL;
+ g_autoptr(virQEMUCaps) copy = NULL;
g_autofree char *actual = NULL;
capsFile = g_strdup_printf("%s/%s_%s.%s.xml",
@@ -169,8 +168,6 @@ testQemuCapsCopy(const void *opaque)
ret = 0;
cleanup:
- virObjectUnref(orig);
- virObjectUnref(copy);
return ret;
}
diff --git a/tests/qemucaps2xmltest.c b/tests/qemucaps2xmltest.c
index 5ff4374935..5316a221ff 100644
--- a/tests/qemucaps2xmltest.c
+++ b/tests/qemucaps2xmltest.c
@@ -94,7 +94,7 @@ testQemuGetCaps(char *caps)
static virCapsPtr
testGetCaps(char *capsData, const testQemuData *data)
{
- virQEMUCapsPtr qemuCaps = NULL;
+ g_autoptr(virQEMUCaps) qemuCaps = NULL;
virCapsPtr caps = NULL;
virArch arch = virArchFromString(data->archName);
g_autofree char *binary = NULL;
@@ -119,11 +119,9 @@ testGetCaps(char *capsData, const testQemuData *data)
goto error;
}
- virObjectUnref(qemuCaps);
return caps;
error:
- virObjectUnref(qemuCaps);
virObjectUnref(caps);
return NULL;
}
@@ -137,7 +135,7 @@ testQemuCapsXML(const void *opaque)
g_autofree char *xmlFile = NULL;
g_autofree char *capsData = NULL;
g_autofree char *capsXml = NULL;
- virCapsPtr capsProvided = NULL;
+ g_autoptr(virCaps) capsProvided = NULL;
xmlFile = g_strdup_printf("%s/caps.%s.xml", data->outputDir,
data->archName);
@@ -160,7 +158,6 @@ testQemuCapsXML(const void *opaque)
ret = 0;
cleanup:
- virObjectUnref(capsProvided);
return ret;
}
diff --git a/tests/qemuhotplugtest.c b/tests/qemuhotplugtest.c
index 9d7d2e44e8..ba644abe8a 100644
--- a/tests/qemuhotplugtest.c
+++ b/tests/qemuhotplugtest.c
@@ -244,7 +244,7 @@ testQemuHotplug(const void *data)
unsigned int device_parse_flags = 0;
virDomainObjPtr vm = NULL;
virDomainDeviceDefPtr dev = NULL;
- virCapsPtr caps = NULL;
+ g_autoptr(virCaps) caps = NULL;
qemuMonitorTestPtr test_mon = NULL;
qemuDomainObjPrivatePtr priv = NULL;
@@ -349,7 +349,6 @@ testQemuHotplug(const void *data)
test->vm = NULL;
}
virDomainDeviceDefFree(dev);
- virObjectUnref(caps);
qemuMonitorTestFree(test_mon);
return ((ret < 0 && fail) || (!ret && !fail)) ? 0 : -1;
}
@@ -555,7 +554,7 @@ testQemuHotplugCpuIndividual(const void *opaque)
{
const struct testQemuHotplugCpuParams *params = opaque;
struct testQemuHotplugCpuData *data = NULL;
- virBitmapPtr map = NULL;
+ g_autoptr(virBitmap) map = NULL;
int ret = -1;
int rc;
@@ -584,7 +583,6 @@ testQemuHotplugCpuIndividual(const void *opaque)
ret = testQemuHotplugCpuFinalize(data);
cleanup:
- virBitmapFree(map);
testQemuHotplugCpuDataFree(data);
return ret;
}
diff --git a/tests/qemumemlocktest.c b/tests/qemumemlocktest.c
index 0867e3a255..68e446ba7b 100644
--- a/tests/qemumemlocktest.c
+++ b/tests/qemumemlocktest.c
@@ -30,7 +30,7 @@ static int
testCompareMemLock(const void *data)
{
const struct testInfo *info = data;
- virDomainDefPtr def = NULL;
+ g_autoptr(virDomainDef) def = NULL;
g_autofree char *xml = NULL;
int ret = -1;
@@ -45,7 +45,6 @@ testCompareMemLock(const void *data)
ret = virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(def,
false));
cleanup:
- virDomainDefFree(def);
return ret;
}
@@ -57,7 +56,7 @@ mymain(void)
{
int ret = 0;
g_autofree char *fakerootdir = NULL;
- virQEMUCapsPtr qemuCaps = NULL;
+ g_autoptr(virQEMUCaps) qemuCaps = NULL;
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
@@ -145,8 +144,6 @@ mymain(void)
DO_TEST("pseries-locked+hostdev", VIR_DOMAIN_MEMORY_PARAM_UNLIMITED);
cleanup:
- virObjectUnref(qemuCaps);
-
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);
diff --git a/tests/qemumigparamstest.c b/tests/qemumigparamstest.c
index f4357e0f53..e6e6bf7138 100644
--- a/tests/qemumigparamstest.c
+++ b/tests/qemumigparamstest.c
@@ -60,9 +60,9 @@ qemuMigParamsTestXML2XML(const void *opaque)
const qemuMigParamsData *data = opaque;
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *xmlFile = NULL;
- xmlDocPtr doc = NULL;
- xmlXPathContextPtr ctxt = NULL;
- qemuMigrationParamsPtr migParams = NULL;
+ g_autoptr(xmlDoc) doc = NULL;
+ g_autoptr(xmlXPathContext) ctxt = NULL;
+ g_autoptr(qemuMigrationParams) migParams = NULL;
g_autofree char *actualXML = NULL;
int ret = -1;
@@ -86,9 +86,6 @@ qemuMigParamsTestXML2XML(const void *opaque)
ret = 0;
cleanup:
- qemuMigrationParamsFree(migParams);
- xmlXPathFreeContext(ctxt);
- xmlFreeDoc(doc);
return ret;
}
@@ -101,8 +98,8 @@ qemuMigParamsTestXML(const void *opaque)
g_autofree char *replyFile = NULL;
g_autofree char *xmlFile = NULL;
qemuMonitorTestPtr mon = NULL;
- virJSONValuePtr params = NULL;
- qemuMigrationParamsPtr migParams = NULL;
+ g_autoptr(virJSONValue) params = NULL;
+ g_autoptr(qemuMigrationParams) migParams = NULL;
g_autofree char *actualXML = NULL;
int ret = -1;
@@ -132,8 +129,6 @@ qemuMigParamsTestXML(const void *opaque)
ret = 0;
cleanup:
- virJSONValueFree(params);
- qemuMigrationParamsFree(migParams);
qemuMonitorTestFree(mon);
return ret;
}
@@ -146,9 +141,9 @@ qemuMigParamsTestJSON(const void *opaque)
g_autofree char *replyFile = NULL;
g_autofree char *jsonFile = NULL;
qemuMonitorTestPtr mon = NULL;
- virJSONValuePtr paramsIn = NULL;
- virJSONValuePtr paramsOut = NULL;
- qemuMigrationParamsPtr migParams = NULL;
+ g_autoptr(virJSONValue) paramsIn = NULL;
+ g_autoptr(virJSONValue) paramsOut = NULL;
+ g_autoptr(qemuMigrationParams) migParams = NULL;
g_autofree char *actualJSON = NULL;
int ret = -1;
@@ -177,9 +172,6 @@ qemuMigParamsTestJSON(const void *opaque)
ret = 0;
cleanup:
- virJSONValueFree(paramsIn);
- virJSONValueFree(paramsOut);
- qemuMigrationParamsFree(migParams);
qemuMonitorTestFree(mon);
return ret;
}
diff --git a/tests/qemumonitortestutils.c b/tests/qemumonitortestutils.c
index 08e90757b1..7fa5ad6a9a 100644
--- a/tests/qemumonitortestutils.c
+++ b/tests/qemumonitortestutils.c
@@ -720,7 +720,7 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test,
qemuMonitorTestItemPtr item G_GNUC_UNUSED,
const char *cmdstr)
{
- virJSONValuePtr val = NULL;
+ g_autoptr(virJSONValue) val = NULL;
virJSONValuePtr args;
unsigned long long id;
const char *cmdname;
@@ -756,7 +756,6 @@ qemuMonitorTestProcessGuestAgentSync(qemuMonitorTestPtr test,
ret = qemuMonitorTestAddResponse(test, retmsg);
cleanup:
- virJSONValueFree(val);
return ret;
}
@@ -783,7 +782,7 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
const char *cmdstr)
{
struct qemuMonitorTestHandlerData *data = item->opaque;
- virJSONValuePtr val = NULL;
+ g_autoptr(virJSONValue) val = NULL;
virJSONValuePtr args;
virJSONValuePtr argobj;
const char *cmdname;
@@ -841,7 +840,6 @@ qemuMonitorTestProcessCommandWithArgs(qemuMonitorTestPtr test,
ret = qemuMonitorTestAddResponse(test, data->response);
cleanup:
- virJSONValueFree(val);
return ret;
}
@@ -905,7 +903,7 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
const char *cmdstr)
{
struct qemuMonitorTestHandlerData *data = item->opaque;
- virJSONValuePtr val = NULL;
+ g_autoptr(virJSONValue) val = NULL;
virJSONValuePtr args;
g_autofree char *argstr = NULL;
const char *cmdname;
@@ -946,7 +944,6 @@ qemuMonitorTestProcessCommandWithArgStr(qemuMonitorTestPtr test,
ret = qemuMonitorTestAddResponse(test, data->response);
cleanup:
- virJSONValueFree(val);
return ret;
}
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index 9388f7bf39..f26de13df1 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -565,9 +565,9 @@ testCompareXMLToArgv(const void *data)
int ret = -1;
virDomainObjPtr vm = NULL;
virDomainChrSourceDef monitor_chr;
- virConnectPtr conn;
+ g_autoptr(virConnect) conn = NULL;
char *log = NULL;
- virCommandPtr cmd = NULL;
+ g_autoptr(virCommand) cmd = NULL;
qemuDomainObjPrivatePtr priv = NULL;
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
@@ -688,11 +688,9 @@ testCompareXMLToArgv(const void *data)
cleanup:
VIR_FREE(log);
virDomainChrSourceDefClear(&monitor_chr);
- virCommandFree(cmd);
virObjectUnref(vm);
virSetConnectSecret(NULL);
virSetConnectStorage(NULL);
- virObjectUnref(conn);
if (info->arch != VIR_ARCH_NONE && info->arch != VIR_ARCH_X86_64)
qemuTestSetHostArch(&driver, VIR_ARCH_NONE);
@@ -716,7 +714,7 @@ mymain(void)
{
int ret = 0;
g_autofree char *fakerootdir = NULL;
- virHashTablePtr capslatest = NULL;
+ g_autoptr(virHashTable) capslatest = NULL;
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
@@ -3362,7 +3360,6 @@ mymain(void)
VIR_FREE(driver.config->nbdTLSx509certdir);
qemuTestDriverFree(&driver);
- virHashFree(capslatest);
virFileWrapperClearPrefixes();
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c
index ccb810ee08..579dac4d6a 100644
--- a/tests/qemuxml2xmltest.c
+++ b/tests/qemuxml2xmltest.c
@@ -133,7 +133,7 @@ mymain(void)
int ret = 0;
g_autofree char *fakerootdir = NULL;
virQEMUDriverConfigPtr cfg = NULL;
- virHashTablePtr capslatest = NULL;
+ g_autoptr(virHashTable) capslatest = NULL;
g_autoptr(virConnect) conn = NULL;
capslatest = testQemuGetLatestCaps();
@@ -1498,7 +1498,6 @@ mymain(void)
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
virFileDeleteTree(fakerootdir);
- virHashFree(capslatest);
qemuTestDriverFree(&driver);
virFileWrapperClearPrefixes();
--
2.26.2