提交 27e56337 编写于 作者: J Jiri Denemark

qemu: Generalize APPEND macro in qemuMonitorJSONSetMigrationParams

The APPEND macro is now be usable for any type.
Signed-off-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 7ddcab89
...@@ -2739,21 +2739,24 @@ qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon, ...@@ -2739,21 +2739,24 @@ qemuMonitorJSONSetMigrationParams(qemuMonitorPtr mon,
if (!(args = virJSONValueNewObject())) if (!(args = virJSONValueNewObject()))
goto cleanup; goto cleanup;
#define APPEND(VAR, FIELD) \ #define APPEND(VALID, API, VAR, FIELD) \
do { \ do { \
if (params->VAR ## _set && \ if (VALID && API(args, FIELD, params->VAR) < 0) \
virJSONValueObjectAppendNumberInt(args, FIELD, \
params->VAR) < 0) \
goto cleanup; \ goto cleanup; \
} while (0) } while (0)
APPEND(compressLevel, "compress-level"); #define APPEND_INT(VAR, FIELD) \
APPEND(compressThreads, "compress-threads"); APPEND(params->VAR ## _set, \
APPEND(decompressThreads, "decompress-threads"); virJSONValueObjectAppendNumberInt, VAR, FIELD)
APPEND(cpuThrottleInitial, "cpu-throttle-initial");
APPEND(cpuThrottleIncrement, "cpu-throttle-increment"); 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
#undef APPEND_INT
if (params->migrateTLSAlias && if (params->migrateTLSAlias &&
virJSONValueObjectAppendString(args, "tls-creds", virJSONValueObjectAppendString(args, "tls-creds",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册