]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Generalize PARSE macro in qemuMonitorJSONGetMigrationParams
authorJiri Denemark <jdenemar@redhat.com>
Mon, 23 Oct 2017 15:11:10 +0000 (17:11 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Thu, 2 Nov 2017 21:14:18 +0000 (22:14 +0100)
The macro (now called PARSE_SET) is now usable for any type which needs
a *_set bool for indicating a valid value.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
src/qemu/qemu_monitor_json.c

index 05cc634d202656a227298256ad2c105ac9be2d9a..16554d5b26c2e291a944b0846f43a72ea3eab55f 100644 (file)
@@ -2679,20 +2679,23 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
 
     result = virJSONValueObjectGet(reply, "return");
 
-#define PARSE(VAR, FIELD)                                                   \
+#define PARSE_SET(API, VAR, FIELD)                                          \
     do {                                                                    \
-        if (virJSONValueObjectGetNumberInt(result, FIELD,                   \
-                                           &params->VAR) == 0)              \
+        if (API(result, FIELD, &params->VAR) == 0)                          \
             params->VAR ## _set = true;                                     \
     } while (0)
 
-    PARSE(compressLevel, "compress-level");
-    PARSE(compressThreads, "compress-threads");
-    PARSE(decompressThreads, "decompress-threads");
-    PARSE(cpuThrottleInitial, "cpu-throttle-initial");
-    PARSE(cpuThrottleIncrement, "cpu-throttle-increment");
+#define PARSE_INT(VAR, FIELD)                                               \
+    PARSE_SET(virJSONValueObjectGetNumberInt, VAR, FIELD)
 
-#undef PARSE
+    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");
+
+#undef PARSE_SET
+#undef PARSE_INT
 
     if (virJSONValueObjectGetNumberUlong(result, "downtime-limit",
                                          &params->downtimeLimit) == 0)