[PATCH 05/11] qemu: Rework qemuMonitorJSONSetMigrationParams

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]