提交 c04fbbd9 编写于 作者: J Jiri Denemark

qemu: Generalize PARSE macro in qemuMonitorJSONGetMigrationParams

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: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 3b2674ff
...@@ -2679,20 +2679,23 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon, ...@@ -2679,20 +2679,23 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon,
result = virJSONValueObjectGet(reply, "return"); result = virJSONValueObjectGet(reply, "return");
#define PARSE(VAR, FIELD) \ #define PARSE_SET(API, VAR, FIELD) \
do { \ do { \
if (virJSONValueObjectGetNumberInt(result, FIELD, \ if (API(result, FIELD, &params->VAR) == 0) \
&params->VAR) == 0) \
params->VAR ## _set = true; \ params->VAR ## _set = true; \
} while (0) } while (0)
PARSE(compressLevel, "compress-level"); #define PARSE_INT(VAR, FIELD) \
PARSE(compressThreads, "compress-threads"); PARSE_SET(virJSONValueObjectGetNumberInt, VAR, FIELD)
PARSE(decompressThreads, "decompress-threads");
PARSE(cpuThrottleInitial, "cpu-throttle-initial");
PARSE(cpuThrottleIncrement, "cpu-throttle-increment");
#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", if (virJSONValueObjectGetNumberUlong(result, "downtime-limit",
&params->downtimeLimit) == 0) &params->downtimeLimit) == 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册