qapi: add conditions to SPICE type/commands/events on the schema

Add #if defined(CONFIG_SPICE) in generated code, and adjust the
qmp/hmp code accordingly.

query-qmp-schema no longer reports the command/events etc as
available when disabled at compile time.

Commands made conditional:

* query-spice

  Before the patch, the command for !CONFIG_SPICE is unregistered. It
  will fail with the same error.

Events made conditional:

* SPICE_CONNECTED, SPICE_INITIALIZED, SPICE_DISCONNECTED,
  SPICE_MIGRATE_COMPLETED

Add TODO for conditional SPICE chardevs, delayed until the supports
for conditional members lands.

No HMP change, the code was already conditional.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180703155648.11933-15-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Marc-André Lureau 2018-07-03 17:56:48 +02:00 committed by Markus Armbruster
parent 05eb4a25ae
commit 514337c142
4 changed files with 26 additions and 31 deletions

View File

@ -1191,9 +1191,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
*/ */
static void qmp_unregister_commands_hack(void) static void qmp_unregister_commands_hack(void)
{ {
#ifndef CONFIG_SPICE
qmp_unregister_command(&qmp_commands, "query-spice");
#endif
#ifndef CONFIG_REPLICATION #ifndef CONFIG_REPLICATION
qmp_unregister_command(&qmp_commands, "xen-set-replication"); qmp_unregister_command(&qmp_commands, "xen-set-replication");
qmp_unregister_command(&qmp_commands, "query-xen-replication-status"); qmp_unregister_command(&qmp_commands, "query-xen-replication-status");

View File

@ -320,6 +320,7 @@
## ##
{ 'struct': 'ChardevSpiceChannel', 'data': { 'type' : 'str' }, { 'struct': 'ChardevSpiceChannel', 'data': { 'type' : 'str' },
'base': 'ChardevCommon' } 'base': 'ChardevCommon' }
# TODO: 'if': 'defined(CONFIG_SPICE)'
## ##
# @ChardevSpicePort: # @ChardevSpicePort:
@ -332,6 +333,7 @@
## ##
{ 'struct': 'ChardevSpicePort', 'data': { 'fqdn' : 'str' }, { 'struct': 'ChardevSpicePort', 'data': { 'fqdn' : 'str' },
'base': 'ChardevCommon' } 'base': 'ChardevCommon' }
# TODO: 'if': 'defined(CONFIG_SPICE)'
## ##
# @ChardevVC: # @ChardevVC:
@ -385,8 +387,10 @@
'testdev': 'ChardevCommon', 'testdev': 'ChardevCommon',
'stdio' : 'ChardevStdio', 'stdio' : 'ChardevStdio',
'console': 'ChardevCommon', 'console': 'ChardevCommon',
'spicevmc' : 'ChardevSpiceChannel', 'spicevmc': 'ChardevSpiceChannel',
'spiceport' : 'ChardevSpicePort', # TODO: { 'type': 'ChardevSpiceChannel', 'if': 'defined(CONFIG_SPICE)' },
'spiceport': 'ChardevSpicePort',
# TODO: { 'type': 'ChardevSpicePort', 'if': 'defined(CONFIG_SPICE)' },
'vc' : 'ChardevVC', 'vc' : 'ChardevVC',
'ringbuf': 'ChardevRingbuf', 'ringbuf': 'ChardevRingbuf',
# next one is just for compatibility # next one is just for compatibility

View File

@ -118,7 +118,8 @@
{ 'struct': 'SpiceBasicInfo', { 'struct': 'SpiceBasicInfo',
'data': { 'host': 'str', 'data': { 'host': 'str',
'port': 'str', 'port': 'str',
'family': 'NetworkAddressFamily' } } 'family': 'NetworkAddressFamily' },
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SpiceServerInfo: # @SpiceServerInfo:
@ -131,7 +132,8 @@
## ##
{ 'struct': 'SpiceServerInfo', { 'struct': 'SpiceServerInfo',
'base': 'SpiceBasicInfo', 'base': 'SpiceBasicInfo',
'data': { '*auth': 'str' } } 'data': { '*auth': 'str' },
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SpiceChannel: # @SpiceChannel:
@ -156,7 +158,8 @@
{ 'struct': 'SpiceChannel', { 'struct': 'SpiceChannel',
'base': 'SpiceBasicInfo', 'base': 'SpiceBasicInfo',
'data': {'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'int', 'data': {'connection-id': 'int', 'channel-type': 'int', 'channel-id': 'int',
'tls': 'bool'} } 'tls': 'bool'},
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SpiceQueryMouseMode: # @SpiceQueryMouseMode:
@ -175,7 +178,8 @@
# Since: 1.1 # Since: 1.1
## ##
{ 'enum': 'SpiceQueryMouseMode', { 'enum': 'SpiceQueryMouseMode',
'data': [ 'client', 'server', 'unknown' ] } 'data': [ 'client', 'server', 'unknown' ],
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SpiceInfo: # @SpiceInfo:
@ -212,7 +216,8 @@
{ 'struct': 'SpiceInfo', { 'struct': 'SpiceInfo',
'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int', 'data': {'enabled': 'bool', 'migrated': 'bool', '*host': 'str', '*port': 'int',
'*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str', '*tls-port': 'int', '*auth': 'str', '*compiled-version': 'str',
'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']} } 'mouse-mode': 'SpiceQueryMouseMode', '*channels': ['SpiceChannel']},
'if': 'defined(CONFIG_SPICE)' }
## ##
# @query-spice: # @query-spice:
@ -257,7 +262,8 @@
# } # }
# #
## ##
{ 'command': 'query-spice', 'returns': 'SpiceInfo' } { 'command': 'query-spice', 'returns': 'SpiceInfo',
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SPICE_CONNECTED: # @SPICE_CONNECTED:
@ -282,7 +288,8 @@
## ##
{ 'event': 'SPICE_CONNECTED', { 'event': 'SPICE_CONNECTED',
'data': { 'server': 'SpiceBasicInfo', 'data': { 'server': 'SpiceBasicInfo',
'client': 'SpiceBasicInfo' } } 'client': 'SpiceBasicInfo' },
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SPICE_INITIALIZED: # @SPICE_INITIALIZED:
@ -310,7 +317,8 @@
## ##
{ 'event': 'SPICE_INITIALIZED', { 'event': 'SPICE_INITIALIZED',
'data': { 'server': 'SpiceServerInfo', 'data': { 'server': 'SpiceServerInfo',
'client': 'SpiceChannel' } } 'client': 'SpiceChannel' },
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SPICE_DISCONNECTED: # @SPICE_DISCONNECTED:
@ -335,7 +343,8 @@
## ##
{ 'event': 'SPICE_DISCONNECTED', { 'event': 'SPICE_DISCONNECTED',
'data': { 'server': 'SpiceBasicInfo', 'data': { 'server': 'SpiceBasicInfo',
'client': 'SpiceBasicInfo' } } 'client': 'SpiceBasicInfo' },
'if': 'defined(CONFIG_SPICE)' }
## ##
# @SPICE_MIGRATE_COMPLETED: # @SPICE_MIGRATE_COMPLETED:
@ -350,7 +359,8 @@
# "event": "SPICE_MIGRATE_COMPLETED" } # "event": "SPICE_MIGRATE_COMPLETED" }
# #
## ##
{ 'event': 'SPICE_MIGRATE_COMPLETED' } { 'event': 'SPICE_MIGRATE_COMPLETED',
'if': 'defined(CONFIG_SPICE)' }
## ##
# == VNC # == VNC

16
qmp.c
View File

@ -129,22 +129,6 @@ void qmp_cpu_add(int64_t id, Error **errp)
} }
} }
#ifndef CONFIG_SPICE
/*
* qmp_unregister_commands_hack() ensures that QMP command query-spice
* exists only #ifdef CONFIG_SPICE. Necessary for an accurate
* query-commands result. However, the QAPI schema is blissfully
* unaware of that, and the QAPI code generator happily generates a
* dead qmp_marshal_query_spice() that calls qmp_query_spice().
* Provide it one, or else linking fails. FIXME Educate the QAPI
* schema on CONFIG_SPICE.
*/
SpiceInfo *qmp_query_spice(Error **errp)
{
abort();
};
#endif
void qmp_exit_preconfig(Error **errp) void qmp_exit_preconfig(Error **errp)
{ {
if (!runstate_check(RUN_STATE_PRECONFIG)) { if (!runstate_check(RUN_STATE_PRECONFIG)) {