From bd3da5169771ae8a6ea94bf5990700c3b53f21cd Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Mon, 20 Jun 2016 16:55:07 +0200 Subject: [PATCH] qemu: Rework qemuMonitorJSONSetMigrationParams Signed-off-by: Jiri Denemark --- src/qemu/qemu_monitor_json.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 99678c1c63..0434522ba6 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2589,20 +2589,19 @@ qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon, if (!(args = virJSONValueNewObject())) goto cleanup; - if (params->compressLevel_set && - virJSONValueObjectAppendNumberInt(args, "compress-level", - params->compressLevel) < 0) - goto cleanup; +#define APPEND(VAR, FIELD) \ + do { \ + if (params->VAR ## _set && \ + virJSONValueObjectAppendNumberInt(args, FIELD, \ + params->VAR) < 0) \ + goto cleanup; \ + } while (0) - if (params->compressThreads_set && - virJSONValueObjectAppendNumberInt(args, "compress-threads", - params->compressThreads) < 0) - goto cleanup; + APPEND(compressLevel, "compress-level"); + APPEND(compressThreads, "compress-threads"); + APPEND(decompressThreads, "decompress-threads"); - if (params->decompressThreads_set && - virJSONValueObjectAppendNumberInt(args, "decompress-threads", - params->decompressThreads) < 0) - goto cleanup; +#undef APPEND if (virJSONValueObjectAppend(cmd, "arguments", args) < 0) goto cleanup;