mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities: refactor cleanup
Use automatic memory freeing to remove the 'cleanup:' label and 'ret' variable. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
681006a14b
commit
812b0e9122
@ -2050,11 +2050,10 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
|
|||||||
{
|
{
|
||||||
const testGenericData *data = opaque;
|
const testGenericData *data = opaque;
|
||||||
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
virDomainXMLOptionPtr xmlopt = data->xmlopt;
|
||||||
int ret = -1;
|
|
||||||
const char *cap;
|
const char *cap;
|
||||||
char **caps = NULL;
|
g_auto(GStrv) caps = NULL;
|
||||||
virBitmapPtr bitmap = NULL;
|
g_autoptr(virBitmap) bitmap = NULL;
|
||||||
virJSONValuePtr json = NULL;
|
g_autoptr(virJSONValue) json = NULL;
|
||||||
const char *reply =
|
const char *reply =
|
||||||
"{"
|
"{"
|
||||||
" \"return\": ["
|
" \"return\": ["
|
||||||
@ -2073,32 +2072,26 @@ testQemuMonitorJSONqemuMonitorJSONGetMigrationCapabilities(const void *opaque)
|
|||||||
if (qemuMonitorTestAddItem(test, "query-migrate-capabilities", reply) < 0 ||
|
if (qemuMonitorTestAddItem(test, "query-migrate-capabilities", reply) < 0 ||
|
||||||
qemuMonitorTestAddItem(test, "migrate-set-capabilities",
|
qemuMonitorTestAddItem(test, "migrate-set-capabilities",
|
||||||
"{\"return\":{}}") < 0)
|
"{\"return\":{}}") < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
if (qemuMonitorGetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
|
if (qemuMonitorGetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
|
||||||
&caps) < 0)
|
&caps) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
cap = qemuMigrationCapabilityTypeToString(QEMU_MIGRATION_CAP_XBZRLE);
|
cap = qemuMigrationCapabilityTypeToString(QEMU_MIGRATION_CAP_XBZRLE);
|
||||||
if (!virStringListHasString((const char **) caps, cap)) {
|
if (!virStringListHasString((const char **) caps, cap)) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
"Expected capability %s is missing", cap);
|
"Expected capability %s is missing", cap);
|
||||||
goto cleanup;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
bitmap = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
|
bitmap = virBitmapNew(QEMU_MIGRATION_CAP_LAST);
|
||||||
ignore_value(virBitmapSetBit(bitmap, QEMU_MIGRATION_CAP_XBZRLE));
|
ignore_value(virBitmapSetBit(bitmap, QEMU_MIGRATION_CAP_XBZRLE));
|
||||||
if (!(json = qemuMigrationCapsToJSON(bitmap, bitmap)))
|
if (!(json = qemuMigrationCapsToJSON(bitmap, bitmap)))
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
|
||||||
ret = qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
|
return qemuMonitorJSONSetMigrationCapabilities(qemuMonitorTestGetMonitor(test),
|
||||||
&json);
|
&json);
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(json);
|
|
||||||
g_strfreev(caps);
|
|
||||||
virBitmapFree(bitmap);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
|
Loading…
Reference in New Issue
Block a user