mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 07:05:28 +00:00
qemu: Use macro for parsing string migration parameters
Signed-off-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
c04fbbd9c9
commit
4fabc0caa0
@ -2659,7 +2659,6 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
|
|||||||
virJSONValuePtr result;
|
virJSONValuePtr result;
|
||||||
virJSONValuePtr cmd = NULL;
|
virJSONValuePtr cmd = NULL;
|
||||||
virJSONValuePtr reply = NULL;
|
virJSONValuePtr reply = NULL;
|
||||||
const char *tlsStr = NULL;
|
|
||||||
|
|
||||||
memset(params, 0, sizeof(*params));
|
memset(params, 0, sizeof(*params));
|
||||||
|
|
||||||
@ -2688,29 +2687,31 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
|
|||||||
#define PARSE_INT(VAR, FIELD) \
|
#define PARSE_INT(VAR, FIELD) \
|
||||||
PARSE_SET(virJSONValueObjectGetNumberInt, VAR, FIELD)
|
PARSE_SET(virJSONValueObjectGetNumberInt, VAR, FIELD)
|
||||||
|
|
||||||
|
#define PARSE_STR(VAR, FIELD) \
|
||||||
|
do { \
|
||||||
|
const char *str; \
|
||||||
|
if ((str = virJSONValueObjectGetString(result, FIELD))) { \
|
||||||
|
if (VIR_STRDUP(params->VAR, str) < 0) \
|
||||||
|
goto cleanup; \
|
||||||
|
} \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
PARSE_INT(compressLevel, "compress-level");
|
PARSE_INT(compressLevel, "compress-level");
|
||||||
PARSE_INT(compressThreads, "compress-threads");
|
PARSE_INT(compressThreads, "compress-threads");
|
||||||
PARSE_INT(decompressThreads, "decompress-threads");
|
PARSE_INT(decompressThreads, "decompress-threads");
|
||||||
PARSE_INT(cpuThrottleInitial, "cpu-throttle-initial");
|
PARSE_INT(cpuThrottleInitial, "cpu-throttle-initial");
|
||||||
PARSE_INT(cpuThrottleIncrement, "cpu-throttle-increment");
|
PARSE_INT(cpuThrottleIncrement, "cpu-throttle-increment");
|
||||||
|
PARSE_STR(migrateTLSAlias, "tls-creds");
|
||||||
|
PARSE_STR(migrateTLSHostname, "tls-hostname");
|
||||||
|
|
||||||
#undef PARSE_SET
|
#undef PARSE_SET
|
||||||
#undef PARSE_INT
|
#undef PARSE_INT
|
||||||
|
#undef PARSE_STR
|
||||||
|
|
||||||
if (virJSONValueObjectGetNumberUlong(result, "downtime-limit",
|
if (virJSONValueObjectGetNumberUlong(result, "downtime-limit",
|
||||||
¶ms->downtimeLimit) == 0)
|
¶ms->downtimeLimit) == 0)
|
||||||
params->downtimeLimit_set = true;
|
params->downtimeLimit_set = true;
|
||||||
|
|
||||||
if ((tlsStr = virJSONValueObjectGetString(result, "tls-creds"))) {
|
|
||||||
if (VIR_STRDUP(params->migrateTLSAlias, tlsStr) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((tlsStr = virJSONValueObjectGetString(result, "tls-hostname"))) {
|
|
||||||
if (VIR_STRDUP(params->migrateTLSHostname, tlsStr) < 0)
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virJSONValueFree(cmd);
|
virJSONValueFree(cmd);
|
||||||
|
Loading…
Reference in New Issue
Block a user