Commit d6fe3d02 authored by Igor Mammedov's avatar Igor Mammedov Committed by Eduardo Habkost
Browse files

qapi: introduce new cmd option "allow-preconfig"



New option will be used to allow commands, which are prepared/need
to run, during preconfig state. Other commands that should be able
to run in preconfig state, should be amended to not expect machine
in initialized state or deal with it.

For compatibility reasons, commands that don't use new flag
'allow-preconfig' explicitly are not permitted to run in
preconfig state but allowed in all other states like they used
to be.

Within this patch allow following commands in preconfig state:
   qmp_capabilities
   query-qmp-schema
   query-commands
   query-command-line-options
   query-status
   exit-preconfig
to allow qmp connection, basic introspection and moving to the next
state.

PS:
set-numa-node and query-hotpluggable-cpus will be enabled later in
a separate patches.

Signed-off-by: default avatarIgor Mammedov <imammedo@redhat.com>
Message-Id: <1526057503-39287-1-git-send-email-imammedo@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
[ehabkost: Changed "since 2.13" to "since 3.0"]
Signed-off-by: default avatarEduardo Habkost <ehabkost@redhat.com>
parent 71dc578e
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -559,7 +559,7 @@ following example objects:
Usage: { 'command': STRING, '*data': COMPLEX-TYPE-NAME-OR-DICT,
         '*returns': TYPE-NAME, '*boxed': true,
         '*gen': false, '*success-response': false,
         '*allow-oob': true }
         '*allow-oob': true, '*allow-preconfig': true }

Commands are defined by using a dictionary containing several members,
where three members are most common.  The 'command' member is a
@@ -683,6 +683,15 @@ OOB command handlers must satisfy the following conditions:

If in doubt, do not implement OOB execution support.

A command may use the optional 'allow-preconfig' key to permit its execution
at early runtime configuration stage (preconfig runstate).
If not specified then a command defaults to 'allow-preconfig': false.

An example of declaring a command that is enabled during preconfig:
 { 'command': 'qmp_capabilities',
   'data': { '*enable': [ 'QMPCapability' ] },
   'allow-preconfig': true }

=== Events ===

Usage: { 'event': STRING, '*data': COMPLEX-TYPE-NAME-OR-DICT,
+1 −0
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ typedef enum QmpCommandOptions
    QCO_NO_OPTIONS            =  0x0,
    QCO_NO_SUCCESS_RESP       =  (1U << 0),
    QCO_ALLOW_OOB             =  (1U << 1),
    QCO_ALLOW_PRECONFIG       =  (1U << 2),
} QmpCommandOptions;

typedef struct QmpCommand
+2 −3
Original line number Diff line number Diff line
@@ -1179,8 +1179,7 @@ static void monitor_init_qmp_commands(void)
    qmp_init_marshal(&qmp_commands);

    qmp_register_command(&qmp_commands, "query-qmp-schema",
                         qmp_query_qmp_schema,
                         QCO_NO_OPTIONS);
                         qmp_query_qmp_schema, QCO_ALLOW_PRECONFIG);
    qmp_register_command(&qmp_commands, "device_add", qmp_device_add,
                         QCO_NO_OPTIONS);
    qmp_register_command(&qmp_commands, "netdev_add", qmp_netdev_add,
@@ -1190,7 +1189,7 @@ static void monitor_init_qmp_commands(void)

    QTAILQ_INIT(&qmp_cap_negotiation_commands);
    qmp_register_command(&qmp_cap_negotiation_commands, "qmp_capabilities",
                         qmp_marshal_qmp_capabilities, QCO_NO_OPTIONS);
                         qmp_marshal_qmp_capabilities, QCO_ALLOW_PRECONFIG);
}

static bool qmp_cap_enabled(Monitor *mon, QMPCapability cap)
+4 −1
Original line number Diff line number Diff line
@@ -262,13 +262,16 @@
# @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-oob': 'bool', 'allow-preconfig': 'bool' } }

##
# @SchemaInfoEvent:
+6 −3
Original line number Diff line number Diff line
@@ -37,7 +37,8 @@
#
##
{ 'command': 'qmp_capabilities',
  'data': { '*enable': [ 'QMPCapability' ] } }
  'data': { '*enable': [ 'QMPCapability' ] },
  'allow-preconfig': true }

##
# @QMPCapability:
@@ -155,7 +156,8 @@
# Note: This example has been shortened as the real response is too long.
#
##
{ 'command': 'query-commands', 'returns': ['CommandInfo'] }
{ 'command': 'query-commands', 'returns': ['CommandInfo'],
  'allow-preconfig': true }

##
# @LostTickPolicy:
@@ -2648,7 +2650,8 @@
#
##
{'command': 'query-command-line-options', 'data': { '*option': 'str' },
 'returns': ['CommandLineOptionInfo'] }
 'returns': ['CommandLineOptionInfo'],
 'allow-preconfig': true }

##
# @X86CPURegister32:
Loading