提交 2f259d59 编写于 作者: P Peter Krempa

qemu: monitor: Remove old code for dual handling of 'transaction' data

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: NPeter Krempa <pkrempa@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 42f3bbb1
...@@ -515,48 +515,30 @@ qemuMonitorJSONTransactionAdd(virJSONValuePtr actions, ...@@ -515,48 +515,30 @@ qemuMonitorJSONTransactionAdd(virJSONValuePtr actions,
* qemuMonitorJSONMakeCommandInternal: * qemuMonitorJSONMakeCommandInternal:
* @cmdname: QMP command name * @cmdname: QMP command name
* @arguments: a JSON object containing command arguments or NULL * @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 * Create a JSON object used on the QMP monitor to call a command.
* @transaction is true, the returned object is formatted to be used as a member
* of the 'transaction' command.
* *
* Note that @arguments is always consumed and should not be referenced after * Note that @arguments is always consumed and should not be referenced after
* the call to this function. * the call to this function.
*/ */
static virJSONValuePtr static virJSONValuePtr
qemuMonitorJSONMakeCommandInternal(const char *cmdname, qemuMonitorJSONMakeCommandInternal(const char *cmdname,
virJSONValuePtr arguments, virJSONValuePtr arguments)
bool transaction)
{ {
virJSONValuePtr cmd = NULL;
virJSONValuePtr ret = NULL; virJSONValuePtr ret = NULL;
if (!transaction) { ignore_value(virJSONValueObjectCreate(&ret,
if (virJSONValueObjectCreate(&cmd, "s:execute", cmdname,
"s:execute", cmdname, "A:arguments", &arguments, NULL));
"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);
cleanup:
virJSONValueFree(arguments); virJSONValueFree(arguments);
virJSONValueFree(cmd);
return ret; return ret;
} }
static virJSONValuePtr ATTRIBUTE_SENTINEL static virJSONValuePtr ATTRIBUTE_SENTINEL
qemuMonitorJSONMakeCommandRaw(bool transaction, qemuMonitorJSONMakeCommand(const char *cmdname,
const char *cmdname, ...)
...)
{ {
virJSONValuePtr obj = NULL; virJSONValuePtr obj = NULL;
virJSONValuePtr jargs = NULL; virJSONValuePtr jargs = NULL;
...@@ -567,7 +549,7 @@ qemuMonitorJSONMakeCommandRaw(bool transaction, ...@@ -567,7 +549,7 @@ qemuMonitorJSONMakeCommandRaw(bool transaction,
if (virJSONValueObjectCreateVArgs(&jargs, args) < 0) if (virJSONValueObjectCreateVArgs(&jargs, args) < 0)
goto cleanup; goto cleanup;
obj = qemuMonitorJSONMakeCommandInternal(cmdname, jargs, transaction); obj = qemuMonitorJSONMakeCommandInternal(cmdname, jargs);
cleanup: cleanup:
va_end(args); va_end(args);
...@@ -575,9 +557,6 @@ qemuMonitorJSONMakeCommandRaw(bool transaction, ...@@ -575,9 +557,6 @@ qemuMonitorJSONMakeCommandRaw(bool transaction,
return obj; return obj;
} }
#define qemuMonitorJSONMakeCommand(cmdname, ...) \
qemuMonitorJSONMakeCommandRaw(false, cmdname, __VA_ARGS__)
static virJSONValuePtr static virJSONValuePtr
qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword) qemuMonitorJSONKeywordStringToJSON(const char *str, const char *firstkeyword)
...@@ -4068,7 +4047,7 @@ qemuMonitorJSONAddObject(qemuMonitorPtr mon, ...@@ -4068,7 +4047,7 @@ qemuMonitorJSONAddObject(qemuMonitorPtr mon,
virJSONValuePtr cmd; virJSONValuePtr cmd;
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", props, false))) if (!(cmd = qemuMonitorJSONMakeCommandInternal("object-add", props)))
goto cleanup; goto cleanup;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
...@@ -7975,8 +7954,7 @@ qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon, ...@@ -7975,8 +7954,7 @@ qemuMonitorJSONBlockdevAdd(qemuMonitorPtr mon,
virJSONValuePtr reply = NULL; virJSONValuePtr reply = NULL;
int ret = -1; int ret = -1;
if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", if (!(cmd = qemuMonitorJSONMakeCommandInternal("blockdev-add", props)))
props, false)))
return -1; return -1;
if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册