From: Jiri Denemark Date: Mon, 23 Oct 2017 15:15:32 +0000 (+0200) Subject: qemu: Use macro for parsing string migration parameters X-Git-Tag: v3.10.0-rc1~264 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4fabc0caa0e058d5865322f946a93da177928a5b;p=thirdparty%2Flibvirt.git qemu: Use macro for parsing string migration parameters Signed-off-by: Jiri Denemark Reviewed-by: John Ferlan --- diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 16554d5b26..cb0bb0d0df 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2659,7 +2659,6 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon, virJSONValuePtr result; virJSONValuePtr cmd = NULL; virJSONValuePtr reply = NULL; - const char *tlsStr = NULL; memset(params, 0, sizeof(*params)); @@ -2688,29 +2687,31 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon, #define PARSE_INT(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(compressThreads, "compress-threads"); PARSE_INT(decompressThreads, "decompress-threads"); PARSE_INT(cpuThrottleInitial, "cpu-throttle-initial"); PARSE_INT(cpuThrottleIncrement, "cpu-throttle-increment"); + PARSE_STR(migrateTLSAlias, "tls-creds"); + PARSE_STR(migrateTLSHostname, "tls-hostname"); #undef PARSE_SET #undef PARSE_INT +#undef PARSE_STR if (virJSONValueObjectGetNumberUlong(result, "downtime-limit", ¶ms->downtimeLimit) == 0) 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; cleanup: virJSONValueFree(cmd);