We should not require any parameters to be present. After all we have the *_set bools to express that some parameters were not set. Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx> --- src/qemu/qemu_monitor_json.c | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index eea32ab..99678c1 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2537,6 +2537,8 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon, virJSONValuePtr cmd = NULL; virJSONValuePtr reply = NULL; + memset(params, 0, sizeof(*params)); + if (!(cmd = qemuMonitorJSONMakeCommand("query-migrate-parameters", NULL))) return -1; @@ -2548,32 +2550,18 @@ qemuMonitorJSONGetMigrationParams(qemuMonitorPtr mon, result = virJSONValueObjectGet(reply, "return"); - if (virJSONValueObjectGetNumberInt(result, "compress-level", - ¶ms->compressLevel) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed/missing compress-level " - "in migrate parameters")); - goto cleanup; - } - params->compressLevel_set = true; +#define PARSE(VAR, FIELD) \ + do { \ + if (virJSONValueObjectGetNumberInt(result, FIELD, \ + ¶ms->VAR) == 0) \ + params->VAR ## _set = true; \ + } while (0) - if (virJSONValueObjectGetNumberInt(result, "compress-threads", - ¶ms->compressThreads) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed/missing compress-threads " - "in migrate parameters")); - goto cleanup; - } - params->compressThreads_set = true; + PARSE(compressLevel, "compress-level"); + PARSE(compressThreads, "compress-threads"); + PARSE(decompressThreads, "decompress-threads"); - if (virJSONValueObjectGetNumberInt(result, "decompress-threads", - ¶ms->decompressThreads) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed/missing decompress-threads " - "in migrate parameters")); - goto cleanup; - } - params->decompressThreads_set = true; +#undef PARSE ret = 0; cleanup: -- 2.9.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list