Skip to content

Commit

Permalink
qapi: Do not expose "allow-preconfig" in query-qmp-schema
Browse files Browse the repository at this point in the history
According to commit 047f703, option --preconfig

    [...] allows pausing QEMU in the new RUN_STATE_PRECONFIG state,
    allowing the configuration of QEMU from QMP before the machine
    jumps into board initialization code of machine_run_board_init()

    The intent is to allow management to query machine state and
    additionally configure it using previous query results within one
    QEMU instance (i.e. eliminate the need to start QEMU twice, 1st to
    query board specific parameters and 2nd for actual VM start using
    query results for additional parameters).

The implementation is a bit of a hack: it splices in an additional
main loop before machine creation, in special runstate preconfig.  New
command exit-preconfig exits that main loop.  QEMU continues
initializing, creates the machine, and runs the good old main loop.
The replacement of the main loop is transparent to monitors.

Sadly, some commands expect initialization to be complete.  Running
them in --preconfig's main loop violates their preconditions.  Since
we don't really know which commands are safe, we use a whitelist.
This drags the concept of run state into the QMP core.

The whitelist is done as a command flag in the QAPI schema (commit
d6fe3d0).  Drags the concept of run state further into the QAPI
language.

The command flag is exposed in query-qmp-schema (also commit
d6fe3d0).  This makes it ABI.

I consider the whole thing an offensively ugly hack, but sometimes an
ugly hack is the best we can do to solve a problem people have.

The need described by the commit message quote above is genuine.  The
proper solution would be a main loop that permits complete
configuration via QMP.  This is out of reach, thus the hack.

However, even though the need is genuine, it isn't urgent: libvirt is
not going to use this anytime soon.  Baking a hack into ABI before it
has any users is a bad idea.

This commit reverts the parts of commit d6fe3d0 that affect ABI
via query-qmp-schema.  The commit did the following:

(1) Add command flag 'allow-preconfig' to the QAPI schema language

(2) Pass it to code generators

(3) Have the commands.py code generator pass it to the command
    registry (so commit 047f703 can use it as whitelist)

(4) Add 'allow-preconfig' to SchemaInfoCommand (neglecting to update
    qapi-code-gen.txt section "Client JSON Protocol introspection")

(5) Set 'allow-preconfig': true for commands qmp_capabilities,
    query-commands, query-command-line-options, query-status

Revert exactly (4), plus a bit of documentation added to
qemu-tech.info in commit 047f703.

Shrinks query-qmp-schema's output from 126.5KiB to 121.8KiB for me.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180705091402.26244-2-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Acked-by: Eduardo Habkost <ehabkost@redhat.com>
Acked-by: Igor Mammedov <imammedo@redhat.com>
[Straightforward conflict with commit d626b6c resolved]
  • Loading branch information
Markus Armbruster committed Jul 16, 2018
1 parent 633e824 commit 1f214ee
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions qapi/introspect.json
Expand Up @@ -262,16 +262,13 @@
# @allow-oob: whether the command allows out-of-band execution.
# (Since: 2.12)
#
# @allow-preconfig: command can be executed in preconfig runstate,
# default: false (Since 3.0)
#
# TODO: @success-response (currently irrelevant, because it's QGA, not QMP)
#
# Since: 2.5
##
{ 'struct': 'SchemaInfoCommand',
'data': { 'arg-type': 'str', 'ret-type': 'str',
'allow-oob': 'bool', 'allow-preconfig': 'bool' } }
'allow-oob': 'bool' } }

##
# @SchemaInfoEvent:
Expand Down
3 changes: 0 additions & 3 deletions qemu-tech.texi
Expand Up @@ -350,9 +350,6 @@ depend on an initialized machine, including but not limited to:
@item query-status
@item exit-preconfig
@end table
The full list of commands is in QMP schema which could be queried with
query-qmp-schema, where commands supported at preconfig state have option
'allow-preconfig' set to true.

@node Bibliography
@section Bibliography
Expand Down
4 changes: 2 additions & 2 deletions scripts/qapi/introspect.py
Expand Up @@ -187,8 +187,8 @@ def visit_command(self, name, info, ifcond, arg_type, ret_type, gen,
self._gen_qlit(name, 'command',
{'arg-type': self._use_type(arg_type),
'ret-type': self._use_type(ret_type),
'allow-oob': allow_oob,
'allow-preconfig': allow_preconfig}, ifcond)
'allow-oob': allow_oob},
ifcond)

def visit_event(self, name, info, ifcond, arg_type, boxed):
arg_type = arg_type or self._schema.the_empty_object_type
Expand Down

0 comments on commit 1f214ee

Please sign in to comment.