testQemuAgentFSFreeze(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
const char *mountpoints[] = {"/fs1", "/fs2", "/fs3", "/fs4", "/fs5"};
int ret = -1;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentFSThaw(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
int ret = -1;
if (!test)
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentFSTrim(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
int ret = -1;
if (!test)
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
return ret;
}
{
int ret = -1;
g_autofree char *domain_filename = NULL;
- qemuMonitorTest *ret_test = NULL;
+ g_autoptr(qemuMonitorTest) ret_test = NULL;
g_autoptr(virDomainDef) ret_def = NULL;
if (!test || !def)
ret = 0;
cleanup:
- if (ret_test)
- qemuMonitorTestFree(ret_test);
return ret;
}
testQemuAgentGetFSInfo(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = NULL;
+ g_autoptr(qemuMonitorTest) test = NULL;
g_autoptr(virDomainDef) def = NULL;
qemuAgentFSInfo **info = NULL;
int ret = -1, ninfo = 0, i;
for (i = 0; i < ninfo; i++)
qemuAgentFSInfoFree(info[i]);
VIR_FREE(info);
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentSuspend(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
int ret = -1;
size_t i;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentShutdown(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
struct qemuAgentShutdownTestData priv;
int ret = -1;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentCPU(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
qemuAgentCPUInfo *cpuinfo = NULL;
int nvcpus;
int ret = -1;
cleanup:
VIR_FREE(cpuinfo);
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentArbitraryCommand(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
int ret = -1;
g_autofree char *reply = NULL;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentTimeout(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
g_autofree char *reply = NULL;
int ret = -1;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentGetInterfaces(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
size_t i;
int ret = -1;
int ifaces_count = 0;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
if (ifaces) {
for (i = 0; i < ifaces_count; i++)
virDomainInterfaceFree(ifaces[i]);
testQemuAgentGetDisks(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
size_t i;
int ret = -1;
int disks_count = 0;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
if (disks) {
for (i = 0; i < disks_count; i++)
qemuAgentDiskInfoFree(disks[i]);
testQemuAgentUsers(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
virTypedParameterPtr params = NULL;
int nparams = 0;
int maxparams = 0;
cleanup:
virTypedParamsFree(params, nparams);
- qemuMonitorTestFree(test);
return ret;
}
testQemuAgentOSInfo(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
virTypedParameterPtr params = NULL;
int nparams = 0;
int maxparams = 0;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
virTypedParamsFree(params, nparams);
return ret;
}
testQemuAgentTimezone(const void *data)
{
virDomainXMLOption *xmlopt = (virDomainXMLOption *)data;
- qemuMonitorTest *test = qemuMonitorTestNewAgent(xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewAgent(xmlopt);
virTypedParameterPtr params = NULL;
int nparams = 0;
int ret = -1;
ret = 0;
cleanup:
- qemuMonitorTestFree(test);
virTypedParamsFree(params, nparams);
return ret;
}
testQemuData *data = (void *) opaque;
g_autofree char *repliesFile = NULL;
g_autofree char *capsFile = NULL;
- qemuMonitorTest *mon = NULL;
+ g_autoptr(qemuMonitorTest) mon = NULL;
g_autoptr(virQEMUCaps) capsActual = NULL;
g_autofree char *binary = NULL;
g_autofree char *actual = NULL;
ret = 0;
cleanup:
- qemuMonitorTestFree(mon);
return ret;
}
virDomainObj *vm = NULL;
virDomainDeviceDef *dev = NULL;
g_autoptr(virCaps) caps = NULL;
- qemuMonitorTest *test_mon = NULL;
+ g_autoptr(qemuMonitorTest) test_mon = NULL;
qemuDomainObjPrivate *priv = NULL;
domain_filename = g_strdup_printf("%s/qemuhotplugtestdomains/qemuhotplug-%s.xml",
test->vm = NULL;
}
virDomainDeviceDefFree(dev);
- qemuMonitorTestFree(test_mon);
return ((ret < 0 && fail) || (!ret && !fail)) ? 0 : -1;
}
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
g_autofree char *replyFile = NULL;
g_autofree char *xmlFile = NULL;
- qemuMonitorTest *mon = NULL;
+ g_autoptr(qemuMonitorTest) mon = NULL;
g_autoptr(virJSONValue) params = NULL;
g_autoptr(qemuMigrationParams) migParams = NULL;
g_autofree char *actualXML = NULL;
ret = 0;
cleanup:
- qemuMonitorTestFree(mon);
return ret;
}
const qemuMigParamsData *data = opaque;
g_autofree char *replyFile = NULL;
g_autofree char *jsonFile = NULL;
- qemuMonitorTest *mon = NULL;
+ g_autoptr(qemuMonitorTest) mon = NULL;
g_autoptr(virJSONValue) paramsIn = NULL;
g_autoptr(virJSONValue) paramsOut = NULL;
g_autoptr(qemuMigrationParams) migParams = NULL;
ret = 0;
cleanup:
- qemuMonitorTestFree(mon);
return ret;
}
{
struct qemuMonitorJSONTestAttachChardevData data = {0};
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewSchema(xmlopt, schema);
g_autofree char *jsonreply = NULL;
g_autofree char *fulllabel = NULL;
int ret = -1;
+ if (!test)
+ goto cleanup;
+
if (!reply)
reply = "";
fulllabel = g_strdup_printf("qemuMonitorJSONTestAttachChardev(%s)", label);
- data.chr = chr;
- data.fail = fail;
- data.expectPty = expectPty;
- if (!(data.test = qemuMonitorTestNewSchema(xmlopt, schema)))
- goto cleanup;
-
- qemuMonitorTestAllowUnusedCommands(data.test);
+ qemuMonitorTestAllowUnusedCommands(test);
- if (qemuMonitorTestAddItemExpect(data.test, "chardev-add",
+ if (qemuMonitorTestAddItemExpect(test, "chardev-add",
expectargs, true, jsonreply) < 0)
goto cleanup;
+ data.chr = chr;
+ data.fail = fail;
+ data.expectPty = expectPty;
+ data.test = test;
+
if (virTestRun(fulllabel, &testQemuMonitorJSONAttachChardev, &data) < 0)
goto cleanup;
ret = 0;
cleanup:
- qemuMonitorTestFree(data.test);
return ret;
}
testQueryJobs(const void *opaque)
{
const struct testQueryJobsData *data = opaque;
- qemuMonitorTest *test = qemuMonitorTestNewSimple(data->xmlopt);
+ g_autoptr(qemuMonitorTest) test = qemuMonitorTestNewSimple(data->xmlopt);
g_autofree char *filenameJSON = NULL;
g_autofree char *fileJSON = NULL;
g_autofree char *filenameResult = NULL;
for (i = 0; i < njobs; i++)
qemuMonitorJobInfoFree(jobs[i]);
VIR_FREE(jobs);
- qemuMonitorTestFree(test);
return ret;
}
virDomainObj *vm,
virDomainChrSourceDef *src)
{
- qemuMonitorTest *test = NULL;
+ g_autoptr(qemuMonitorTest) test = NULL;
char *path = NULL;
char *tmpdir_template = NULL;
if (virNetSocketListen(test->server, 1) < 0)
goto error;
- return test;
+ return g_steal_pointer(&test);
error:
VIR_FREE(path);
VIR_FREE(tmpdir_template);
- qemuMonitorTestFree(test);
return NULL;
}
const char *greeting,
GHashTable *schema)
{
- qemuMonitorTest *test = NULL;
+ g_autoptr(qemuMonitorTest) test = NULL;
virDomainChrSourceDef src;
memset(&src, 0, sizeof(src));
virDomainChrSourceDefClear(&src);
- return test;
+ return g_steal_pointer(&test);
error:
virDomainChrSourceDefClear(&src);
- qemuMonitorTestFree(test);
return NULL;
}
virDomainXMLOption *xmlopt,
bool simple)
{
- qemuMonitorTest *test = NULL;
+ g_autoptr(qemuMonitorTest) test = NULL;
g_autofree char *json = NULL;
char *tmp;
char *singleReply;
if (test && qemuMonitorTestAddItem(test, NULL, singleReply) < 0)
goto error;
- return test;
+ return g_steal_pointer(&test);
error:
- qemuMonitorTestFree(test);
return NULL;
}
virDomainObj *vm,
GHashTable *qmpschema)
{
- qemuMonitorTest *ret = NULL;
+ g_autoptr(qemuMonitorTest) ret = NULL;
g_autofree char *jsonstr = NULL;
char *tmp;
size_t line = 0;
goto error;
}
- return ret;
+ return g_steal_pointer(&ret);
error:
- qemuMonitorTestFree(ret);
return NULL;
}
qemuMonitorTest *
qemuMonitorTestNewAgent(virDomainXMLOption *xmlopt)
{
- qemuMonitorTest *test = NULL;
+ g_autoptr(qemuMonitorTest) test = NULL;
virDomainChrSourceDef src;
memset(&src, 0, sizeof(src));
virDomainChrSourceDefClear(&src);
- return test;
+ return g_steal_pointer(&test);
error:
virDomainChrSourceDefClear(&src);
- qemuMonitorTestFree(test);
return NULL;
}