qapi: introduce new cmd option "allow-oob"

Here "oob" stands for "Out-Of-Band".  When "allow-oob" is set, it means
the command allows out-of-band execution.

The "oob" idea is proposed by Markus Armbruster in following thread:

  https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg02057.html

This new "allow-oob" boolean will be exposed by "query-qmp-schema" as
well for command entries, so that QMP clients can know which commands
can be used in out-of-band calls. For example the command "migrate"
originally looks like:

  {"name": "migrate", "ret-type": "17", "meta-type": "command",
   "arg-type": "86"}

And it'll be changed into:

  {"name": "migrate", "ret-type": "17", "allow-oob": false,
   "meta-type": "command", "arg-type": "86"}

This patch only provides the QMP interface level changes.  It does not
contain the real out-of-band execution implementation yet.

Suggested-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Peter Xu <peterx@redhat.com>
Message-Id: <20180309090006.10018-18-peterx@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
[eblake: rebase on introspection done by qlit]
Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Peter Xu 2018-03-09 17:00:00 +08:00 committed by Eric Blake
parent bf1e730174
commit 876c67512e
7 changed files with 38 additions and 17 deletions

View file

@ -193,10 +193,18 @@ out:
return ret
def gen_register_command(name, success_response):
options = 'QCO_NO_OPTIONS'
def gen_register_command(name, success_response, allow_oob):
options = []
if not success_response:
options = 'QCO_NO_SUCCESS_RESP'
options += ['QCO_NO_SUCCESS_RESP']
if allow_oob:
options += ['QCO_ALLOW_OOB']
if not options:
options = ['QCO_NO_OPTIONS']
options = " | ".join(options)
ret = mcgen('''
qmp_register_command(cmds, "%(name)s",
@ -268,7 +276,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
genc.add(gen_registry(self._regy, self._prefix))
def visit_command(self, name, info, arg_type, ret_type,
gen, success_response, boxed):
gen, success_response, boxed, allow_oob):
if not gen:
return
self._genh.add(gen_command_decl(name, arg_type, boxed, ret_type))
@ -277,7 +285,7 @@ void %(c_prefix)sqmp_init_marshal(QmpCommandList *cmds);
self._genc.add(gen_marshal_output(ret_type))
self._genh.add(gen_marshal_decl(name))
self._genc.add(gen_marshal(name, arg_type, boxed, ret_type))
self._regy += gen_register_command(name, success_response)
self._regy += gen_register_command(name, success_response, allow_oob)
def gen_commands(schema, output_dir, prefix):