On 03/09/2018 03:00 AM, Peter Xu wrote:
Having "allow-oob" to true for a command does not mean that this command
s/to/:/
will always be run in out-of-band mode. The out-of-band quick path will only be executed if we specify the extra "run-oob" flag when sending the QMP request: { "execute": "command-that-allows-oob", "arguments": { ... }, "control": { "run-oob": true } } The "control" key is introduced to store this extra flag. "control" field is used to store arguments that are shared by all the commands, rather than command specific arguments. Let "run-oob" be the first. Note that in the patch I exported qmp_dispatch_check_obj() to be used to check the request earlier, and at the same time allowed "id" field to be there since actually we always allow that. Reviewed-by: Stefan Hajnoczi <stefa...@redhat.com> Signed-off-by: Peter Xu <pet...@redhat.com> --- include/qapi/qmp/dispatch.h | 2 ++ monitor.c | 84 ++++++++++++++++++++++++++++++++++++++++----- qapi/qmp-dispatch.c | 33 +++++++++++++++++- trace-events | 2 ++ 4 files changed, 111 insertions(+), 10 deletions(-)
+ + if (qmp_is_oob(req)) { + if (!qmp_oob_enabled(mon)) { + error_setg(errp, "Please enable Out-Of-Band first " + "for the session during capabilities negociation");
s/negociation/negotiation/
+++ b/qapi/qmp-dispatch.c @@ -17,8 +17,9 @@
+/* + * Detect whether a request should be run out-of-band, by quickly + * peeking at whether we have: { "control": { "run-oob": True } }. By
s/True/true/
+ * default commands are run in-band. + */ +bool qmp_is_oob(QDict *dict) +{ + QBool *bool_obj; + + dict = qdict_get_qdict(dict, "control"); + if (!dict) { + return false; + } + + bool_obj = qobject_to_qbool(qdict_get(dict, "run-oob"));
Another qobject_to() rebase victim. Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org