[libvirt] [PATCH 05/11] qemu: Rework qemuMonitorJSONSetMigrationParams

Jiri Denemark jdenemar at redhat.com
Tue Jun 21 11:47:11 UTC 2016


Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 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 99678c1..0434522 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;
-- 
2.9.0




More information about the libvir-list mailing list