]> git.proxmox.com Git - mirror_qemu.git/commit
qmp: Clean up how we enforce capability negotiation
authorMarkus Armbruster <armbru@redhat.com>
Fri, 3 Mar 2017 12:32:27 +0000 (13:32 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Sun, 5 Mar 2017 08:14:11 +0000 (09:14 +0100)
commit635db18f68ded6abec11cd4cf64ebc15c1c6b190
treeef96491b6c966d48f8515552f0ddc8da58f8eb44
parent9b0c9a63492f9f8f4dc94b0ac5a28fc6a946389b
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>
monitor.c