Commit 5dafaf4f authored by Peter Maydell's avatar Peter Maydell
Browse files

Merge remote-tracking branch 'remotes/armbru/tags/pull-qapi-2018-07-03' into staging



QAPI patches for 2018-07-03

# gpg: Signature made Tue 03 Jul 2018 21:52:55 BST
# gpg:                using RSA key 3870B400EB918653
# gpg: Good signature from "Markus Armbruster <armbru@redhat.com>"
# gpg:                 aka "Markus Armbruster <armbru@pond.sub.org>"
# Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867  4E5F 3870 B400 EB91 8653

* remotes/armbru/tags/pull-qapi-2018-07-03:
  qapi: add conditions to SPICE type/commands/events on the schema
  qapi: add conditions to VNC type/commands/events on the schema
  qapi: add 'If:' section to generated documentation
  qapi-types: add #if conditions to types & visitors
  qapi/events: add #if conditions to events
  qapi/commands: add #if conditions to commands
  qapi-introspect: add preprocessor conditions to generated QLit
  qapi-introspect: modify to_qlit() to append ',' on level > 0
  qapi: add #if/#endif helpers
  qapi: mcgen() shouldn't indent # lines
  qapi: add 'ifcond' to visitor methods
  qapi: leave the ifcond attribute undefined until check()
  qapi: pass 'if' condition into QAPISchemaEntity objects
  qapi: add 'if' to top-level expressions

Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
parents 8beb8cc6 514337c1
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -744,6 +744,35 @@ Example: Red Hat, Inc. controls redhat.com, and may therefore add a
downstream command __com.redhat_drive-mirror.


=== Configuring the schema ===

The 'struct', 'enum', 'union', 'alternate', 'command' and 'event'
top-level expressions can take an 'if' key.  Its value must be a string
or a list of strings.  A string is shorthand for a list containing just
that string.  The code generated for the top-level expression will then
be guarded by #if COND for each COND in the list.

Example: a conditional struct

 { 'struct': 'IfStruct', 'data': { 'foo': 'int' },
   'if': ['defined(CONFIG_FOO)', 'defined(HAVE_BAR)'] }

gets its generated code guarded like this:

 #if defined(CONFIG_FOO)
 #if defined(HAVE_BAR)
 ... generated code ...
 #endif /* defined(HAVE_BAR) */
 #endif /* defined(CONFIG_FOO) */

Please note that you are responsible to ensure that the C code will
compile with an arbitrary combination of conditions, since the
generators are unable to check it at this point.

The presence of 'if' keys in the schema is reflected through to the
introspection output depending on the build configuration.


== Client JSON Protocol introspection ==

Clients of a Client JSON Protocol commonly need to figure out what
+2 −0
Original line number Diff line number Diff line
@@ -426,6 +426,7 @@ STEXI
Show which guest mouse is receiving events.
ETEXI

#if defined(CONFIG_VNC)
    {
        .name       = "vnc",
        .args_type  = "",
@@ -433,6 +434,7 @@ ETEXI
        .help       = "show the vnc server status",
        .cmd        = hmp_info_vnc,
    },
#endif

STEXI
@item info vnc
+8 −1
Original line number Diff line number Diff line
@@ -616,6 +616,7 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
    qapi_free_BlockStatsList(stats_list);
}

#ifdef CONFIG_VNC
/* Helper for hmp_info_vnc_clients, _servers */
static void hmp_info_VncBasicInfo(Monitor *mon, VncBasicInfo *info,
                                  const char *name)
@@ -703,6 +704,7 @@ void hmp_info_vnc(Monitor *mon, const QDict *qdict)
    qapi_free_VncInfo2List(info2l);

}
#endif

#ifdef CONFIG_SPICE
void hmp_info_spice(Monitor *mon, const QDict *qdict)
@@ -1772,12 +1774,14 @@ void hmp_eject(Monitor *mon, const QDict *qdict)
    hmp_handle_error(mon, &err);
}

#ifdef CONFIG_VNC
static void hmp_change_read_arg(void *opaque, const char *password,
                                void *readline_opaque)
{
    qmp_change_vnc_password(password, NULL);
    monitor_read_command(opaque, 1);
}
#endif

void hmp_change(Monitor *mon, const QDict *qdict)
{
@@ -1788,6 +1792,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
    BlockdevChangeReadOnlyMode read_only_mode = 0;
    Error *err = NULL;

#ifdef CONFIG_VNC
    if (strcmp(device, "vnc") == 0) {
        if (read_only) {
            monitor_printf(mon,
@@ -1802,7 +1807,9 @@ void hmp_change(Monitor *mon, const QDict *qdict)
            }
        }
        qmp_change("vnc", target, !!arg, arg, &err);
    } else {
    } else
#endif
    {
        if (read_only) {
            read_only_mode =
                qapi_enum_parse(&BlockdevChangeReadOnlyMode_lookup,
+0 −3
Original line number Diff line number Diff line
@@ -1191,9 +1191,6 @@ static void qmp_query_qmp_schema(QDict *qdict, QObject **ret_data,
 */
static void qmp_unregister_commands_hack(void)
{
#ifndef CONFIG_SPICE
    qmp_unregister_command(&qmp_commands, "query-spice");
#endif
#ifndef CONFIG_REPLICATION
    qmp_unregister_command(&qmp_commands, "xen-set-replication");
    qmp_unregister_command(&qmp_commands, "query-xen-replication-status");
+6 −2
Original line number Diff line number Diff line
@@ -320,6 +320,7 @@
##
{ 'struct': 'ChardevSpiceChannel', 'data': { 'type'  : 'str' },
  'base': 'ChardevCommon' }
# TODO: 'if': 'defined(CONFIG_SPICE)'

##
# @ChardevSpicePort:
@@ -332,6 +333,7 @@
##
{ 'struct': 'ChardevSpicePort', 'data': { 'fqdn'  : 'str' },
  'base': 'ChardevCommon' }
# TODO: 'if': 'defined(CONFIG_SPICE)'

##
# @ChardevVC:
@@ -386,7 +388,9 @@
                                       'stdio'  : 'ChardevStdio',
                                       'console': 'ChardevCommon',
                                       'spicevmc': 'ChardevSpiceChannel',
# TODO: { 'type': 'ChardevSpiceChannel', 'if': 'defined(CONFIG_SPICE)' },
                                       'spiceport': 'ChardevSpicePort',
# TODO: { 'type': 'ChardevSpicePort', 'if': 'defined(CONFIG_SPICE)' },
                                       'vc'     : 'ChardevVC',
                                       'ringbuf': 'ChardevRingbuf',
                                       # next one is just for compatibility
Loading