aboutsummaryrefslogtreecommitdiff
path: root/qapi
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2018-07-03 10:53:43 +0200
committerMarkus Armbruster <armbru@redhat.com>2018-07-03 23:18:56 +0200
commit69240fe62d1ae02257bc0694a11c478b10378948 (patch)
tree27c70b833e5435b942932de13221b49983e8e1b4 /qapi
parente8f4a22168f573633f31fad3d6bfcbe5f0259b28 (diff)
downloadqemu-69240fe62d1ae02257bc0694a11c478b10378948.zip
qemu-69240fe62d1ae02257bc0694a11c478b10378948.tar.gz
qemu-69240fe62d1ae02257bc0694a11c478b10378948.tar.bz2
qmp: Don't let malformed in-band commands jump the queue
handle_qmp_command() reports certain errors right away. This is wrong when OOB is enabled, because the errors can "jump the queue" then, as the previous commit demonstrates. To fix, we need to delay errors until dispatch. Do that for semantic errors, mostly by reverting ill-advised parts of commit cf869d53172 "qmp: support out-of-band (oob) execution". Bonus: doesn't run qmp_dispatch_check_obj() twice, once in handle_qmp_command(), and again in do_qmp_dispatch(). That's also due to commit cf869d53172. The next commit will fix queue jumping for syntax errors. Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20180703085358.13941-18-armbru@redhat.com>
Diffstat (limited to 'qapi')
-rw-r--r--qapi/qmp-dispatch.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c
index 12be120..6d78f3e 100644
--- a/qapi/qmp-dispatch.c
+++ b/qapi/qmp-dispatch.c
@@ -20,8 +20,8 @@
#include "qapi/qmp/qbool.h"
#include "sysemu/sysemu.h"
-QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oob,
- Error **errp)
+static QDict *qmp_dispatch_check_obj(const QObject *request, bool allow_oob,
+ Error **errp)
{
const char *exec_key = NULL;
const QDictEntry *ent;
@@ -78,6 +78,7 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
bool allow_oob, Error **errp)
{
Error *local_err = NULL;
+ bool oob;
const char *command;
QDict *args, *dict;
QmpCommand *cmd;
@@ -89,9 +90,11 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
}
command = qdict_get_try_str(dict, "execute");
+ oob = false;
if (!command) {
assert(allow_oob);
command = qdict_get_str(dict, "exec-oob");
+ oob = true;
}
cmd = qmp_find_command(cmds, command);
if (cmd == NULL) {
@@ -104,6 +107,11 @@ static QObject *do_qmp_dispatch(QmpCommandList *cmds, QObject *request,
command);
return NULL;
}
+ if (oob && !(cmd->options & QCO_ALLOW_OOB)) {
+ error_setg(errp, "The command %s does not support OOB",
+ command);
+ return false;
+ }
if (runstate_check(RUN_STATE_PRECONFIG) &&
!(cmd->options & QCO_ALLOW_PRECONFIG)) {