Now that we use only the separate function for creating data for the 'transaction' command we can remove all the boilerplate which was necessary before. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_monitor_json.c | 42 ++++++++++-------------------------------- 1 file changed, 10 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index cf1636d858..87ec496d0d 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -514,48 +514,30 @@ qemuMonitorJSONTransactionAdd(virJSONValuePtr actions, * qemuMonitorJSONMakeCommandInternal: * @cmdname: QMP command name * @arguments: a JSON object containing command arguments or NULL - * @transaction: format the command as arguments for the 'transaction' command * - * Create a JSON object used on the QMP monitor to call a command. If - * @transaction is true, the returned object is formatted to be used as a member - * of the 'transaction' command. + * Create a JSON object used on the QMP monitor to call a command. * * Note that @arguments is always consumed and should not be referenced after * the call to this function. */ static virJSONValuePtr qemuMonitorJSONMakeCommandInternal(const char *cmdname, - virJSONValuePtr arguments, - bool transaction) + virJSONValuePtr arguments) { - virJSONValuePtr cmd = NULL; virJSONValuePtr ret = NULL; - if (!transaction) { - if (virJSONValueObjectCreate(&cmd, - "s:execute", cmdname, - "A:arguments", &arguments, NULL) < 0) - goto cleanup; - } else { - if (virJSONValueObjectCreate(&cmd, - "s:type", cmdname, - "A:data", &arguments, NULL) < 0) - goto cleanup; - } - - VIR_STEAL_PTR(ret, cmd); + ignore_value(virJSONValueObjectCreate(&ret, + "s:execute", cmdname, + "A:arguments", &arguments, NULL)); - cleanup: virJSONValueFree(arguments); - virJSONValueFree(cmd); return ret; } static virJSONValuePtr ATTRIBUTE_SENTINEL -qemuMonitorJSONMakeCommandRaw(bool transaction, - const char *cmdname, - ...) +qemuMonitorJSONMakeCommand(const char *cmdname, + ...) { virJSONValuePtr obj = NULL; virJSONValuePtr jargs = NULL; @@ -566,7 +548,7 @@ qemuMonitorJSONMakeCommandRaw(bool transaction, if (virJSONValueObjectCreateVArgs(&jargs, args) < 0) goto cleanup; - obj = qemuMonitorJSONMakeCommandInternal(cmdname, jargs, transaction); + obj = qemuMonitorJSONMakeCommandInternal(cmdname, jargs); cleanup: va_end(args); @@ -574,9 +556,6 @@ qemuMonitorJSONMakeCommandRaw(bool transaction, return obj; } -#define qemuMonitorJSONMakeCommand(cmdname, ...) \ - qemuMonitorJSONMakeCommandRaw(false, cmdname, __VA_ARGS__) - static virJSONValuePtr qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword) @@ -4057,7 +4036,7 @@ qemuMonitorJSONAddObject(qemuMonitorPtr mon, virJSONValuePtr cmd; virJSONValuePtr reply = NULL; - if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", props, false))) + if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", props))) goto cleanup; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) @@ -7964,8 +7943,7 @@ qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, virJSONValuePtr reply = NULL; int ret = -1; - if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", - props, false))) + if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", props))) return -1; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) -- 2.16.2 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list