[PATCH 04/12] qemu: Generalize APPEND macro in qemuMonitorJSONSetMigrationParams

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

 



The APPEND macro is now be usable for any type.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/qemu/qemu_monitor_json.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 76fc84ed0..218bbd8bd 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2739,21 +2739,24 @@ qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
     if (!(args = virJSONValueNewObject()))
         goto cleanup;
 
-#define APPEND(VAR, FIELD)                                                  \
+#define APPEND(VALID, API, VAR, FIELD)                                      \
     do {                                                                    \
-        if (params->VAR ## _set &&                                          \
-            virJSONValueObjectAppendNumberInt(args, FIELD,                  \
-                                              params->VAR) < 0)             \
+        if (VALID && API(args, FIELD, params->VAR) < 0)                     \
             goto cleanup;                                                   \
     } while (0)
 
-    APPEND(compressLevel, "compress-level");
-    APPEND(compressThreads, "compress-threads");
-    APPEND(decompressThreads, "decompress-threads");
-    APPEND(cpuThrottleInitial, "cpu-throttle-initial");
-    APPEND(cpuThrottleIncrement, "cpu-throttle-increment");
+#define APPEND_INT(VAR, FIELD)                                              \
+    APPEND(params->VAR ## _set,                                             \
+           virJSONValueObjectAppendNumberInt, VAR, FIELD)
+
+    APPEND_INT(compressLevel, "compress-level");
+    APPEND_INT(compressThreads, "compress-threads");
+    APPEND_INT(decompressThreads, "decompress-threads");
+    APPEND_INT(cpuThrottleInitial, "cpu-throttle-initial");
+    APPEND_INT(cpuThrottleIncrement, "cpu-throttle-increment");
 
 #undef APPEND
+#undef APPEND_INT
 
     if (params->migrateTLSAlias &&
         virJSONValueObjectAppendString(args, "tls-creds",
-- 
2.14.3

--
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]
  Powered by Linux