summary refs log tree commit diff stats
path: root/qapi/qobject-input-visitor.c
diff options
context:
space:
mode:
authorMarkus Armbruster <armbru@redhat.com>2017-03-03 13:32:27 +0100
committerMarkus Armbruster <armbru@redhat.com>2017-03-05 09:14:11 +0100
commit635db18f68ded6abec11cd4cf64ebc15c1c6b190 (patch)
treeef96491b6c966d48f8515552f0ddc8da58f8eb44 /qapi/qobject-input-visitor.c
parent9b0c9a63492f9f8f4dc94b0ac5a28fc6a946389b (diff)
downloadfocaccia-qemu-635db18f68ded6abec11cd4cf64ebc15c1c6b190.tar.gz
focaccia-qemu-635db18f68ded6abec11cd4cf64ebc15c1c6b190.zip
qmp: Clean up how we enforce capability negotiation
To enforce capability negotiation before normal operation,
handle_qmp_command() inspects every command before it's handed off to
qmp_dispatch().  This is a bit of a layering violation, and results in
duplicated code.

Before capability negotiation (!cur_mon->in_command_mode), we fail
commands other than "qmp_capabilities".  This is what enforces
capability negotiation.

Afterwards, we fail command "qmp_capabilities".

Clean this up as follows.

The obvious place to fail a command is the command itself, so move the
"afterwards" check to qmp_qmp_capabilities().

We do the "before" check in every other command, but that would be
bothersome.  Instead, start with an alternate list of commands that
contains only "qmp_capabilities".  Switch to the full list in
qmp_qmp_capabilities().

Additionally, replace the generic human-readable error message for
CommandNotFound by one that reminds the user to run qmp_capabilities.
Without that, we'd regress commit 2d5a834.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <1488544368-30622-8-git-send-email-armbru@redhat.com>
[Mirco-optimization squashed in, commit message typo fixed]
Reviewed-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'qapi/qobject-input-visitor.c')
0 files changed, 0 insertions, 0 deletions