Skip to contentSkip to conversation

qapi: Put type information back into QMP documentation

PATCH Superseded Markus Armbruster 3 participants 137 messages Mar 13, 2017 – Apr 27, 2017 Kbuild Page 1 of 2

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover qapi: Put type information back into QMP documentation

I'm proposing this is 2.9 because it fixes a documentation regression. It affects only documentation; generated C code is unchanged except for the removal of trailing space in PATCH 46.

Based on my qapi-next branch, which contains Marc-André's PATCH 1/2.

Marc-André's work to merge qmp-commands.txt and qmp-events.txt into the QAPI schema and generate their replacements from the schema (commit b6af8ea..56e8bdd) was a big step forward. As committed, it also was a step back: the documentation lost information on JSON types, because I didn't like Marc-André's patch to add it. He reposted it for further review afterwards:

    Subject: [PATCH 0/2] qapi2texi: add type information
    Message-Id: <[email protected]>
    https://lists.gnu.org/archive/html/qemu-devel/2017-01/msg05432.html

His PATCH 1/2 is a straightforward cleanup. His PATCH 2/2 adds type descriptions in a new formal language to the generated documentation. Quoting the commit message:

Array types have the following syntax: type[]. Ex: str[].

- Struct, commands and events use the following members syntax:

{ 'member': type, ('foo': str), ... }

Optional members are under parentheses.

A structure with a base type will have 'BaseStruct +' prepended.

- Alternates use the following syntax:

[ 'foo': type, 'bar': type, ... ]

- Simple unions use the following syntax:

{ 'type': str, 'data': 'type' = [ 'foo': type, 'bar': type... ] }

- Flat unions use the following syntax:

BaseStruct + 'discriminator' = [ 'foo': type, 'bar': type... ]

End quote. Looks like this in generated documentation:

-- Event: VNC_CONNECTED {'server': VncServerInfo, 'client':
VncBasicInfo}

Emitted when a VNC client establishes a connection ''server''
server information
''client''
client information

Note: This event is emitted before any authentication takes place, thus the authentication ID is not provided
[...]

-- Struct: VncServerInfo VncBasicInfo + {('auth': str)}

The network connection information for server
''auth'' (optional)
authentication method used for the plain (non-websocket) VNC server

Since: 2.1

-- Simple Union: SocketAddress { 'type': str, 'data': 'type' = ['inet':
InetSocketAddress, 'unix': UnixSocketAddress, 'vsock':
VsockSocketAddress, 'fd': String] }

Captures the address of a socket, which could also be a named file descriptor

Since: 1.3

Here's my counter-proposal: instead of inventing a formal language, fix the natural language documentation to actually mention *all* members, and add type information in a plain, easy-to-understand way. Looks like this:

-- Event: VNC_CONNECTED

Emitted when a VNC client establishes a connection

Arguments:
'server: VncServerInfo'
server information
'client: VncBasicInfo'
client information

Note: This event is emitted before any authentication takes place, thus the authentication ID is not provided
[...]

-- Object: VncServerInfo

The network connection information for server

Members:
'auth: string' (optional)
authentication method used for the plain (non-websocket) VNC server
The members of 'VncBasicInfo'

Since: 2.1

-- Object: SocketAddress

Captures the address of a socket, which could also be a named file descriptor

Members:
'type'
One of "inet", "unix", "vsock", "fd"
'data: InetSocketAddress' when 'type' is "inet" 'data: UnixSocketAddress' when 'type' is "unix" 'data: VsockSocketAddress' when 'type' is "vsock" 'data: String' when 'type' is "fd"

Since: 1.3

Additionally, my series fixes a number of bugs and cleans up along the way. In particular, it converts qapi2texi.py from parse trees to the visitor interface the other generators use.

Future generated documentation work includes eliding types that aren't visible in QMP (like introspection does), and making uses of type names links in HTML.

Markus Armbruster (47):
qapi: Factor QAPISchemaParser._include() out of .__init__()
qapi: Make doc comments optional where we don't need them
qapi: Back out doc comments added just to please qapi.py docs/qapi-code-gen.txt: Drop confusing reference to 'gen'
qapi: Have each QAPI schema declare its returns white-list
qapi: Have each QAPI schema declare its name rule violations
qapi: Clean up build of generated documentation tests/qapi-schema: Cover empty union base
qapi: Fix to reject empty union base gracefully
qapi2texi: Fix up output around #optional
qapi: Avoid unwanted blank lines in QAPIDoc qapi/rocker: Fix up doc comment notes on optional members
qapi: Fix QAPISchemaEnumType.is_implicit() for 'QType'
qapi: Prepare for requiring more complete documentation
qapi: Conjure up QAPIDoc.ArgSection for undocumented members
qapi2texi: Convert to QAPISchemaVisitor
qapi: The #optional tag is redundant, drop
qapi: Use raw strings for regular expressions consistently
qapi: Prefer single-quoted strings more consistently
qapi2texi: Plainer enum value and member name formatting
qapi2texi: Present the table of members more clearly
qapi2texi: Explain enum value undocumentedness more clearly
qapi2texi: Don't hide undocumented members and arguments
qapi2texi: Implement boxed argument documentation
qapi2texi: Include member type in generated documentation
qapi2texi: Generate reference to base type members
qapi2texi: Generate documentation for variant members
qapi2texi: Generate descriptions for simple union tags
qapi2texi: Use category "Object" for all object types tests/qapi-schema: Improve doc / expression mismatch coverage
qapi: Fix detection of doc / expression mismatch
qapi: Move detection of doc / expression name mismatch
qapi: Improve error message on @NAME: in free-form doc
qapi: Move empty doc section checking to doc parser tests/qapi-schema: Rename doc-bad-args to doc-bad-command-arg tests/qapi-schema: Improve coverage of bogus member docs
qapi: Fix detection of bogus member documentation
qapi: Eliminate check_docs() and drop QAPIDoc.expr
qapi: Drop unused variable events
qapi: Simplify what gets stored in enum_types
qapi: Factor add_name() calls out of the meta conditional
qapi: enum_types is a list used like a dict, make it one
qapi: struct_types is a list used like a dict, make it one
qapi: union_types is a list used like a dict, make it one
qapi: Drop unused .check_clash() parameter schema
qapi: Make pylint a bit happier
qapi: Fix a misleading parser error message

 .gitignore                                         |  10 +-
 Makefile                                           |  27 +-
 docs/qapi-code-gen.txt                             |  81 +--
 docs/qemu-qmp-ref.texi                             |   2 +-
 docs/writing-qmp-commands.txt                      |   4 +-
 qapi-schema.json                                   | 403 ++++++-------
 qapi/block-core.json                               | 428 +++++++-------
 qapi/block.json                                    |   8 +-
 qapi/crypto.json                                   |  22 +-
 qapi/event.json                                    |  10 +-
 qapi/introspect.json                               |   6 +-
 qapi/rocker.json                                   |  88 +--
 qapi/trace.json                                    |   6 +-
 qga/qapi-schema.json                               |  55 +-
 rules.mak                                          |   2 +-
 scripts/qapi-commands.py                           |   6 +-
 scripts/qapi-event.py                              |   2 +-
 scripts/qapi-introspect.py                         |   4 +-
 scripts/qapi-types.py                              |   4 +-
 scripts/qapi-visit.py                              |   5 +-
 scripts/qapi.py                                    | 632 ++++++++++-----------
 scripts/qapi2texi.py                               | 298 +++++-----
 tests/Makefile.include                             |   9 +-
 tests/qapi-schema/alternate-any.err                |   2 +-
 tests/qapi-schema/alternate-any.json               |   4 -
 tests/qapi-schema/alternate-array.err              |   2 +-
 tests/qapi-schema/alternate-array.json             |   7 -
 tests/qapi-schema/alternate-base.err               |   2 +-
 tests/qapi-schema/alternate-base.json              |   7 -
 tests/qapi-schema/alternate-clash.err              |   2 +-
 tests/qapi-schema/alternate-clash.json             |   4 -
 tests/qapi-schema/alternate-conflict-dict.err      |   2 +-
 tests/qapi-schema/alternate-conflict-dict.json     |  10 -
 tests/qapi-schema/alternate-conflict-string.err    |   2 +-
 tests/qapi-schema/alternate-conflict-string.json   |   7 -
 tests/qapi-schema/alternate-empty.err              |   2 +-
 tests/qapi-schema/alternate-empty.json             |   4 -
 tests/qapi-schema/alternate-nested.err             |   2 +-
 tests/qapi-schema/alternate-nested.json            |   7 -
 tests/qapi-schema/alternate-unknown.err            |   2 +-
 tests/qapi-schema/alternate-unknown.json           |   4 -
 tests/qapi-schema/args-alternate.err               |   2 +-
 tests/qapi-schema/args-alternate.json              |   8 -
 tests/qapi-schema/args-any.err                     |   2 +-
 tests/qapi-schema/args-any.json                    |   4 -
 tests/qapi-schema/args-array-empty.err             |   2 +-
 tests/qapi-schema/args-array-empty.json            |   4 -
 tests/qapi-schema/args-array-unknown.err           |   2 +-
 tests/qapi-schema/args-array-unknown.json          |   4 -
 tests/qapi-schema/args-bad-boxed.err               |   2 +-
 tests/qapi-schema/args-bad-boxed.json              |   4 -
 tests/qapi-schema/args-boxed-anon.err              |   2 +-
 tests/qapi-schema/args-boxed-anon.json             |   4 -
 tests/qapi-schema/args-boxed-empty.err             |   2 +-
 tests/qapi-schema/args-boxed-empty.json            |   8 -
 tests/qapi-schema/args-boxed-string.err            |   2 +-
 tests/qapi-schema/args-boxed-string.json           |   4 -
 tests/qapi-schema/args-int.err                     |   2 +-
 tests/qapi-schema/args-int.json                    |   4 -
 tests/qapi-schema/args-invalid.err                 |   2 +-
 tests/qapi-schema/args-invalid.json                |   3 -
 tests/qapi-schema/args-member-array-bad.err        |   2 +-
 tests/qapi-schema/args-member-array-bad.json       |   4 -
 tests/qapi-schema/args-member-case.err             |   2 +-
 tests/qapi-schema/args-member-case.json            |   4 -
 tests/qapi-schema/args-member-unknown.err          |   2 +-
 tests/qapi-schema/args-member-unknown.json         |   4 -
 tests/qapi-schema/args-name-clash.err              |   2 +-
 tests/qapi-schema/args-name-clash.json             |   4 -
 tests/qapi-schema/args-union.err                   |   2 +-
 tests/qapi-schema/args-union.json                  |   7 -
 tests/qapi-schema/args-unknown.err                 |   2 +-
 tests/qapi-schema/args-unknown.json                |   4 -
 tests/qapi-schema/bad-base.err                     |   2 +-
 tests/qapi-schema/bad-base.json                    |   7 -
 tests/qapi-schema/bad-data.err                     |   2 +-
 tests/qapi-schema/bad-data.json                    |   4 -
 tests/qapi-schema/bad-ident.err                    |   2 +-
 tests/qapi-schema/bad-ident.json                   |   4 -
 tests/qapi-schema/bad-type-bool.err                |   2 +-
 tests/qapi-schema/bad-type-bool.json               |   4 -
 tests/qapi-schema/bad-type-dict.err                |   2 +-
 tests/qapi-schema/bad-type-dict.json               |   4 -
 tests/qapi-schema/base-cycle-direct.err            |   2 +-
 tests/qapi-schema/base-cycle-direct.json           |   4 -
 tests/qapi-schema/base-cycle-indirect.err          |   2 +-
 tests/qapi-schema/base-cycle-indirect.json         |   7 -
 tests/qapi-schema/command-int.err                  |   2 +-
 tests/qapi-schema/command-int.json                 |   4 -
 tests/qapi-schema/comments.json                    |   4 -
 tests/qapi-schema/comments.out                     |   1 -
 tests/qapi-schema/doc-bad-alternate-member.err     |   1 +
 ...optional.exit => doc-bad-alternate-member.exit} |   0
 tests/qapi-schema/doc-bad-alternate-member.json    |   9 +
 ...c-optional.out => doc-bad-alternate-member.out} |   0
 tests/qapi-schema/doc-bad-args.err                 |   1 -
 tests/qapi-schema/doc-bad-command-arg.err          |   1 +
 ...{doc-bad-args.exit => doc-bad-command-arg.exit} |   0
 ...{doc-bad-args.json => doc-bad-command-arg.json} |   0
 .../{doc-bad-args.out => doc-bad-command-arg.out}  |   0
 tests/qapi-schema/doc-bad-expr.err                 |   1 +
 tests/qapi-schema/doc-bad-expr.exit                |   1 +
 tests/qapi-schema/doc-bad-expr.json                |   7 +
 tests/qapi-schema/doc-bad-expr.out                 |   0
 tests/qapi-schema/doc-bad-symbol.err               |   2 +-
 tests/qapi-schema/doc-bad-union-member.err         |   1 +
 tests/qapi-schema/doc-bad-union-member.exit        |   1 +
 tests/qapi-schema/doc-bad-union-member.json        |  19 +
 tests/qapi-schema/doc-bad-union-member.out         |   0
 tests/qapi-schema/doc-empty-section.err            |   2 +-
 tests/qapi-schema/doc-invalid-section.err          |   2 +-
 tests/qapi-schema/doc-missing-expr.err             |   2 +-
 tests/qapi-schema/doc-missing.err                  |   1 +
 tests/qapi-schema/doc-missing.exit                 |   1 +
 tests/qapi-schema/doc-missing.json                 |   5 +
 tests/qapi-schema/doc-missing.out                  |   0
 tests/qapi-schema/doc-no-symbol.err                |   1 +
 tests/qapi-schema/doc-no-symbol.exit               |   1 +
 tests/qapi-schema/doc-no-symbol.json               |   6 +
 tests/qapi-schema/doc-no-symbol.out                |   0
 tests/qapi-schema/doc-optional.err                 |   1 -
 tests/qapi-schema/doc-optional.json                |   7 -
 tests/qapi-schema/double-type.err                  |   2 +-
 tests/qapi-schema/double-type.json                 |   4 -
 tests/qapi-schema/enum-bad-name.err                |   2 +-
 tests/qapi-schema/enum-bad-name.json               |   4 -
 tests/qapi-schema/enum-bad-prefix.err              |   2 +-
 tests/qapi-schema/enum-bad-prefix.json             |   4 -
 tests/qapi-schema/enum-clash-member.err            |   2 +-
 tests/qapi-schema/enum-clash-member.json           |   4 -
 tests/qapi-schema/enum-dict-member.err             |   2 +-
 tests/qapi-schema/enum-dict-member.json            |   4 -
 tests/qapi-schema/enum-member-case.err             |   2 +-
 tests/qapi-schema/enum-member-case.json            |   8 +-
 tests/qapi-schema/enum-missing-data.err            |   2 +-
 tests/qapi-schema/enum-missing-data.json           |   4 -
 tests/qapi-schema/enum-wrong-data.err              |   2 +-
 tests/qapi-schema/enum-wrong-data.json             |   4 -
 tests/qapi-schema/event-boxed-empty.err            |   2 +-
 tests/qapi-schema/event-boxed-empty.json           |   4 -
 tests/qapi-schema/event-case.json                  |   4 -
 tests/qapi-schema/event-case.out                   |   1 -
 tests/qapi-schema/event-nest-struct.err            |   2 +-
 tests/qapi-schema/event-nest-struct.json           |   4 -
 tests/qapi-schema/flat-union-array-branch.err      |   2 +-
 tests/qapi-schema/flat-union-array-branch.json     |  12 -
 tests/qapi-schema/flat-union-bad-base.err          |   2 +-
 tests/qapi-schema/flat-union-bad-base.json         |  13 -
 tests/qapi-schema/flat-union-bad-discriminator.err |   2 +-
 .../qapi-schema/flat-union-bad-discriminator.json  |  16 -
 tests/qapi-schema/flat-union-base-any.err          |   2 +-
 tests/qapi-schema/flat-union-base-any.json         |  13 -
 tests/qapi-schema/flat-union-base-union.err        |   2 +-
 tests/qapi-schema/flat-union-base-union.json       |  16 -
 tests/qapi-schema/flat-union-clash-member.err      |   2 +-
 tests/qapi-schema/flat-union-clash-member.json     |  16 -
 tests/qapi-schema/flat-union-empty.err             |   2 +-
 tests/qapi-schema/flat-union-empty.json            |  10 -
 tests/qapi-schema/flat-union-incomplete-branch.err |   2 +-
 .../qapi-schema/flat-union-incomplete-branch.json  |  10 -
 tests/qapi-schema/flat-union-inline.err            |   2 +-
 tests/qapi-schema/flat-union-inline.json           |  10 -
 tests/qapi-schema/flat-union-int-branch.err        |   2 +-
 tests/qapi-schema/flat-union-int-branch.json       |  13 -
 .../qapi-schema/flat-union-invalid-branch-key.err  |   2 +-
 .../qapi-schema/flat-union-invalid-branch-key.json |  15 -
 .../flat-union-invalid-discriminator.err           |   2 +-
 .../flat-union-invalid-discriminator.json          |  15 -
 tests/qapi-schema/flat-union-no-base.err           |   2 +-
 tests/qapi-schema/flat-union-no-base.json          |  13 -
 .../flat-union-optional-discriminator.err          |   2 +-
 .../flat-union-optional-discriminator.json         |  13 -
 .../flat-union-string-discriminator.err            |   2 +-
 .../flat-union-string-discriminator.json           |  15 -
 tests/qapi-schema/ident-with-escape.json           |   4 -
 tests/qapi-schema/ident-with-escape.out            |   1 -
 tests/qapi-schema/include-relpath-sub.json         |   3 -
 tests/qapi-schema/include-relpath.out              |   1 -
 tests/qapi-schema/include-repetition.out           |   1 -
 tests/qapi-schema/include-simple-sub.json          |   3 -
 tests/qapi-schema/include-simple.out               |   1 -
 tests/qapi-schema/indented-expr.json               |   6 -
 tests/qapi-schema/indented-expr.out                |   2 -
 tests/qapi-schema/missing-type.err                 |   2 +-
 tests/qapi-schema/missing-type.json                |   4 -
 tests/qapi-schema/nested-struct-data.err           |   2 +-
 tests/qapi-schema/nested-struct-data.json          |   4 -
 tests/qapi-schema/qapi-schema-test.json            | 218 +------
 tests/qapi-schema/qapi-schema-test.out             | 130 -----
 tests/qapi-schema/redefined-builtin.err            |   2 +-
 tests/qapi-schema/redefined-builtin.json           |   4 -
 tests/qapi-schema/redefined-command.err            |   2 +-
 tests/qapi-schema/redefined-command.json           |   7 -
 tests/qapi-schema/redefined-event.err              |   2 +-
 tests/qapi-schema/redefined-event.json             |   7 -
 tests/qapi-schema/redefined-type.err               |   2 +-
 tests/qapi-schema/redefined-type.json              |   7 -
 tests/qapi-schema/reserved-command-q.err           |   2 +-
 tests/qapi-schema/reserved-command-q.json          |   7 -
 tests/qapi-schema/reserved-enum-q.err              |   2 +-
 tests/qapi-schema/reserved-enum-q.json             |   4 -
 tests/qapi-schema/reserved-member-has.err          |   2 +-
 tests/qapi-schema/reserved-member-has.json         |   4 -
 tests/qapi-schema/reserved-member-q.err            |   2 +-
 tests/qapi-schema/reserved-member-q.json           |   4 -
 tests/qapi-schema/reserved-member-u.err            |   2 +-
 tests/qapi-schema/reserved-member-u.json           |   4 -
 tests/qapi-schema/reserved-member-underscore.err   |   2 +-
 tests/qapi-schema/reserved-member-underscore.json  |   4 -
 tests/qapi-schema/reserved-type-kind.err           |   2 +-
 tests/qapi-schema/reserved-type-kind.json          |   4 -
 tests/qapi-schema/reserved-type-list.err           |   2 +-
 tests/qapi-schema/reserved-type-list.json          |   4 -
 tests/qapi-schema/returns-alternate.err            |   2 +-
 tests/qapi-schema/returns-alternate.json           |   7 -
 tests/qapi-schema/returns-array-bad.err            |   2 +-
 tests/qapi-schema/returns-array-bad.json           |   4 -
 tests/qapi-schema/returns-dict.err                 |   2 +-
 tests/qapi-schema/returns-dict.json                |   4 -
 tests/qapi-schema/returns-unknown.err              |   2 +-
 tests/qapi-schema/returns-unknown.json             |   4 -
 tests/qapi-schema/returns-whitelist.err            |   2 +-
 tests/qapi-schema/returns-whitelist.json           |  18 +-
 tests/qapi-schema/struct-base-clash-deep.err       |   2 +-
 tests/qapi-schema/struct-base-clash-deep.json      |  10 -
 tests/qapi-schema/struct-base-clash.err            |   2 +-
 tests/qapi-schema/struct-base-clash.json           |   7 -
 tests/qapi-schema/struct-data-invalid.err          |   2 +-
 tests/qapi-schema/struct-data-invalid.json         |   3 -
 tests/qapi-schema/struct-member-invalid.err        |   2 +-
 tests/qapi-schema/struct-member-invalid.json       |   3 -
 tests/qapi-schema/test-qapi.py                     |  14 -
 tests/qapi-schema/trailing-comma-list.err          |   2 +-
 tests/qapi-schema/type-bypass-bad-gen.err          |   2 +-
 tests/qapi-schema/type-bypass-bad-gen.json         |   4 -
 tests/qapi-schema/unicode-str.err                  |   2 +-
 tests/qapi-schema/unicode-str.json                 |   4 -
 tests/qapi-schema/union-base-empty.err             |   1 +
 tests/qapi-schema/union-base-empty.exit            |   1 +
 tests/qapi-schema/union-base-empty.json            |   9 +
 tests/qapi-schema/union-base-empty.out             |   0
 tests/qapi-schema/union-base-no-discriminator.err  |   2 +-
 tests/qapi-schema/union-base-no-discriminator.json |  12 -
 tests/qapi-schema/union-branch-case.err            |   2 +-
 tests/qapi-schema/union-branch-case.json           |   4 -
 tests/qapi-schema/union-clash-branches.err         |   2 +-
 tests/qapi-schema/union-clash-branches.json        |   4 -
 tests/qapi-schema/union-empty.err                  |   2 +-
 tests/qapi-schema/union-empty.json                 |   4 -
 tests/qapi-schema/union-invalid-base.err           |   2 +-
 tests/qapi-schema/union-invalid-base.json          |  10 -
 tests/qapi-schema/union-optional-branch.err        |   2 +-
 tests/qapi-schema/union-optional-branch.json       |   4 -
 tests/qapi-schema/union-unknown.err                |   2 +-
 tests/qapi-schema/union-unknown.json               |   4 -
 tests/qapi-schema/unknown-escape.err               |   2 +-
 tests/qapi-schema/unknown-escape.json              |   4 -
 tests/qapi-schema/unknown-expr-key.err             |   2 +-
 tests/qapi-schema/unknown-expr-key.json            |   4 -
 259 files changed, 1263 insertions(+), 2109 deletions(-)
 create mode 100644 tests/qapi-schema/doc-bad-alternate-member.err
 rename tests/qapi-schema/{doc-optional.exit => doc-bad-alternate-member.exit} (100%)
 create mode 100644 tests/qapi-schema/doc-bad-alternate-member.json
 rename tests/qapi-schema/{doc-optional.out => doc-bad-alternate-member.out} (100%)
 delete mode 100644 tests/qapi-schema/doc-bad-args.err
 create mode 100644 tests/qapi-schema/doc-bad-command-arg.err
 rename tests/qapi-schema/{doc-bad-args.exit => doc-bad-command-arg.exit} (100%)
 rename tests/qapi-schema/{doc-bad-args.json => doc-bad-command-arg.json} (100%)
 rename tests/qapi-schema/{doc-bad-args.out => doc-bad-command-arg.out} (100%)
 create mode 100644 tests/qapi-schema/doc-bad-expr.err
 create mode 100644 tests/qapi-schema/doc-bad-expr.exit
 create mode 100644 tests/qapi-schema/doc-bad-expr.json
 create mode 100644 tests/qapi-schema/doc-bad-expr.out
 create mode 100644 tests/qapi-schema/doc-bad-union-member.err
 create mode 100644 tests/qapi-schema/doc-bad-union-member.exit
 create mode 100644 tests/qapi-schema/doc-bad-union-member.json
 create mode 100644 tests/qapi-schema/doc-bad-union-member.out
 create mode 100644 tests/qapi-schema/doc-missing.err
 create mode 100644 tests/qapi-schema/doc-missing.exit
 create mode 100644 tests/qapi-schema/doc-missing.json
 create mode 100644 tests/qapi-schema/doc-missing.out
 create mode 100644 tests/qapi-schema/doc-no-symbol.err
 create mode 100644 tests/qapi-schema/doc-no-symbol.exit
 create mode 100644 tests/qapi-schema/doc-no-symbol.json
 create mode 100644 tests/qapi-schema/doc-no-symbol.out
 delete mode 100644 tests/qapi-schema/doc-optional.err
 delete mode 100644 tests/qapi-schema/doc-optional.json
 create mode 100644 tests/qapi-schema/union-base-empty.err
 create mode 100644 tests/qapi-schema/union-base-empty.exit
 create mode 100644 tests/qapi-schema/union-base-empty.json
 create mode 100644 tests/qapi-schema/union-base-empty.out
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/47 qapi: Factor QAPISchemaParser._include() out of .__init__()

---
 scripts/qapi.py | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)
scripts/qapi.py +23 -22
index 53a4477..345cde1 100644
@@ -268,34 +268,15 @@ class QAPISchemaParser(object):
                 continue
 
             expr = self.get_expr(False)
-            if isinstance(expr, dict) and "include" in expr:
+            if 'include' in expr:
                 if len(expr) != 1:
                     raise QAPISemError(info, "Invalid 'include' directive")
                 include = expr["include"]
                 if not isinstance(include, str):
                     raise QAPISemError(info,
                                        "Value of 'include' must be a string")
-                incl_abs_fname = os.path.join(os.path.dirname(abs_fname),
-                                              include)
-                # catch inclusion cycle
-                inf = info
-                while inf:
-                    if incl_abs_fname == os.path.abspath(inf['file']):
-                        raise QAPISemError(info, "Inclusion loop for %s"
-                                           % include)
-                    inf = inf['parent']
-
-                # skip multiple include of the same file
-                if incl_abs_fname in previously_included:
-                    continue
-                try:
-                    fobj = open(incl_abs_fname, 'r')
-                except IOError as e:
-                    raise QAPISemError(info, '%s: %s' % (e.strerror, include))
-                exprs_include = QAPISchemaParser(fobj, previously_included,
-                                                 info)
-                self.exprs.extend(exprs_include.exprs)
-                self.docs.extend(exprs_include.docs)
+                self._include(include, info, os.path.dirname(abs_fname),
+                              previously_included)
             else:
                 expr_elem = {'expr': expr,
                              'info': info}
@@ -307,6 +288,26 @@ class QAPISchemaParser(object):
 
                 self.exprs.append(expr_elem)
 
+    def _include(self, include, info, base_dir, previously_included):
+        incl_abs_fname = os.path.join(base_dir, include)
+        # catch inclusion cycle
+        inf = info
+        while inf:
+            if incl_abs_fname == os.path.abspath(inf['file']):
+                raise QAPISemError(info, "Inclusion loop for %s" % include)
+            inf = inf['parent']
+
+        # skip multiple include of the same file
+        if incl_abs_fname in previously_included:
+            return
+        try:
+            fobj = open(incl_abs_fname, 'r')
+        except IOError as e:
+            raise QAPISemError(info, '%s: %s' % (e.strerror, include))
+        exprs_include = QAPISchemaParser(fobj, previously_included, info)
+        self.exprs.extend(exprs_include.exprs)
+        self.docs.extend(exprs_include.docs)
+
     def accept(self, skip_comment=True):
         while True:
             self.tok = self.src[self.cursor]
Signature · 1 line
2.7.4
Reviewed-by on v1 1/47
#2 lore raw

Re: [Qemu-devel] [PATCH for-2.9 01/47] qapi: Factor QAPISchemaParser._include() out of .__init__()

Quoted 9 lines · Markus Armbruster
---
 scripts/qapi.py | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)

+++ b/scripts/qapi.py

scripts/qapi.py class QAPISchemaParser(object): · line 271

Quoted 5 lines
scripts/qapi.py +1 -1
@@ -268,34 +268,15 @@ class QAPISchemaParser(object):
                 continue
 
             expr = self.get_expr(False)
-            if isinstance(expr, dict) and "include" in expr:
+            if 'include' in expr:

What happens when expr is not a dict?
/me goes and reads get_expr()...
aha - get_expr() can only return a dict at the top level, and we are only checking for includes at the top level (it can return non-dict when nested, but this part of __init__ is not nested).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 1/47
#3 lore raw

Re: [Qemu-devel] [PATCH for-2.9 01/47] qapi: Factor QAPISchemaParser._include() out of .__init__()

In reply to Markus Armbruster

On Mon, Mar 13, 2017 at 10:20 AM Markus Armbruster <[email protected]> wrote:

---
 scripts/qapi.py | 45 +++++++++++++++++++++++----------------------
 1 file changed, 23 insertions(+), 22 deletions(-)
scripts/qapi.py +1 -1
index 53a4477..345cde1 100644
@@ -268,34 +268,15 @@ class QAPISchemaParser(object):
                 continue
 
             expr = self.get_expr(False)
-            if isinstance(expr, dict) and "include" in expr:
+            if 'include' in expr:
                 if len(expr) != 1:
                     raise QAPISemError(info, "Invalid 'include' directive")
                 include = expr["include"]
                 if not isinstance(include, str):
                     raise QAPISemError(info,
                                        "Value of 'include' must be a

string")
- incl_abs_fname = os.path.join(os.path.dirname(abs_fname),
- include)

-                # catch inclusion cycle
-                inf = info
-                while inf:

- if incl_abs_fname == os.path.abspath(inf['file']):
- raise QAPISemError(info, "Inclusion loop for %s"
- % include)
- inf = inf['parent']
-
- # skip multiple include of the same file
- if incl_abs_fname in previously_included:
- continue
- try:
- fobj = open(incl_abs_fname, 'r')
- except IOError as e:
- raise QAPISemError(info, '%s: %s' % (e.strerror,
include))
- exprs_include = QAPISchemaParser(fobj, previously_included,
- info)

-                self.exprs.extend(exprs_include.exprs)
-                self.docs.extend(exprs_include.docs)
+                self._include(include, info, os.path.dirname(abs_fname),
+                              previously_included)
             else:
                 expr_elem = {'expr': expr,
                              'info': info}

@@ -307,6 +288,26 @@ class QAPISchemaParser(object):

self.exprs.append(expr_elem)

+ def _include(self, include, info, base_dir, previously_included):

+        incl_abs_fname = os.path.join(base_dir, include)
+        # catch inclusion cycle
+        inf = info
+        while inf:

+ if incl_abs_fname == os.path.abspath(inf['file']):
+ raise QAPISemError(info, "Inclusion loop for %s" % include)
+ inf = inf['parent']
+
+ # skip multiple include of the same file
+ if incl_abs_fname in previously_included:
+ return
+ try:
+ fobj = open(incl_abs_fname, 'r')
+ except IOError as e:
+ raise QAPISemError(info, '%s: %s' % (e.strerror, include))

+        exprs_include = QAPISchemaParser(fobj, previously_included, info)
+        self.exprs.extend(exprs_include.exprs)
+        self.docs.extend(exprs_include.docs)

+
def accept(self, skip_comment=True):
while True:
self.tok = self.src[self.cursor]
--
2.7.4

Signature · 1 line
Marc-André Lureau
#4 lore raw

PATCH 2/47 qapi: Make doc comments optional where we don't need them

In reply to Markus Armbruster

Since we added the documentation generator in commit 3313b61, doc comments are mandatory. That's a very good idea for a schema that needs to be documented, but has proven to be annoying for testing.

Make doc comments optional again, but add a new directive

    { 'pragma': { 'doc-required': true } }

to let a QAPI schema require them.

Require documentation in the schemas we actually want documented:
qapi-schema.json and qga/qapi-schema.json.

We could probably make qapi2texi.py cope with incomplete documentation, but for now, simply make it refuse to run unless the schema has 'doc-required': true.

---
 docs/qapi-code-gen.txt             | 40 +++++++++++++++++++++++++-------------
 qapi-schema.json                   |  2 ++
 qga/qapi-schema.json               |  2 ++
 scripts/qapi.py                    | 20 ++++++++++++++++++-
 scripts/qapi2texi.py               |  3 +++
 tests/Makefile.include             |  1 +
 tests/qapi-schema/doc-missing.err  |  1 +
 tests/qapi-schema/doc-missing.exit |  1 +
 tests/qapi-schema/doc-missing.json |  5 +++++
 tests/qapi-schema/doc-missing.out  |  0
 10 files changed, 61 insertions(+), 14 deletions(-)
 create mode 100644 tests/qapi-schema/doc-missing.err
 create mode 100644 tests/qapi-schema/doc-missing.exit
 create mode 100644 tests/qapi-schema/doc-missing.json
 create mode 100644 tests/qapi-schema/doc-missing.out
docs/qapi-code-gen.txt +27 -13
index 9514d93..88de5c7 100644
@@ -117,10 +117,13 @@ Example:
 
 ==== Expression documentation ====
 
-Each expression that isn't an include directive must be preceded by a
+Each expression that isn't an include directive may be preceded by a
 documentation block.  Such blocks are called expression documentation
 blocks.
 
+When documentation is required (see pragma 'doc-required'), expression
+documentation blocks are mandatory.
+
 The documentation block consists of a first line naming the
 expression, an optional overview, a description of each argument (for
 commands and events) or member (for structs, unions and alternates),
@@ -204,17 +207,17 @@ once.  It is permissible for the schema to contain additional types
 not used by any commands or events in the Client JSON Protocol, for
 the side effect of generated C code used internally.
 
-There are seven top-level expressions recognized by the parser:
-'include', 'command', 'struct', 'enum', 'union', 'alternate', and
-'event'.  There are several groups of types: simple types (a number of
-built-in types, such as 'int' and 'str'; as well as enumerations),
-complex types (structs and two flavors of unions), and alternate types
-(a choice between other types).  The 'command' and 'event' expressions
-can refer to existing types by name, or list an anonymous type as a
-dictionary. Listing a type name inside an array refers to a
-single-dimension array of that type; multi-dimension arrays are not
-directly supported (although an array of a complex struct that
-contains an array member is possible).
+There are eight top-level expressions recognized by the parser:
+'include', 'pragma', 'command', 'struct', 'enum', 'union',
+'alternate', and 'event'.  There are several groups of types: simple
+types (a number of built-in types, such as 'int' and 'str'; as well as
+enumerations), complex types (structs and two flavors of unions), and
+alternate types (a choice between other types).  The 'command' and
+'event' expressions can refer to existing types by name, or list an
+anonymous type as a dictionary. Listing a type name inside an array
+refers to a single-dimension array of that type; multi-dimension
+arrays are not directly supported (although an array of a complex
+struct that contains an array member is possible).
 
 All names must begin with a letter, and contain only ASCII letters,
 digits, hyphen, and underscore.  There are two exceptions: enum values
@@ -282,7 +285,7 @@ The following types are predefined, and map to C as follows:
   QType     QType      JSON string matching enum QType values
 
 
-=== Includes ===
+=== Include directives ===
 
 Usage: { 'include': STRING }
 
@@ -302,6 +305,17 @@ an outer file.  The parser may be made stricter in the future to
 prevent incomplete include files.
 
 
+=== Pragma directives ===
+
+Usage: { 'pragma': DICT }
+
+The pragma directive lets you control optional generator behavior.
+The dictionary's entries are pragma names and values.
+
+Pragma 'doc-required' takes a boolean value.  If true, documentation
+is required.  Default is false.
+
+
 === Struct types ===
 
 Usage: { 'struct': STRING, 'data': DICT, '*base': STRUCT-NAME }
qapi-schema.json +2 -0
index 32b4a4b..d5438ee 100644
@@ -49,6 +49,8 @@
 #
 ##
 
+{ 'pragma': { 'doc-required': true } }
+
 # QAPI common definitions
 { 'include': 'qapi/common.json' }
 
qga/qapi-schema.json +2 -0
index d421609..3f3d428 100644
@@ -11,6 +11,8 @@
 #
 ##
 
+{ 'pragma': { 'doc-required': true } }
+
 ##
 # @guest-sync-delimited:
 #
scripts/qapi.py +19 -1
index 345cde1..29a8b77 100644
@@ -37,6 +37,9 @@ builtin_types = {
     'QType':    'QTYPE_QSTRING',
 }
 
+# Are documentation comments required?
+doc_required = False
+
 # Whitelist of commands allowed to return a non-dictionary
 returns_whitelist = [
     # From QMP:
@@ -277,6 +280,11 @@ class QAPISchemaParser(object):
                                        "Value of 'include' must be a string")
                 self._include(include, info, os.path.dirname(abs_fname),
                               previously_included)
+            elif "pragma" in expr:
+                if len(expr) != 1:
+                    raise QAPISemError(info, "Invalid 'pragma' directive")
+                for name, value in expr['pragma'].iteritems():
+                    self._pragma(name, value, info)
             else:
                 expr_elem = {'expr': expr,
                              'info': info}
@@ -308,6 +316,16 @@ class QAPISchemaParser(object):
         self.exprs.extend(exprs_include.exprs)
         self.docs.extend(exprs_include.docs)
 
+    def _pragma(self, name, value, info):
+        global doc_required
+        if name == 'doc-required':
+            if not isinstance(value, bool):
+                raise QAPISemError(info,
+                                   "Pragma 'doc-required' must be boolean")
+            doc_required = value
+        else:
+            raise QAPISemError(info, "Unknown pragma '%s'" % name)
+
     def accept(self, skip_comment=True):
         while True:
             self.tok = self.src[self.cursor]
@@ -863,7 +881,7 @@ def check_exprs(exprs):
         expr = expr_elem['expr']
         info = expr_elem['info']
 
-        if 'doc' not in expr_elem:
+        if 'doc' not in expr_elem and doc_required:
             raise QAPISemError(info,
                                "Expression missing documentation comment")
 
scripts/qapi2texi.py +3 -0
index 69f5edc..06d6abf 100755
@@ -254,6 +254,9 @@ def main(argv):
         sys.exit(1)
 
     schema = qapi.QAPISchema(argv[1])
+    if not qapi.doc_required:
+        print >>sys.stderr, ("%s: need pragma 'doc-required' "
+                             "to generate documentation" % argv[0])
     print texi(schema.docs)
 
 
tests/Makefile.include +1 -0
index 346345e..736dd15 100644
@@ -381,6 +381,7 @@ qapi-schema += doc-invalid-end2.json
 qapi-schema += doc-invalid-return.json
 qapi-schema += doc-invalid-section.json
 qapi-schema += doc-invalid-start.json
+qapi-schema += doc-missing.json
 qapi-schema += doc-missing-colon.json
 qapi-schema += doc-missing-expr.json
 qapi-schema += doc-missing-space.json
tests/qapi-schema/doc-missing.err new file +1 -0
new file mode 100644
index 0000000..7f2f326
@@ -0,0 +1 @@
+tests/qapi-schema/doc-missing.json:5: Expression missing documentation comment
tests/qapi-schema/doc-missing.exit new file +1 -0
new file mode 100644
index 0000000..d00491f
@@ -0,0 +1 @@
+1
tests/qapi-schema/doc-missing.json new file +5 -0
new file mode 100644
index 0000000..5956709
@@ -0,0 +1,5 @@
+# Expression documentation required
+
+{ 'pragma': { 'doc-required': true } }
+
+{ 'command': 'undocumented' }
tests/qapi-schema/doc-missing.out new file +0 -0
new file mode 100644
index 0000000..e69de29
Signature · 1 line
2.7.4
Reviewed-by on v1 2/47
#5 lore raw

Re: [Qemu-devel] [PATCH for-2.9 02/47] qapi: Make doc comments optional where we don't need them

Quoted 3 lines · Markus Armbruster

Since we added the documentation generator in commit 3313b61, doc comments are mandatory. That's a very good idea for a schema that needs to be documented, but has proven to be annoying for testing.

As I've found out while rebasing my JSON output visitor as well as patches to allow anonymous bases to flat unions. Thanks, this will help me!

Quoted 6 lines

Make doc comments optional again, but add a new directive

    { 'pragma': { 'doc-required': true } }

to let a QAPI schema require them.

I like it. It's extensible to other pragmas, as well; and reading ahead, it looks like you did a good job of flagging unknown pragmas.

Quoted 7 lines

Require documentation in the schemas we actually want documented:
qapi-schema.json and qga/qapi-schema.json.

We could probably make qapi2texi.py cope with incomplete documentation, but for now, simply make it refuse to run unless the schema has 'doc-required': true.

I'd rather fail early on our non-documented stuff then risk broken corner cases; so I think you made the right decision.

scripts/qapi.py class QAPISchemaParser(object): · line 285

Quoted 12 lines
---
 docs/qapi-code-gen.txt             | 40 +++++++++++++++++++++++++-------------
scripts/qapi.py +3 -0
@@ -277,6 +280,11 @@ class QAPISchemaParser(object):
                                        "Value of 'include' must be a string")
                 self._include(include, info, os.path.dirname(abs_fname),
                               previously_included)
+            elif "pragma" in expr:
+                if len(expr) != 1:
+                    raise QAPISemError(info, "Invalid 'pragma' directive")

You may also want to check that you have an actual dictionary; otherwise...

scripts/qapi.py class QAPISchemaParser(object): · line 286

Quoted 1 line
scripts/qapi.py +1 -0
+                for name, value in expr['pragma'].iteritems():

calling .iteritems() can lead to some funky python messages. For example, tweaking qapi-schema.json to use

{ 'pragma': [ { 'doc-required': true } ] }

=>

$ make
  GEN     qmp-commands.h
Traceback (most recent call last):
  File "/home/eblake/qemu/scripts/qapi-commands.py", line 317, in <module>
    schema = QAPISchema(input_file)
  File "/home/eblake/qemu/scripts/qapi.py", line 1496, in __init__
    parser = QAPISchemaParser(open(fname, "r"))
  File "/home/eblake/qemu/scripts/qapi.py", line 286, in __init__
    for name, value in expr['pragma'].iteritems():
AttributeError: 'list' object has no attribute 'iteritems'
Makefile:431: recipe for target 'qmp-commands.h' failed

Not the end of the world, but we've done a nice job elsewhere of avoiding cryptic python traces.

scripts/qapi.py class QAPISchemaParser(object): · line 325

Quoted 6 lines
scripts/qapi.py +6 -0
+        global doc_required
+        if name == 'doc-required':
+            if not isinstance(value, bool):
+                raise QAPISemError(info,
+                                   "Pragma 'doc-required' must be boolean")
+            doc_required = value

No testsuite coverage of this message?

If you decide to not bother, or to defer error message(s) cleanup to followups (especially since we are running short on time for fixing the actual doc regression from going into 2.9), then using this patch as-is can have:

Of course, if you spin a v2 that actually addresses my concerns, it probably will be more involved than something that can trivially keep my R-b (in part because you'll probably also want a testsuite addition to cover any new error message...).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#6 lore raw

Re: [Qemu-devel] [PATCH for-2.9 02/47] qapi: Make doc comments optional where we don't need them

Quoted 22 lines · Eric Blake
Quoted 3 lines · Markus Armbruster

Since we added the documentation generator in commit 3313b61, doc comments are mandatory. That's a very good idea for a schema that needs to be documented, but has proven to be annoying for testing.

As I've found out while rebasing my JSON output visitor as well as patches to allow anonymous bases to flat unions. Thanks, this will help me!

Quoted 6 lines

Make doc comments optional again, but add a new directive

    { 'pragma': { 'doc-required': true } }

to let a QAPI schema require them.

I like it. It's extensible to other pragmas, as well; and reading ahead, it looks like you did a good job of flagging unknown pragmas.

Quoted 4 lines

Require documentation in the schemas we actually want documented:
qapi-schema.json and qga/qapi-schema.json.

Quoted 6 lines
Quoted 3 lines

We could probably make qapi2texi.py cope with incomplete documentation, but for now, simply make it refuse to run unless the schema has 'doc-required': true.

I'd rather fail early on our non-documented stuff then risk broken corner cases; so I think you made the right decision.

I figure making qapi2texi.py robust wouldn't be hard, but decided not to try for 2.9.

Quoted 24 lines

scripts/qapi.py class QAPISchemaParser(object): · line 285

Quoted 12 lines
---
 docs/qapi-code-gen.txt             | 40 +++++++++++++++++++++++++-------------
scripts/qapi.py +3 -0
@@ -277,6 +280,11 @@ class QAPISchemaParser(object):
                                        "Value of 'include' must be a string")
                 self._include(include, info, os.path.dirname(abs_fname),
                               previously_included)
+            elif "pragma" in expr:
+                if len(expr) != 1:
+                    raise QAPISemError(info, "Invalid 'pragma' directive")

You may also want to check that you have an actual dictionary; otherwise...

scripts/qapi.py class QAPISchemaParser(object): · line 286

Quoted 1 line
scripts/qapi.py +1 -0
+                for name, value in expr['pragma'].iteritems():

calling .iteritems() can lead to some funky python messages. For example, tweaking qapi-schema.json to use

{ 'pragma': [ { 'doc-required': true } ] }

=>

Quoted 11 lines
$ make
  GEN     qmp-commands.h
Traceback (most recent call last):
  File "/home/eblake/qemu/scripts/qapi-commands.py", line 317, in <module>
    schema = QAPISchema(input_file)
  File "/home/eblake/qemu/scripts/qapi.py", line 1496, in __init__
    parser = QAPISchemaParser(open(fname, "r"))
  File "/home/eblake/qemu/scripts/qapi.py", line 286, in __init__
    for name, value in expr['pragma'].iteritems():
AttributeError: 'list' object has no attribute 'iteritems'
Makefile:431: recipe for target 'qmp-commands.h' failed

You're right. Need to decide whether to fix it in a respin or on top.

Quoted 11 lines

Not the end of the world, but we've done a nice job elsewhere of avoiding cryptic python traces.

scripts/qapi.py class QAPISchemaParser(object): · line 325

Quoted 6 lines
scripts/qapi.py +6 -0
+        global doc_required
+        if name == 'doc-required':
+            if not isinstance(value, bool):
+                raise QAPISemError(info,
+                                   "Pragma 'doc-required' must be boolean")
+            doc_required = value

No testsuite coverage of this message?

Not yet, i.e. you're right, test coverage is advisable even for exotic stuff that's expected not to change like pragma.

Quoted 6 lines

If you decide to not bother, or to defer error message(s) cleanup to followups (especially since we are running short on time for fixing the actual doc regression from going into 2.9), then using this patch as-is can have:

Thanks!

Quoted 4 lines

Of course, if you spin a v2 that actually addresses my concerns, it probably will be more involved than something that can trivially keep my R-b (in part because you'll probably also want a testsuite addition to cover any new error message...).

Possible :)

#7 lore raw

PATCH 3/47 qapi: Back out doc comments added just to please qapi.py

In reply to Markus Armbruster

This reverts commit 3313b61's changes to tests/qapi-schema/, except for tests/qapi-schema/doc-*.

---
 tests/qapi-schema/alternate-any.err                |   2 +-
 tests/qapi-schema/alternate-any.json               |   4 -
 tests/qapi-schema/alternate-array.err              |   2 +-
 tests/qapi-schema/alternate-array.json             |   7 -
 tests/qapi-schema/alternate-base.err               |   2 +-
 tests/qapi-schema/alternate-base.json              |   7 -
 tests/qapi-schema/alternate-clash.err              |   2 +-
 tests/qapi-schema/alternate-clash.json             |   4 -
 tests/qapi-schema/alternate-conflict-dict.err      |   2 +-
 tests/qapi-schema/alternate-conflict-dict.json     |  10 -
 tests/qapi-schema/alternate-conflict-string.err    |   2 +-
 tests/qapi-schema/alternate-conflict-string.json   |   7 -
 tests/qapi-schema/alternate-empty.err              |   2 +-
 tests/qapi-schema/alternate-empty.json             |   4 -
 tests/qapi-schema/alternate-nested.err             |   2 +-
 tests/qapi-schema/alternate-nested.json            |   7 -
 tests/qapi-schema/alternate-unknown.err            |   2 +-
 tests/qapi-schema/alternate-unknown.json           |   4 -
 tests/qapi-schema/args-alternate.err               |   2 +-
 tests/qapi-schema/args-alternate.json              |   8 -
 tests/qapi-schema/args-any.err                     |   2 +-
 tests/qapi-schema/args-any.json                    |   4 -
 tests/qapi-schema/args-array-empty.err             |   2 +-
 tests/qapi-schema/args-array-empty.json            |   4 -
 tests/qapi-schema/args-array-unknown.err           |   2 +-
 tests/qapi-schema/args-array-unknown.json          |   4 -
 tests/qapi-schema/args-bad-boxed.err               |   2 +-
 tests/qapi-schema/args-bad-boxed.json              |   4 -
 tests/qapi-schema/args-boxed-anon.err              |   2 +-
 tests/qapi-schema/args-boxed-anon.json             |   4 -
 tests/qapi-schema/args-boxed-empty.err             |   2 +-
 tests/qapi-schema/args-boxed-empty.json            |   8 -
 tests/qapi-schema/args-boxed-string.err            |   2 +-
 tests/qapi-schema/args-boxed-string.json           |   4 -
 tests/qapi-schema/args-int.err                     |   2 +-
 tests/qapi-schema/args-int.json                    |   4 -
 tests/qapi-schema/args-invalid.err                 |   2 +-
 tests/qapi-schema/args-invalid.json                |   3 -
 tests/qapi-schema/args-member-array-bad.err        |   2 +-
 tests/qapi-schema/args-member-array-bad.json       |   4 -
 tests/qapi-schema/args-member-case.err             |   2 +-
 tests/qapi-schema/args-member-case.json            |   4 -
 tests/qapi-schema/args-member-unknown.err          |   2 +-
 tests/qapi-schema/args-member-unknown.json         |   4 -
 tests/qapi-schema/args-name-clash.err              |   2 +-
 tests/qapi-schema/args-name-clash.json             |   4 -
 tests/qapi-schema/args-union.err                   |   2 +-
 tests/qapi-schema/args-union.json                  |   7 -
 tests/qapi-schema/args-unknown.err                 |   2 +-
 tests/qapi-schema/args-unknown.json                |   4 -
 tests/qapi-schema/bad-base.err                     |   2 +-
 tests/qapi-schema/bad-base.json                    |   7 -
 tests/qapi-schema/bad-data.err                     |   2 +-
 tests/qapi-schema/bad-data.json                    |   4 -
 tests/qapi-schema/bad-ident.err                    |   2 +-
 tests/qapi-schema/bad-ident.json                   |   4 -
 tests/qapi-schema/bad-type-bool.err                |   2 +-
 tests/qapi-schema/bad-type-bool.json               |   4 -
 tests/qapi-schema/bad-type-dict.err                |   2 +-
 tests/qapi-schema/bad-type-dict.json               |   4 -
 tests/qapi-schema/base-cycle-direct.err            |   2 +-
 tests/qapi-schema/base-cycle-direct.json           |   4 -
 tests/qapi-schema/base-cycle-indirect.err          |   2 +-
 tests/qapi-schema/base-cycle-indirect.json         |   7 -
 tests/qapi-schema/command-int.err                  |   2 +-
 tests/qapi-schema/command-int.json                 |   4 -
 tests/qapi-schema/comments.json                    |   4 -
 tests/qapi-schema/comments.out                     |   1 -
 tests/qapi-schema/double-type.err                  |   2 +-
 tests/qapi-schema/double-type.json                 |   4 -
 tests/qapi-schema/enum-bad-name.err                |   2 +-
 tests/qapi-schema/enum-bad-name.json               |   4 -
 tests/qapi-schema/enum-bad-prefix.err              |   2 +-
 tests/qapi-schema/enum-bad-prefix.json             |   4 -
 tests/qapi-schema/enum-clash-member.err            |   2 +-
 tests/qapi-schema/enum-clash-member.json           |   4 -
 tests/qapi-schema/enum-dict-member.err             |   2 +-
 tests/qapi-schema/enum-dict-member.json            |   4 -
 tests/qapi-schema/enum-member-case.err             |   2 +-
 tests/qapi-schema/enum-member-case.json            |   7 -
 tests/qapi-schema/enum-missing-data.err            |   2 +-
 tests/qapi-schema/enum-missing-data.json           |   4 -
 tests/qapi-schema/enum-wrong-data.err              |   2 +-
 tests/qapi-schema/enum-wrong-data.json             |   4 -
 tests/qapi-schema/event-boxed-empty.err            |   2 +-
 tests/qapi-schema/event-boxed-empty.json           |   4 -
 tests/qapi-schema/event-case.json                  |   4 -
 tests/qapi-schema/event-case.out                   |   1 -
 tests/qapi-schema/event-nest-struct.err            |   2 +-
 tests/qapi-schema/event-nest-struct.json           |   4 -
 tests/qapi-schema/flat-union-array-branch.err      |   2 +-
 tests/qapi-schema/flat-union-array-branch.json     |  12 --
 tests/qapi-schema/flat-union-bad-base.err          |   2 +-
 tests/qapi-schema/flat-union-bad-base.json         |  13 --
 tests/qapi-schema/flat-union-bad-discriminator.err |   2 +-
 .../qapi-schema/flat-union-bad-discriminator.json  |  16 --
 tests/qapi-schema/flat-union-base-any.err          |   2 +-
 tests/qapi-schema/flat-union-base-any.json         |  13 --
 tests/qapi-schema/flat-union-base-union.err        |   2 +-
 tests/qapi-schema/flat-union-base-union.json       |  16 --
 tests/qapi-schema/flat-union-clash-member.err      |   2 +-
 tests/qapi-schema/flat-union-clash-member.json     |  16 --
 tests/qapi-schema/flat-union-empty.err             |   2 +-
 tests/qapi-schema/flat-union-empty.json            |  10 -
 tests/qapi-schema/flat-union-incomplete-branch.err |   2 +-
 .../qapi-schema/flat-union-incomplete-branch.json  |  10 -
 tests/qapi-schema/flat-union-inline.err            |   2 +-
 tests/qapi-schema/flat-union-inline.json           |  10 -
 tests/qapi-schema/flat-union-int-branch.err        |   2 +-
 tests/qapi-schema/flat-union-int-branch.json       |  13 --
 .../qapi-schema/flat-union-invalid-branch-key.err  |   2 +-
 .../qapi-schema/flat-union-invalid-branch-key.json |  15 --
 .../flat-union-invalid-discriminator.err           |   2 +-
 .../flat-union-invalid-discriminator.json          |  15 --
 tests/qapi-schema/flat-union-no-base.err           |   2 +-
 tests/qapi-schema/flat-union-no-base.json          |  13 --
 .../flat-union-optional-discriminator.err          |   2 +-
 .../flat-union-optional-discriminator.json         |  13 --
 .../flat-union-string-discriminator.err            |   2 +-
 .../flat-union-string-discriminator.json           |  15 --
 tests/qapi-schema/ident-with-escape.json           |   4 -
 tests/qapi-schema/ident-with-escape.out            |   1 -
 tests/qapi-schema/include-relpath-sub.json         |   3 -
 tests/qapi-schema/include-relpath.out              |   1 -
 tests/qapi-schema/include-repetition.out           |   1 -
 tests/qapi-schema/include-simple-sub.json          |   3 -
 tests/qapi-schema/include-simple.out               |   1 -
 tests/qapi-schema/indented-expr.json               |   6 -
 tests/qapi-schema/indented-expr.out                |   2 -
 tests/qapi-schema/missing-type.err                 |   2 +-
 tests/qapi-schema/missing-type.json                |   4 -
 tests/qapi-schema/nested-struct-data.err           |   2 +-
 tests/qapi-schema/nested-struct-data.json          |   4 -
 tests/qapi-schema/qapi-schema-test.json            | 213 ---------------------
 tests/qapi-schema/qapi-schema-test.out             | 130 -------------
 tests/qapi-schema/redefined-builtin.err            |   2 +-
 tests/qapi-schema/redefined-builtin.json           |   4 -
 tests/qapi-schema/redefined-command.err            |   2 +-
 tests/qapi-schema/redefined-command.json           |   7 -
 tests/qapi-schema/redefined-event.err              |   2 +-
 tests/qapi-schema/redefined-event.json             |   7 -
 tests/qapi-schema/redefined-type.err               |   2 +-
 tests/qapi-schema/redefined-type.json              |   7 -
 tests/qapi-schema/reserved-command-q.err           |   2 +-
 tests/qapi-schema/reserved-command-q.json          |   7 -
 tests/qapi-schema/reserved-enum-q.err              |   2 +-
 tests/qapi-schema/reserved-enum-q.json             |   4 -
 tests/qapi-schema/reserved-member-has.err          |   2 +-
 tests/qapi-schema/reserved-member-has.json         |   4 -
 tests/qapi-schema/reserved-member-q.err            |   2 +-
 tests/qapi-schema/reserved-member-q.json           |   4 -
 tests/qapi-schema/reserved-member-u.err            |   2 +-
 tests/qapi-schema/reserved-member-u.json           |   4 -
 tests/qapi-schema/reserved-member-underscore.err   |   2 +-
 tests/qapi-schema/reserved-member-underscore.json  |   4 -
 tests/qapi-schema/reserved-type-kind.err           |   2 +-
 tests/qapi-schema/reserved-type-kind.json          |   4 -
 tests/qapi-schema/reserved-type-list.err           |   2 +-
 tests/qapi-schema/reserved-type-list.json          |   4 -
 tests/qapi-schema/returns-alternate.err            |   2 +-
 tests/qapi-schema/returns-alternate.json           |   7 -
 tests/qapi-schema/returns-array-bad.err            |   2 +-
 tests/qapi-schema/returns-array-bad.json           |   4 -
 tests/qapi-schema/returns-dict.err                 |   2 +-
 tests/qapi-schema/returns-dict.json                |   4 -
 tests/qapi-schema/returns-unknown.err              |   2 +-
 tests/qapi-schema/returns-unknown.json             |   4 -
 tests/qapi-schema/returns-whitelist.err            |   2 +-
 tests/qapi-schema/returns-whitelist.json           |  16 --
 tests/qapi-schema/struct-base-clash-deep.err       |   2 +-
 tests/qapi-schema/struct-base-clash-deep.json      |  10 -
 tests/qapi-schema/struct-base-clash.err            |   2 +-
 tests/qapi-schema/struct-base-clash.json           |   7 -
 tests/qapi-schema/struct-data-invalid.err          |   2 +-
 tests/qapi-schema/struct-data-invalid.json         |   3 -
 tests/qapi-schema/struct-member-invalid.err        |   2 +-
 tests/qapi-schema/struct-member-invalid.json       |   3 -
 tests/qapi-schema/test-qapi.py                     |  14 --
 tests/qapi-schema/type-bypass-bad-gen.err          |   2 +-
 tests/qapi-schema/type-bypass-bad-gen.json         |   4 -
 tests/qapi-schema/unicode-str.err                  |   2 +-
 tests/qapi-schema/unicode-str.json                 |   4 -
 tests/qapi-schema/union-base-no-discriminator.err  |   2 +-
 tests/qapi-schema/union-base-no-discriminator.json |  12 --
 tests/qapi-schema/union-branch-case.err            |   2 +-
 tests/qapi-schema/union-branch-case.json           |   4 -
 tests/qapi-schema/union-clash-branches.err         |   2 +-
 tests/qapi-schema/union-clash-branches.json        |   4 -
 tests/qapi-schema/union-empty.err                  |   2 +-
 tests/qapi-schema/union-empty.json                 |   4 -
 tests/qapi-schema/union-invalid-base.err           |   2 +-
 tests/qapi-schema/union-invalid-base.json          |  10 -
 tests/qapi-schema/union-optional-branch.err        |   2 +-
 tests/qapi-schema/union-optional-branch.json       |   4 -
 tests/qapi-schema/union-unknown.err                |   2 +-
 tests/qapi-schema/union-unknown.json               |   4 -
 tests/qapi-schema/unknown-escape.err               |   2 +-
 tests/qapi-schema/unknown-escape.json              |   4 -
 tests/qapi-schema/unknown-expr-key.err             |   2 +-
 tests/qapi-schema/unknown-expr-key.json            |   4 -
 200 files changed, 92 insertions(+), 1074 deletions(-)
tests/qapi-schema/alternate-any.err +1 -1
index 395c8ab..aaa0154 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-any.json:6: Alternate 'Alt' member 'one' cannot use type 'any'
+tests/qapi-schema/alternate-any.json:2: Alternate 'Alt' member 'one' cannot use type 'any'
tests/qapi-schema/alternate-any.json +0 -4
index c958776..e47a73a 100644
@@ -1,8 +1,4 @@
 # we do not allow the 'any' type as an alternate branch
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'any',
             'two': 'int' } }
tests/qapi-schema/alternate-array.err +1 -1
index 09628e9..7b930c6 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-array.json:12: Member 'two' of alternate 'Alt' cannot be an array
+tests/qapi-schema/alternate-array.json:5: Member 'two' of alternate 'Alt' cannot be an array
tests/qapi-schema/alternate-array.json +0 -7
index c2f98ad..f241aac 100644
@@ -1,14 +1,7 @@
 # we do not allow array branches in alternates
-
-##
-# @One:
-##
 # TODO: should we support this?
 { 'struct': 'One',
   'data': { 'name': 'str' } }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'One',
             'two': [ 'int' ] } }
tests/qapi-schema/alternate-base.err +1 -1
index 3b67914..30d8a34 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-base.json:11: Unknown key 'base' in alternate 'Alt'
+tests/qapi-schema/alternate-base.json:4: Unknown key 'base' in alternate 'Alt'
tests/qapi-schema/alternate-base.json +0 -7
index 9612b79..529430ec 100644
@@ -1,13 +1,6 @@
 # we reject alternate with base type
-
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'string': 'str' } }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'base': 'Base',
   'data': { 'number': 'int' } }
tests/qapi-schema/alternate-clash.err +1 -1
index f07c3e8..604d849 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-clash.json:11: 'a_b' (branch of Alt1) collides with 'a-b' (branch of Alt1)
+tests/qapi-schema/alternate-clash.json:7: 'a_b' (branch of Alt1) collides with 'a-b' (branch of Alt1)
tests/qapi-schema/alternate-clash.json +0 -4
index 97ca7c8..6d73bc5 100644
@@ -4,9 +4,5 @@
 # TODO: In the future, if alternates are simplified to not generate
 # the implicit Alt1Kind enum, we would still have a collision with the
 # resulting C union trying to have two members named 'a_b'.
-
-##
-# @Alt1:
-##
 { 'alternate': 'Alt1',
   'data': { 'a-b': 'str', 'a_b': 'int' } }
tests/qapi-schema/alternate-conflict-dict.err +1 -1
index 7cb023f..0f411f4 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-conflict-dict.json:16: Alternate 'Alt' member 'two' can't be distinguished from member 'one'
+tests/qapi-schema/alternate-conflict-dict.json:6: Alternate 'Alt' member 'two' can't be distinguished from member 'one'
tests/qapi-schema/alternate-conflict-dict.json +0 -10
index 9f9d97f..d566cca 100644
@@ -1,18 +1,8 @@
 # we reject alternates with multiple object branches
-
-##
-# @One:
-##
 { 'struct': 'One',
   'data': { 'name': 'str' } }
-##
-# @Two:
-##
 { 'struct': 'Two',
   'data': { 'value': 'int' } }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'One',
             'two': 'Two' } }
tests/qapi-schema/alternate-conflict-string.err +1 -1
index 6dbbacd..fc523b0 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-conflict-string.json:11: Alternate 'Alt' member 'two' can't be distinguished from member 'one'
+tests/qapi-schema/alternate-conflict-string.json:4: Alternate 'Alt' member 'two' can't be distinguished from member 'one'
tests/qapi-schema/alternate-conflict-string.json +0 -7
index 12aafab..72f04a8 100644
@@ -1,13 +1,6 @@
 # we reject alternates with multiple string-like branches
-
-##
-# @Enum:
-##
 { 'enum': 'Enum',
   'data': [ 'hello', 'world' ] }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'str',
             'two': 'Enum' } }
tests/qapi-schema/alternate-empty.err +1 -1
index 8245ce3..bb06c5b 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-empty.json:6: Alternate 'Alt' should have at least two branches in 'data'
+tests/qapi-schema/alternate-empty.json:2: Alternate 'Alt' should have at least two branches in 'data'
tests/qapi-schema/alternate-empty.json +0 -4
index db54405..fff15ba 100644
@@ -1,6 +1,2 @@
 # alternates must list at least two types to be useful
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt', 'data': { 'i': 'int' } }
tests/qapi-schema/alternate-nested.err +1 -1
index 1804ffb..4d1187e 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-nested.json:11: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1'
+tests/qapi-schema/alternate-nested.json:4: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1'
tests/qapi-schema/alternate-nested.json +0 -7
index 9f83ebe..8e22186 100644
@@ -1,12 +1,5 @@
 # we reject a nested alternate branch
-
-##
-# @Alt1:
-##
 { 'alternate': 'Alt1',
   'data': { 'name': 'str', 'value': 'int' } }
-##
-# @Alt2:
-##
 { 'alternate': 'Alt2',
   'data': { 'nested': 'Alt1', 'b': 'bool' } }
tests/qapi-schema/alternate-unknown.err +1 -1
index cf5b9b6..dea45dc 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-unknown.json:6: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType'
+tests/qapi-schema/alternate-unknown.json:2: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType'
tests/qapi-schema/alternate-unknown.json +0 -4
index 941ba1f..08c80dc 100644
@@ -1,7 +1,3 @@
 # we reject an alternate with unknown type in branch
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'unknown': 'MissingType', 'i': 'int' } }
tests/qapi-schema/args-alternate.err +1 -1
index 2e6bf54..3086eae 100644
@@ -1 +1 @@
-tests/qapi-schema/args-alternate.json:11: 'data' for command 'oops' cannot use alternate type 'Alt'
+tests/qapi-schema/args-alternate.json:3: 'data' for command 'oops' cannot use alternate type 'Alt'
tests/qapi-schema/args-alternate.json +0 -8
index 49d0211..69e94d4 100644
@@ -1,11 +1,3 @@
 # we do not allow alternate arguments
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'str' } }
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'Alt' }
tests/qapi-schema/args-any.err +1 -1
index 955504b..bf9b5e0 100644
@@ -1 +1 @@
-tests/qapi-schema/args-any.json:6: 'data' for command 'oops' cannot use built-in type 'any'
+tests/qapi-schema/args-any.json:2: 'data' for command 'oops' cannot use built-in type 'any'
tests/qapi-schema/args-any.json +0 -4
index f494479..58fe5e4 100644
@@ -1,6 +1,2 @@
 # we do not allow an 'any' argument
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'any' }
tests/qapi-schema/args-array-empty.err +1 -1
index e85f791..cb7ed33 100644
@@ -1 +1 @@
-tests/qapi-schema/args-array-empty.json:6: Member 'empty' of 'data' for command 'oops': array type must contain single type name
+tests/qapi-schema/args-array-empty.json:2: Member 'empty' of 'data' for command 'oops': array type must contain single type name
tests/qapi-schema/args-array-empty.json +0 -4
index 78a0b88..652dcfb 100644
@@ -1,6 +1,2 @@
 # we reject an array for data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'empty': [ ] } }
tests/qapi-schema/args-array-unknown.err +1 -1
index 77788de..cd7a0f9 100644
@@ -1 +1 @@
-tests/qapi-schema/args-array-unknown.json:6: Member 'array' of 'data' for command 'oops' uses unknown type 'NoSuchType'
+tests/qapi-schema/args-array-unknown.json:2: Member 'array' of 'data' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/args-array-unknown.json +0 -4
index f680fc1..6f3e883 100644
@@ -1,6 +1,2 @@
 # we reject an array for data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'array': [ 'NoSuchType' ] } }
tests/qapi-schema/args-bad-boxed.err +1 -1
index 87a9061..ad0d417 100644
@@ -1 +1 @@
-tests/qapi-schema/args-bad-boxed.json:6: 'boxed' of command 'foo' should only use true value
+tests/qapi-schema/args-bad-boxed.json:2: 'boxed' of command 'foo' should only use true value
tests/qapi-schema/args-bad-boxed.json +0 -4
index 4c0b28f..dea0cd0 100644
@@ -1,6 +1,2 @@
 # 'boxed' should only appear with value true
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': false }
tests/qapi-schema/args-boxed-anon.err +1 -1
index 3cfac0b..f24f345 100644
@@ -1 +1 @@
-tests/qapi-schema/args-boxed-anon.json:6: 'data' for command 'foo' should be a type name
+tests/qapi-schema/args-boxed-anon.json:2: 'data' for command 'foo' should be a type name
tests/qapi-schema/args-boxed-anon.json +0 -4
index 2358e6a..95f60da 100644
@@ -1,6 +1,2 @@
 # 'boxed' can only be used with named types
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': true, 'data': { 'string': 'str' } }
tests/qapi-schema/args-boxed-empty.err +1 -1
index 963f495..039603e 100644
@@ -1 +1 @@
-tests/qapi-schema/args-boxed-empty.json:11: Cannot use 'boxed' with empty type
+tests/qapi-schema/args-boxed-empty.json:3: Cannot use 'boxed' with empty type
tests/qapi-schema/args-boxed-empty.json +0 -8
index 8e8cc26..52717e0 100644
@@ -1,11 +1,3 @@
 # 'boxed' requires a non-empty type
-
-##
-# @Empty:
-##
 { 'struct': 'Empty', 'data': {} }
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': true, 'data': 'Empty' }
tests/qapi-schema/args-boxed-string.err +1 -1
index 7623755..d326b48 100644
@@ -1 +1 @@
-tests/qapi-schema/args-boxed-string.json:6: 'data' for command 'foo' cannot use built-in type 'str'
+tests/qapi-schema/args-boxed-string.json:2: 'data' for command 'foo' cannot use built-in type 'str'
tests/qapi-schema/args-boxed-string.json +0 -4
index aecdf97..f91a150 100644
@@ -1,6 +1,2 @@
 # 'boxed' requires a complex (not built-in) type
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': true, 'data': 'str' }
tests/qapi-schema/args-int.err +1 -1
index 38b3202..dc1d250 100644
@@ -1 +1 @@
-tests/qapi-schema/args-int.json:6: 'data' for command 'oops' cannot use built-in type 'int'
+tests/qapi-schema/args-int.json:2: 'data' for command 'oops' cannot use built-in type 'int'
tests/qapi-schema/args-int.json +0 -4
index 7f4e1b7..a334d92 100644
@@ -1,6 +1,2 @@
 # we reject commands where data is not an array or complex type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'int' }
tests/qapi-schema/args-invalid.err +1 -1
index 5d3568d..fe1e949 100644
@@ -1 +1 @@
-tests/qapi-schema/args-invalid.json:4: 'data' for command 'foo' should be a dictionary or type name
+tests/qapi-schema/args-invalid.json:1: 'data' for command 'foo' should be a dictionary or type name
tests/qapi-schema/args-invalid.json +0 -3
index 1a7e63b..db09813 100644
@@ -1,5 +1,2 @@
-##
-# @foo:
-##
 { 'command': 'foo',
   'data': false }
tests/qapi-schema/args-member-array-bad.err +1 -1
index 825ffca..881b4d9 100644
@@ -1 +1 @@
-tests/qapi-schema/args-member-array-bad.json:6: Member 'member' of 'data' for command 'oops': array type must contain single type name
+tests/qapi-schema/args-member-array-bad.json:2: Member 'member' of 'data' for command 'oops': array type must contain single type name
tests/qapi-schema/args-member-array-bad.json +0 -4
index e934f5c..b2ff144 100644
@@ -1,6 +1,2 @@
 # we reject data if it does not contain a valid array type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'member': [ { 'nested': 'str' } ] } }
tests/qapi-schema/args-member-case.err +1 -1
index a3fb2bd..19c4426 100644
@@ -1 +1 @@
-tests/qapi-schema/args-member-case.json:6: 'Arg' (parameter of no-way-this-will-get-whitelisted) should not use uppercase
+tests/qapi-schema/args-member-case.json:2: 'Arg' (parameter of no-way-this-will-get-whitelisted) should not use uppercase
tests/qapi-schema/args-member-case.json +0 -4
index 811e658..93439be 100644
@@ -1,6 +1,2 @@
 # Member names should be 'lower-case' unless the struct/command is whitelisted
-
-##
-# @no-way-this-will-get-whitelisted:
-##
 { 'command': 'no-way-this-will-get-whitelisted', 'data': { 'Arg': 'int' } }
tests/qapi-schema/args-member-unknown.err +1 -1
index 3db452b..f6f8282 100644
@@ -1 +1 @@
-tests/qapi-schema/args-member-unknown.json:6: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType'
+tests/qapi-schema/args-member-unknown.json:2: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/args-member-unknown.json +0 -4
index e2fef9c..342a41e 100644
@@ -1,6 +1,2 @@
 # we reject data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'member': 'NoSuchType' } }
tests/qapi-schema/args-name-clash.err +1 -1
index 23988cb..d953e8d 100644
@@ -1 +1 @@
-tests/qapi-schema/args-name-clash.json:8: 'a_b' (parameter of oops) collides with 'a-b' (parameter of oops)
+tests/qapi-schema/args-name-clash.json:4: 'a_b' (parameter of oops) collides with 'a-b' (parameter of oops)
tests/qapi-schema/args-name-clash.json +0 -4
index 991323b..61423cb 100644
@@ -1,8 +1,4 @@
 # C member name collision
 # Reject members that clash when mapped to C names (we would have two 'a_b'
 # members).
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'a-b': 'str', 'a_b': 'str' } }
tests/qapi-schema/args-union.err +1 -1
index ce0a34e..f8ad223 100644
@@ -1 +1 @@
-tests/qapi-schema/args-union.json:10: 'data' for command 'oops' cannot use union type 'Uni'
+tests/qapi-schema/args-union.json:3: 'data' for command 'oops' cannot use union type 'Uni'
tests/qapi-schema/args-union.json +0 -7
index 57284b4..2fcaeaa 100644
@@ -1,10 +1,3 @@
 # use of union arguments requires 'boxed':true
-
-##
-# @Uni:
-##
 { 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } }
-##
-# oops:
-##
 { 'command': 'oops', 'data': 'Uni' }
tests/qapi-schema/args-unknown.err +1 -1
index ba6c6cf..4d91ec8 100644
@@ -1 +1 @@
-tests/qapi-schema/args-unknown.json:6: 'data' for command 'oops' uses unknown type 'NoSuchType'
+tests/qapi-schema/args-unknown.json:2: 'data' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/args-unknown.json +0 -4
index 12666dc..32aba43 100644
@@ -1,6 +1,2 @@
 # we reject data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'NoSuchType' }
tests/qapi-schema/bad-base.err +1 -1
index e668761..154274b 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-base.json:10: 'base' for struct 'MyType' cannot use union type 'Union'
+tests/qapi-schema/bad-base.json:3: 'base' for struct 'MyType' cannot use union type 'Union'
tests/qapi-schema/bad-base.json +0 -7
index c3faa82..a634331 100644
@@ -1,10 +1,3 @@
 # we reject a base that is not a struct
-
-##
-# @Union:
-##
 { 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } }
-##
-# @MyType:
-##
 { 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
tests/qapi-schema/bad-data.err +1 -1
index c1b9e35..8523ac4 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-data.json:6: 'data' for command 'oops' cannot be an array
+tests/qapi-schema/bad-data.json:2: 'data' for command 'oops' cannot be an array
tests/qapi-schema/bad-data.json +0 -4
index 51c444f..832eeb7 100644
@@ -1,6 +1,2 @@
 # we ensure 'data' is a dictionary for all but enums
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': [ ] }
tests/qapi-schema/bad-ident.err +1 -1
index b757aa2..c419060 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-ident.json:6: 'struct' does not allow optional name '*oops'
+tests/qapi-schema/bad-ident.json:2: 'struct' does not allow optional name '*oops'
tests/qapi-schema/bad-ident.json +0 -4
index b43df7a..763627a 100644
@@ -1,6 +1,2 @@
 # we reject creating a type name with bad name
-
-##
-# @*oops:
-##
 { 'struct': '*oops', 'data': { 'i': 'int' } }
tests/qapi-schema/bad-type-bool.err +1 -1
index 72e026b..62fd70b 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-type-bool.json:6: 'struct' key must have a string value
+tests/qapi-schema/bad-type-bool.json:2: 'struct' key must have a string value
tests/qapi-schema/bad-type-bool.json +0 -4
index 1f9eddf..bde17b5 100644
@@ -1,6 +1,2 @@
 # we reject an expression with a metatype that is not a string
-
-##
-# @true:
-##
 { 'struct': true, 'data': { } }
tests/qapi-schema/bad-type-dict.err +1 -1
index d0d1f60..0b2a2ae 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-type-dict.json:6: 'command' key must have a string value
+tests/qapi-schema/bad-type-dict.json:2: 'command' key must have a string value
tests/qapi-schema/bad-type-dict.json +0 -4
index 5952caa..2a91b24 100644
@@ -1,6 +1,2 @@
 # we reject an expression with a metatype that is not a string
-
-##
-# @foo:
-##
 { 'command': { } }
tests/qapi-schema/base-cycle-direct.err +1 -1
index dd7f5aa..9c68f65 100644
@@ -1 +1 @@
-tests/qapi-schema/base-cycle-direct.json:6: Object Loopy contains itself
+tests/qapi-schema/base-cycle-direct.json:2: Object Loopy contains itself
tests/qapi-schema/base-cycle-direct.json +0 -4
index 9780f7e..4fc66d0 100644
@@ -1,6 +1,2 @@
 # we reject a loop in base classes
-
-##
-# @Loopy:
-##
 { 'struct': 'Loopy', 'base': 'Loopy', 'data': {} }
tests/qapi-schema/base-cycle-indirect.err +1 -1
index f4198e4..fc92fe4 100644
@@ -1 +1 @@
-tests/qapi-schema/base-cycle-indirect.json:6: Object Base1 contains itself
+tests/qapi-schema/base-cycle-indirect.json:2: Object Base1 contains itself
tests/qapi-schema/base-cycle-indirect.json +0 -7
index 99926c4..2866772 100644
@@ -1,10 +1,3 @@
 # we reject a loop in base classes
-
-##
-# @Base1:
-##
 { 'struct': 'Base1', 'base': 'Base2', 'data': {} }
-##
-# @Base2:
-##
 { 'struct': 'Base2', 'base': 'Base1', 'data': {} }
tests/qapi-schema/command-int.err +1 -1
index 3c834a9..0f93006 100644
@@ -1 +1 @@
-tests/qapi-schema/command-int.json:6: built-in 'int' is already defined
+tests/qapi-schema/command-int.json:2: built-in 'int' is already defined
tests/qapi-schema/command-int.json +0 -4
index 5b51bf1..9a62554 100644
@@ -1,6 +1,2 @@
 # we reject collisions between commands and types
-
-##
-# @int:
-##
 { 'command': 'int', 'data': { 'character': 'str' } }
tests/qapi-schema/comments.json +0 -4
index d31ef0d..e643f3a 100644
@@ -1,8 +1,4 @@
 # Unindented comment
-
-##
-# @Status:
-##
 { 'enum': 'Status',             # Comment to the right of code
   # Indented comment
   'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/comments.out +0 -1
index a962fb2..5d7c13c 100644
@@ -2,4 +2,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
-doc symbol=Status expr=('enum', 'Status')
tests/qapi-schema/double-type.err +1 -1
index 424df9b..f9613c6 100644
@@ -1 +1 @@
-tests/qapi-schema/double-type.json:6: Unknown key 'command' in struct 'bar'
+tests/qapi-schema/double-type.json:2: Unknown key 'command' in struct 'bar'
tests/qapi-schema/double-type.json +0 -4
index ab59523..911fa7a 100644
@@ -1,6 +1,2 @@
 # we reject an expression with ambiguous metatype
-
-##
-# @foo:
-##
 { 'command': 'foo', 'struct': 'bar', 'data': { } }
tests/qapi-schema/enum-bad-name.err +1 -1
index 157d1b0..9c3c100 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-bad-name.json:6: Member of enum 'MyEnum' uses invalid name 'not^possible'
+tests/qapi-schema/enum-bad-name.json:2: Member of enum 'MyEnum' uses invalid name 'not^possible'
tests/qapi-schema/enum-bad-name.json +0 -4
index 978cb88..8506562 100644
@@ -1,6 +1,2 @@
 # we ensure all enum names can map to C
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ 'not^possible' ] }
tests/qapi-schema/enum-bad-prefix.err +1 -1
index 918915f..399f5f7 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-bad-prefix.json:6: Enum 'MyEnum' requires a string for 'prefix'
+tests/qapi-schema/enum-bad-prefix.json:2: Enum 'MyEnum' requires a string for 'prefix'
tests/qapi-schema/enum-bad-prefix.json +0 -4
index 25f17a7..996f628 100644
@@ -1,6 +1,2 @@
 # The prefix must be a string type
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ 'one' ], 'prefix': [ 'fish' ] }
tests/qapi-schema/enum-clash-member.err +1 -1
index 25249b6..5403c78 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-clash-member.json:6: 'one_two' (member of MyEnum) collides with 'one-two' (member of MyEnum)
+tests/qapi-schema/enum-clash-member.json:2: 'one_two' (member of MyEnum) collides with 'one-two' (member of MyEnum)
tests/qapi-schema/enum-clash-member.json +0 -4
index fd52751..b6928b8 100644
@@ -1,6 +1,2 @@
 # we reject enums where members will clash when mapped to C enum
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ 'one-two', 'one_two' ] }
tests/qapi-schema/enum-dict-member.err +1 -1
index 9b7d2f1..8ca146e 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-dict-member.json:6: Member of enum 'MyEnum' requires a string name
+tests/qapi-schema/enum-dict-member.json:2: Member of enum 'MyEnum' requires a string name
tests/qapi-schema/enum-dict-member.json +0 -4
index 69d30f0..79672e0 100644
@@ -1,6 +1,2 @@
 # we reject any enum member that is not a string
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] }
tests/qapi-schema/enum-member-case.err +1 -1
index df96e22..b652e9a 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-member-case.json:10: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase
+tests/qapi-schema/enum-member-case.json:3: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase
tests/qapi-schema/enum-member-case.json +0 -7
index d2e4aba..2096b35 100644
@@ -1,10 +1,3 @@
 # Member names should be 'lower-case' unless the enum is whitelisted
-
-##
-# @UuidInfo:
-##
 { 'enum': 'UuidInfo', 'data': [ 'Value' ] } # UuidInfo is whitelisted
-##
-# @NoWayThisWillGetWhitelisted:
-##
 { 'enum': 'NoWayThisWillGetWhitelisted', 'data': [ 'Value' ] }
tests/qapi-schema/enum-missing-data.err +1 -1
index de4b9e8..ba4873a 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-missing-data.json:6: Key 'data' is missing from enum 'MyEnum'
+tests/qapi-schema/enum-missing-data.json:2: Key 'data' is missing from enum 'MyEnum'
tests/qapi-schema/enum-missing-data.json +0 -4
index d7601f9..558fd35 100644
@@ -1,6 +1,2 @@
 # we require that all QAPI enums have a data array
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum' }
tests/qapi-schema/enum-wrong-data.err +1 -1
index c44e9b5..11b4347 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-wrong-data.json:6: Enum 'MyEnum' requires an array for 'data'
+tests/qapi-schema/enum-wrong-data.json:2: Enum 'MyEnum' requires an array for 'data'
tests/qapi-schema/enum-wrong-data.json +0 -4
index 4b9e978..7b3e255 100644
@@ -1,6 +1,2 @@
 # we require that all qapi enums have an array for data
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': { 'value': 'str' } }
tests/qapi-schema/event-boxed-empty.err +1 -1
index defe656..68ec6f2 100644
@@ -1 +1 @@
-tests/qapi-schema/event-boxed-empty.json:6: Use of 'boxed' requires 'data'
+tests/qapi-schema/event-boxed-empty.json:2: Use of 'boxed' requires 'data'
tests/qapi-schema/event-boxed-empty.json +0 -4
index 63b870b..cb145f1 100644
@@ -1,6 +1,2 @@
 # 'boxed' requires a non-empty type
-
-##
-# @FOO:
-##
 { 'event': 'FOO', 'boxed': true }
tests/qapi-schema/event-case.json +0 -4
index 6b05c5d..3a92d8b 100644
@@ -1,7 +1,3 @@
 # TODO: might be nice to enforce naming conventions; but until then this works
 # even though events should usually be ALL_CAPS
-
-##
-# @oops:
-##
 { 'event': 'oops' }
tests/qapi-schema/event-case.out +0 -1
index 2865714..5a0f2bf 100644
@@ -3,4 +3,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo
 event oops None
    boxed=False
 object q_empty
-doc symbol=oops expr=('event', 'oops')
tests/qapi-schema/event-nest-struct.err +1 -1
index 17a6c3c..5a42701 100644
@@ -1 +1 @@
-tests/qapi-schema/event-nest-struct.json:5: Member 'a' of 'data' for event 'EVENT_A' should be a type name
+tests/qapi-schema/event-nest-struct.json:1: Member 'a' of 'data' for event 'EVENT_A' should be a type name
tests/qapi-schema/event-nest-struct.json +0 -4
index 328e0a6..ee6f3ec 100644
@@ -1,6 +1,2 @@
-##
-# @EVENT_A:
-# event-nest-struct
-##
 { 'event': 'EVENT_A',
   'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }
tests/qapi-schema/flat-union-array-branch.err +1 -1
index e456094..8ea91ea 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-array-branch.json:20: Member 'value1' of union 'TestUnion' cannot be an array
+tests/qapi-schema/flat-union-array-branch.json:8: Member 'value1' of union 'TestUnion' cannot be an array
tests/qapi-schema/flat-union-array-branch.json +0 -12
index 51dde10..0b98820 100644
@@ -1,22 +1,10 @@
-##
-# @TestEnum:
-##
 # we require flat union branches to be a struct
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-bad-base.err +1 -1
index 072ffba..bee24a2 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-bad-base.json:21: 'string' (member of TestTypeA) collides with 'string' (base of TestUnion)
+tests/qapi-schema/flat-union-bad-base.json:8: 'string' (member of TestTypeA) collides with 'string' (base of TestUnion)
tests/qapi-schema/flat-union-bad-base.json +0 -13
index 7713e7f..74dd421 100644
@@ -1,23 +1,10 @@
 # we allow anonymous base, but enforce no duplicate keys
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': { 'enum1': 'TestEnum', 'string': 'str' },
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-bad-discriminator.err +1 -1
index 1be4e7b..c38cc8e 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-bad-discriminator.json:27: Discriminator of flat union 'TestUnion' requires a string name
+tests/qapi-schema/flat-union-bad-discriminator.json:11: Discriminator of flat union 'TestUnion' requires a string name
tests/qapi-schema/flat-union-bad-discriminator.json +0 -16
index ef92f9b..cd10b9d 100644
@@ -1,29 +1,13 @@
 # we require the discriminator to be a string naming a base-type member
 # this tests the old syntax for anonymous unions before we added alternates
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum', 'kind': 'str' } }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': {},
tests/qapi-schema/flat-union-base-any.err +1 -1
index c1ea2d7..646f1c9 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-base-any.json:21: 'base' for union 'TestUnion' cannot use built-in type 'any'
+tests/qapi-schema/flat-union-base-any.json:8: 'base' for union 'TestUnion' cannot use built-in type 'any'
tests/qapi-schema/flat-union-base-any.json +0 -13
index 3dfb02f..fe66b71 100644
@@ -1,23 +1,10 @@
 # we require the base to be an existing struct
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'any',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-base-union.err +1 -1
index ccc5e85..f138395 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-base-union.json:30: 'base' for union 'TestUnion' cannot use union type 'UnionBase'
+tests/qapi-schema/flat-union-base-union.json:14: 'base' for union 'TestUnion' cannot use union type 'UnionBase'
tests/qapi-schema/flat-union-base-union.json +0 -16
index c63c613..98b4eba 100644
@@ -2,31 +2,15 @@
 # TODO: It would be possible to allow a union as a base, as long as all
 # permutations of QMP names exposed by base do not clash with any QMP
 # member names added by local variants.
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @UnionBase:
-##
 { 'union': 'UnionBase',
   'data': { 'kind1': 'TestTypeA',
             'kind2': 'TestTypeB' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'UnionBase',
   'discriminator': 'type',
tests/qapi-schema/flat-union-clash-member.err +1 -1
index fe12a07..2adf697 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-clash-member.json:27: 'name' (member of Branch1) collides with 'name' (member of Base)
+tests/qapi-schema/flat-union-clash-member.json:11: 'name' (member of Branch1) collides with 'name' (member of Base)
tests/qapi-schema/flat-union-clash-member.json +0 -16
index 9000b94..9efc771 100644
@@ -1,29 +1,13 @@
 # We check for no duplicate keys between branch members and base
 # base's member 'name' clashes with Branch1's
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum', '*name': 'str' } }
-##
-# @Branch1:
-##
 { 'struct': 'Branch1',
   'data': { 'name': 'str' } }
-##
-# @Branch2:
-##
 { 'struct': 'Branch2',
   'data': { 'value': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-empty.err +1 -1
index ead7bd4..15754f5 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-empty.json:14: Union 'Union' cannot have empty 'data'
+tests/qapi-schema/flat-union-empty.json:4: Union 'Union' cannot have empty 'data'
tests/qapi-schema/flat-union-empty.json +0 -10
index afa8988..77f1d9a 100644
@@ -1,14 +1,4 @@
 # flat unions cannot be empty
-
-##
-# @Empty:
-##
 { 'enum': 'Empty', 'data': [ ] }
-##
-# @Base:
-##
 { 'struct': 'Base', 'data': { 'type': 'Empty' } }
-##
-# @Union:
-##
 { 'union': 'Union', 'base': 'Base', 'discriminator': 'type', 'data': { } }
tests/qapi-schema/flat-union-incomplete-branch.err +1 -1
index c655bbf..e826bf0 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-incomplete-branch.json:16: Union 'TestUnion' data missing 'value2' branch
+tests/qapi-schema/flat-union-incomplete-branch.json:6: Union 'TestUnion' data missing 'value2' branch
tests/qapi-schema/flat-union-incomplete-branch.json +0 -10
index dea0377..25a411b 100644
@@ -1,18 +1,8 @@
 # we require all branches of the union to be covered
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': { 'type': 'TestEnum' },
   'discriminator': 'type',
tests/qapi-schema/flat-union-inline.err +1 -1
index c2c3f76..2333358 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-inline.json:17: Member 'value1' of union 'TestUnion' should be a type name
+tests/qapi-schema/flat-union-inline.json:7: Member 'value1' of union 'TestUnion' should be a type name
tests/qapi-schema/flat-union-inline.json +0 -10
index 400f081..62c7cda 100644
@@ -1,19 +1,9 @@
 # we require branches to be a struct name
 # TODO: should we allow anonymous inline branch types?
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum', 'kind': 'str' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-int-branch.err +1 -1
index 299cbb2..faf0157 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-int-branch.json:21: Member 'value1' of union 'TestUnion' cannot use built-in type 'int'
+tests/qapi-schema/flat-union-int-branch.json:8: Member 'value1' of union 'TestUnion' cannot use built-in type 'int'
tests/qapi-schema/flat-union-int-branch.json +0 -13
index 9603e17..9370c34 100644
@@ -1,23 +1,10 @@
 # we require flat union branches to be a struct
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-invalid-branch-key.err +1 -1
index 455f2dc..ccf72d2 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-invalid-branch-key.json:28: Discriminator value 'value_wrong' is not found in enum 'TestEnum'
+tests/qapi-schema/flat-union-invalid-branch-key.json:13: Discriminator value 'value_wrong' is not found in enum 'TestEnum'
tests/qapi-schema/flat-union-invalid-branch-key.json +0 -15
index 00f2896..95ff774 100644
@@ -1,30 +1,15 @@
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum' } }
 
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-invalid-discriminator.err +1 -1
index f0e427b..5f40556 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-invalid-discriminator.json:28: Discriminator 'enum_wrong' is not a member of base struct 'TestBase'
+tests/qapi-schema/flat-union-invalid-discriminator.json:13: Discriminator 'enum_wrong' is not a member of base struct 'TestBase'
tests/qapi-schema/flat-union-invalid-discriminator.json +0 -15
index c8700c7..48b94c3 100644
@@ -1,30 +1,15 @@
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum' } }
 
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': 'enum_wrong',
tests/qapi-schema/flat-union-no-base.err +1 -1
index a2d0a81..841c93b 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-no-base.json:22: Flat union 'TestUnion' must have a base
+tests/qapi-schema/flat-union-no-base.json:9: Flat union 'TestUnion' must have a base
tests/qapi-schema/flat-union-no-base.json +0 -13
index 641f68a..ffc4c6f 100644
@@ -1,24 +1,11 @@
 # flat unions require a base
 # TODO: simple unions should be able to use an enum discriminator
-
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @Enum:
-##
 { 'enum': 'Enum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'discriminator': 'Enum',
   'data': { 'value1': 'TestTypeA',
tests/qapi-schema/flat-union-optional-discriminator.err +1 -1
index e15f856..aaabedb 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-optional-discriminator.json:19: Discriminator of flat union 'MyUnion' does not allow optional name '*switch'
+tests/qapi-schema/flat-union-optional-discriminator.json:6: Discriminator of flat union 'MyUnion' does not allow optional name '*switch'
tests/qapi-schema/flat-union-optional-discriminator.json +0 -13
index 9f19af5..08a8f7e 100644
@@ -1,21 +1,8 @@
 # we require the discriminator to be non-optional
-
-##
-# @Enum:
-##
 { 'enum': 'Enum', 'data': [ 'one', 'two' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { '*switch': 'Enum' } }
-##
-# @Branch:
-##
 { 'struct': 'Branch', 'data': { 'name': 'str' } }
-##
-# @MyUnion:
-##
 { 'union': 'MyUnion',
   'base': 'Base',
   'discriminator': '*switch',
tests/qapi-schema/flat-union-string-discriminator.err +1 -1
index bc0c133..200016b 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-string-discriminator.json:28: Discriminator 'kind' must be of enumeration type
+tests/qapi-schema/flat-union-string-discriminator.json:13: Discriminator 'kind' must be of enumeration type
tests/qapi-schema/flat-union-string-discriminator.json +0 -15
index 47a17d2..8af6033 100644
@@ -1,30 +1,15 @@
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum', 'kind': 'str' } }
 
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': 'kind',
tests/qapi-schema/ident-with-escape.json +0 -4
index c03404b..5661750 100644
@@ -1,8 +1,4 @@
 # we allow escape sequences in strings, if they map back to ASCII
 # { 'command': 'fooA', 'data': { 'bar1': 'str' } }
-
-##
-# @fooA:
-##
 { 'c\u006fmmand': '\u0066\u006f\u006FA',
   'd\u0061ta': { '\u0062\u0061\u00721': '\u0073\u0074\u0072' } }
tests/qapi-schema/ident-with-escape.out +0 -1
index 69fc908..1d2722c 100644
@@ -5,4 +5,3 @@ command fooA q_obj_fooA-arg -> None
 object q_empty
 object q_obj_fooA-arg
     member bar1: str optional=False
-doc symbol=fooA expr=('command', 'fooA')
tests/qapi-schema/include-relpath-sub.json +0 -3
index b4bd8a2..4bd4af4 100644
@@ -1,5 +1,2 @@
-##
-# @Status:
-##
 { 'enum': 'Status',
   'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/include-relpath.out +0 -1
index a962fb2..5d7c13c 100644
@@ -2,4 +2,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
-doc symbol=Status expr=('enum', 'Status')
tests/qapi-schema/include-repetition.out +0 -1
index a962fb2..5d7c13c 100644
@@ -2,4 +2,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
-doc symbol=Status expr=('enum', 'Status')
tests/qapi-schema/include-simple-sub.json +0 -3
index b4bd8a2..4bd4af4 100644
@@ -1,5 +1,2 @@
-##
-# @Status:
-##
 { 'enum': 'Status',
   'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/include-simple.out +0 -1
index a962fb2..5d7c13c 100644
@@ -2,4 +2,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbo
     prefix QTYPE
 enum Status ['good', 'bad', 'ugly']
 object q_empty
-doc symbol=Status expr=('enum', 'Status')
tests/qapi-schema/indented-expr.json +0 -6
index d759be1..7115d31 100644
@@ -1,8 +1,2 @@
-##
-# @eins:
-##
 { 'command' : 'eins' }
-##
-# @zwei:
-##
  { 'command' : 'zwei' }
tests/qapi-schema/indented-expr.out +0 -2
index 285d052..e8171c9 100644
@@ -5,5 +5,3 @@ command eins None -> None
 object q_empty
 command zwei None -> None
    gen=True success_response=True boxed=False
-doc symbol=eins expr=('command', 'eins')
-doc symbol=zwei expr=('command', 'zwei')
tests/qapi-schema/missing-type.err +1 -1
index 74c4ef7..b3e7b14 100644
@@ -1 +1 @@
-tests/qapi-schema/missing-type.json:6: Expression is missing metatype
+tests/qapi-schema/missing-type.json:2: Expression is missing metatype
tests/qapi-schema/missing-type.json +0 -4
index c2fc62d..ff5349d 100644
@@ -1,6 +1,2 @@
 # we reject an expression with missing metatype
-
-##
-# @foo:
-##
 { 'data': { } }
tests/qapi-schema/nested-struct-data.err +1 -1
index 379bd1d..da767ba 100644
@@ -1 +1 @@
-tests/qapi-schema/nested-struct-data.json:6: Member 'a' of 'data' for command 'foo' should be a type name
+tests/qapi-schema/nested-struct-data.json:2: Member 'a' of 'data' for command 'foo' should be a type name
tests/qapi-schema/nested-struct-data.json +0 -4
index 6106e15..efbe773 100644
@@ -1,7 +1,3 @@
 # inline subtypes collide with our desired future use of defaults
-
-##
-# @foo:
-##
 { 'command': 'foo',
   'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }
tests/qapi-schema/qapi-schema-test.json +0 -213

375 lines not on this page · raw message

tests/qapi-schema/qapi-schema-test.out +0 -130

133 lines not on this page · raw message

tests/qapi-schema/redefined-builtin.err +1 -1
index ee0a2ad..b275722 100644
@@ -1 +1 @@
-tests/qapi-schema/redefined-builtin.json:6: built-in 'size' is already defined
+tests/qapi-schema/redefined-builtin.json:2: built-in 'size' is already defined
tests/qapi-schema/redefined-builtin.json +0 -4
index 6d3a940..45b8a55 100644
@@ -1,6 +1,2 @@
 # we reject types that duplicate builtin names
-
-##
-# @size:
-##
 { 'struct': 'size', 'data': { 'myint': 'size' } }
tests/qapi-schema/redefined-command.err +1 -1
index 1e297c4..82ae256 100644
@@ -1 +1 @@
-tests/qapi-schema/redefined-command.json:10: command 'foo' is already defined
+tests/qapi-schema/redefined-command.json:3: command 'foo' is already defined
tests/qapi-schema/redefined-command.json +0 -7
index 3a8cb90..247e401 100644
@@ -1,10 +1,3 @@
 # we reject commands defined more than once
-
-##
-# @foo:
-##
 { 'command': 'foo', 'data': { 'one': 'str' } }
-##
-# @foo:
-##
 { 'command': 'foo', 'data': { '*two': 'str' } }
tests/qapi-schema/redefined-event.err +1 -1
index 912c785..35429cb 100644
@@ -1 +1 @@
-tests/qapi-schema/redefined-event.json:10: event 'EVENT_A' is already defined
+tests/qapi-schema/redefined-event.json:3: event 'EVENT_A' is already defined
tests/qapi-schema/redefined-event.json +0 -7
index ec7aeea..7717e91 100644
@@ -1,10 +1,3 @@
 # we reject duplicate events
-
-##
-# @EVENT_A:
-##
 { 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
-##
-# @EVENT_A:
-##
 { 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
tests/qapi-schema/redefined-type.err +1 -1
index 28d87c0..06ea78c 100644
@@ -1 +1 @@
-tests/qapi-schema/redefined-type.json:10: struct 'foo' is already defined
+tests/qapi-schema/redefined-type.json:3: struct 'foo' is already defined
tests/qapi-schema/redefined-type.json +0 -7
index 7a8f3e1..a09e768 100644
@@ -1,10 +1,3 @@
 # we reject types defined more than once
-
-##
-# @foo:
-##
 { 'struct': 'foo', 'data': { 'one': 'str' } }
-##
-# @foo:
-##
 { 'enum': 'foo', 'data': [ 'two' ] }
tests/qapi-schema/reserved-command-q.err +1 -1
index 5e17f31..f939e04 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-command-q.json:12: 'command' uses invalid name 'q-unix'
+tests/qapi-schema/reserved-command-q.json:5: 'command' uses invalid name 'q-unix'
tests/qapi-schema/reserved-command-q.json +0 -7
index bba0860..99f8aae 100644
@@ -1,12 +1,5 @@
 # C entity name collision
 # We reject names like 'q-unix', because they can collide with the mangled
 # name for 'unix' in generated C.
-
-##
-# @unix:
-##
 { 'command': 'unix' }
-##
-# @q-unix:
-##
 { 'command': 'q-unix' }
tests/qapi-schema/reserved-enum-q.err +1 -1
index acb2df8..e1c3480 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-enum-q.json:8: Member of enum 'Foo' uses invalid name 'q-Unix'
+tests/qapi-schema/reserved-enum-q.json:4: Member of enum 'Foo' uses invalid name 'q-Unix'
tests/qapi-schema/reserved-enum-q.json +0 -4
index 6c7e717..3593a76 100644
@@ -1,8 +1,4 @@
 # C entity name collision
 # We reject names like 'q-unix', because they can collide with the mangled
 # name for 'unix' in generated C.
-
-##
-# @Foo:
-##
 { 'enum': 'Foo', 'data': [ 'unix', 'q-Unix' ] }
tests/qapi-schema/reserved-member-has.err +1 -1
index 9ace796..e755771 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-member-has.json:9: Member of 'data' for command 'oops' uses reserved name 'has-a'
+tests/qapi-schema/reserved-member-has.json:5: Member of 'data' for command 'oops' uses reserved name 'has-a'
tests/qapi-schema/reserved-member-has.json +0 -4
index f0d8905..45b9109 100644
@@ -2,8 +2,4 @@
 # We reject names like 'has-a', because they can collide with the flag
 # for an optional 'a' in generated C.
 # TODO we could munge the optional flag name to avoid the collision.
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { '*a': 'str', 'has-a': 'str' } }
tests/qapi-schema/reserved-member-q.err +1 -1
index 1709a88..f3d5dd7 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-member-q.json:8: Member of 'data' for struct 'Foo' uses invalid name 'q-unix'
+tests/qapi-schema/reserved-member-q.json:4: Member of 'data' for struct 'Foo' uses invalid name 'q-unix'
tests/qapi-schema/reserved-member-q.json +0 -4
index f51e312..62fed8f 100644
@@ -1,8 +1,4 @@
 # C member name collision
 # We reject names like 'q-unix', because they can collide with the mangled
 # name for 'unix' in generated C.
-
-##
-# @Foo:
-##
 { 'struct': 'Foo', 'data': { 'unix':'int', 'q-unix':'bool' } }
tests/qapi-schema/reserved-member-u.err +1 -1
index 6ec69a7..87d4229 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-member-u.json:11: Member of 'data' for struct 'Oops' uses reserved name 'u'
+tests/qapi-schema/reserved-member-u.json:7: Member of 'data' for struct 'Oops' uses reserved name 'u'
tests/qapi-schema/reserved-member-u.json +0 -4
index 3a578e5..1eaf0f3 100644
@@ -4,8 +4,4 @@
 # This is true even for non-unions, because it is possible to convert a
 # struct to flat union while remaining backwards compatible in QMP.
 # TODO - we could munge the member name to 'q_u' to avoid the collision
-
-##
-# @Oops:
-##
 { 'struct': 'Oops', 'data': { 'u': 'str' } }
tests/qapi-schema/reserved-member-underscore.err +1 -1
index c9aefee..65ff0da 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-member-underscore.json:8: Member of 'data' for struct 'Oops' uses invalid name '_oops'
+tests/qapi-schema/reserved-member-underscore.json:4: Member of 'data' for struct 'Oops' uses invalid name '_oops'
tests/qapi-schema/reserved-member-underscore.json +0 -4
index cc34b54..4a3a017 100644
@@ -1,8 +1,4 @@
 # C member name collision
 # We reject use of a single leading underscore in all names (names must
 # begin with a letter or a downstream extension double-underscore prefix).
-
-##
-# @Oops:
-##
 { 'struct': 'Oops', 'data': { '_oops': 'str' } }
tests/qapi-schema/reserved-type-kind.err +1 -1
index 8698073..0a38efa 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-type-kind.json:6: enum 'UnionKind' should not end in 'Kind'
+tests/qapi-schema/reserved-type-kind.json:2: enum 'UnionKind' should not end in 'Kind'
tests/qapi-schema/reserved-type-kind.json +0 -4
index a094941..9ecaba1 100644
@@ -1,6 +1,2 @@
 # we reject types that would conflict with implicit union enum
-
-##
-# @UnionKind:
-##
 { 'enum': 'UnionKind', 'data': [ 'oops' ] }
tests/qapi-schema/reserved-type-list.err +1 -1
index ec0531c..4510fa6 100644
@@ -1 +1 @@
-tests/qapi-schema/reserved-type-list.json:9: struct 'FooList' should not end in 'List'
+tests/qapi-schema/reserved-type-list.json:5: struct 'FooList' should not end in 'List'
tests/qapi-schema/reserved-type-list.json +0 -4
index 6effb78..98d53bf 100644
@@ -2,8 +2,4 @@
 # We reserve names ending in 'List' for use by array types.
 # TODO - we could choose array names to avoid collision with user types,
 # in order to let this compile
-
-##
-# @FooList:
-##
 { 'struct': 'FooList', 'data': { 's': 'str' } }
tests/qapi-schema/returns-alternate.err +1 -1
index 2b81623..dfbb419 100644
@@ -1 +1 @@
-tests/qapi-schema/returns-alternate.json:10: 'returns' for command 'oops' cannot use alternate type 'Alt'
+tests/qapi-schema/returns-alternate.json:3: 'returns' for command 'oops' cannot use alternate type 'Alt'
tests/qapi-schema/returns-alternate.json +0 -7
index 005bf2d..972390c 100644
@@ -1,10 +1,3 @@
 # we reject returns if it is an alternate type
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt', 'data': { 'a': 'int', 'b': 'str' } }
-##
-# @oops:
-##
 { 'command': 'oops', 'returns': 'Alt' }
tests/qapi-schema/returns-array-bad.err +1 -1
index b53bdb0..138095c 100644
@@ -1 +1 @@
-tests/qapi-schema/returns-array-bad.json:6: 'returns' for command 'oops': array type must contain single type name
+tests/qapi-schema/returns-array-bad.json:2: 'returns' for command 'oops': array type must contain single type name
tests/qapi-schema/returns-array-bad.json +0 -4
index 30528fe..09b0b1f 100644
@@ -1,6 +1,2 @@
 # we reject an array return that is not a single type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'returns': [ 'str', 'str' ] }
tests/qapi-schema/returns-dict.err +1 -1
index 1570a35..eb2d0c4 100644
@@ -1 +1 @@
-tests/qapi-schema/returns-dict.json:6: 'returns' for command 'oops' should be a type name
+tests/qapi-schema/returns-dict.json:2: 'returns' for command 'oops' should be a type name
tests/qapi-schema/returns-dict.json +0 -4
index 6a3ed0f..1cfef3e 100644
@@ -1,6 +1,2 @@
 # we reject inline struct return type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'returns': { 'a': 'str' } }
tests/qapi-schema/returns-unknown.err +1 -1
index d76bcfe..1f43e3a 100644
@@ -1 +1 @@
-tests/qapi-schema/returns-unknown.json:6: 'returns' for command 'oops' uses unknown type 'NoSuchType'
+tests/qapi-schema/returns-unknown.json:2: 'returns' for command 'oops' uses unknown type 'NoSuchType'
tests/qapi-schema/returns-unknown.json +0 -4
index 3837f0e..25bd498 100644
@@ -1,6 +1,2 @@
 # we reject returns if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'returns': 'NoSuchType' }
tests/qapi-schema/returns-whitelist.err +1 -1
index e77ea2d..f47c1ee 100644
@@ -1 +1 @@
-tests/qapi-schema/returns-whitelist.json:26: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int'
+tests/qapi-schema/returns-whitelist.json:10: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int'
tests/qapi-schema/returns-whitelist.json +0 -16
index 0bc952d..e8b3cea 100644
@@ -1,27 +1,11 @@
 # we enforce that 'returns' be a dict or array of dict unless whitelisted
-
-##
-# @human-monitor-command:
-##
 { 'command': 'human-monitor-command',
   'data': {'command-line': 'str', '*cpu-index': 'int'},
   'returns': 'str' }
-##
-# @TpmModel:
-##
 { 'enum': 'TpmModel', 'data': [ 'tpm-tis' ] }
-##
-# @query-tpm-models:
-##
 { 'command': 'query-tpm-models', 'returns': ['TpmModel'] }
-##
-# @guest-get-time:
-##
 { 'command': 'guest-get-time',
   'returns': 'int' }
 
-##
-# @no-way-this-will-get-whitelisted:
-##
 { 'command': 'no-way-this-will-get-whitelisted',
   'returns': [ 'int' ] }
tests/qapi-schema/struct-base-clash-deep.err +1 -1
index 1b7c0e9..e2d7943 100644
@@ -1 +1 @@
-tests/qapi-schema/struct-base-clash-deep.json:20: 'name' (member of Sub) collides with 'name' (member of Base)
+tests/qapi-schema/struct-base-clash-deep.json:10: 'name' (member of Sub) collides with 'name' (member of Base)
tests/qapi-schema/struct-base-clash-deep.json +0 -10
index 646d680..fa873ab 100644
@@ -2,21 +2,11 @@
 # Here, 'name' would have to appear twice on the wire, locally and
 # indirectly for the grandparent base; the collision doesn't care that
 # one instance is optional.
-
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'name': 'str' } }
-##
-# @Mid:
-##
 { 'struct': 'Mid',
   'base': 'Base',
   'data': { 'value': 'int' } }
-##
-# @Sub:
-##
 { 'struct': 'Sub',
   'base': 'Mid',
   'data': { '*name': 'str' } }
tests/qapi-schema/struct-base-clash.err +1 -1
index 5fe6393..c52f33d 100644
@@ -1 +1 @@
-tests/qapi-schema/struct-base-clash.json:12: 'name' (member of Sub) collides with 'name' (member of Base)
+tests/qapi-schema/struct-base-clash.json:5: 'name' (member of Sub) collides with 'name' (member of Base)
tests/qapi-schema/struct-base-clash.json +0 -7
index a853995..11aec80 100644
@@ -1,14 +1,7 @@
 # Reject attempts to duplicate QMP members
 # Here, 'name' would have to appear twice on the wire, locally and for base.
-
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'name': 'str' } }
-##
-# @Sub:
-##
 { 'struct': 'Sub',
   'base': 'Base',
   'data': { 'name': 'str' } }
tests/qapi-schema/struct-data-invalid.err +1 -1
index 2716335..6644f4c 100644
@@ -1 +1 @@
-tests/qapi-schema/struct-data-invalid.json:4: 'data' for struct 'foo' should be a dictionary or type name
+tests/qapi-schema/struct-data-invalid.json:1: 'data' for struct 'foo' should be a dictionary or type name
tests/qapi-schema/struct-data-invalid.json +0 -3
index aa817bd..9adbc3b 100644
@@ -1,5 +1,2 @@
-##
-# @foo:
-##
 { 'struct': 'foo',
   'data': false }
tests/qapi-schema/struct-member-invalid.err +1 -1
index f2b105b..69a326d 100644
@@ -1 +1 @@
-tests/qapi-schema/struct-member-invalid.json:4: Member 'a' of 'data' for struct 'foo' should be a type name
+tests/qapi-schema/struct-member-invalid.json:1: Member 'a' of 'data' for struct 'foo' should be a type name
tests/qapi-schema/struct-member-invalid.json +0 -3
index 10c7426..8f172f7 100644
@@ -1,5 +1,2 @@
-##
-# @foo:
-##
 { 'struct': 'foo',
   'data': { 'a': false } }
tests/qapi-schema/test-qapi.py +0 -14
index b4cde4f..ef74e2c 100644
@@ -55,17 +55,3 @@ class QAPISchemaTestVisitor(QAPISchemaVisitor):
 
 schema = QAPISchema(sys.argv[1])
 schema.visit(QAPISchemaTestVisitor())
-
-for doc in schema.docs:
-    if doc.symbol:
-        print 'doc symbol=%s expr=%s' % \
-            (doc.symbol, doc.expr.items()[0])
-    else:
-        print 'doc freeform'
-    for arg, section in doc.args.iteritems():
-        print '    arg=%s\n%s' % (arg, section)
-    for section in doc.sections:
-        print '    section=%s\n%s' % (section.name, section)
-    body = str(doc.body)
-    if body:
-        print '    body=\n%s' % body
tests/qapi-schema/type-bypass-bad-gen.err +1 -1
index bd5431f..a83c3c6 100644
@@ -1 +1 @@
-tests/qapi-schema/type-bypass-bad-gen.json:6: 'gen' of command 'foo' should only use false value
+tests/qapi-schema/type-bypass-bad-gen.json:2: 'gen' of command 'foo' should only use false value
tests/qapi-schema/type-bypass-bad-gen.json +0 -4
index 7162c1a..e8dec34 100644
@@ -1,6 +1,2 @@
 # 'gen' should only appear with value false
-
-##
-# @foo:
-##
 { 'command': 'foo', 'gen': 'whatever' }
tests/qapi-schema/unicode-str.err +1 -1
index 92ee277..f621cd6 100644
@@ -1 +1 @@
-tests/qapi-schema/unicode-str.json:6: 'command' uses invalid name 'é'
+tests/qapi-schema/unicode-str.json:2: 'command' uses invalid name 'é'
tests/qapi-schema/unicode-str.json +0 -4
index 75a08b3..5253a1b 100644
@@ -1,6 +1,2 @@
 # we don't support full Unicode strings, yet
-
-##
-# @e:
-##
 { 'command': 'é' }
tests/qapi-schema/union-base-no-discriminator.err +1 -1
index ca6ee92..8b7a242 100644
@@ -1 +1 @@
-tests/qapi-schema/union-base-no-discriminator.json:23: Simple union 'TestUnion' must not have a base
+tests/qapi-schema/union-base-no-discriminator.json:11: Simple union 'TestUnion' must not have a base
tests/qapi-schema/union-base-no-discriminator.json +0 -12
index cc6bac1..1409cf5 100644
@@ -1,25 +1,13 @@
-##
-# @TestTypeA:
-##
 # we reject simple unions with a base (or flat unions without discriminator)
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'string': 'str' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'data': { 'value1': 'TestTypeA',
tests/qapi-schema/union-branch-case.err +1 -1
index 9095bae..1152190 100644
@@ -1 +1 @@
-tests/qapi-schema/union-branch-case.json:6: 'Branch' (branch of NoWayThisWillGetWhitelisted) should not use uppercase
+tests/qapi-schema/union-branch-case.json:2: 'Branch' (branch of NoWayThisWillGetWhitelisted) should not use uppercase
tests/qapi-schema/union-branch-case.json +0 -4
index 6de1315..e6565dc 100644
@@ -1,6 +1,2 @@
 # Branch names should be 'lower-case' unless the union is whitelisted
-
-##
-# @NoWayThisWillGetWhitelisted:
-##
 { 'union': 'NoWayThisWillGetWhitelisted', 'data': { 'Branch': 'int' } }
tests/qapi-schema/union-clash-branches.err +1 -1
index 640caea..e5b2113 100644
@@ -1 +1 @@
-tests/qapi-schema/union-clash-branches.json:8: 'a_b' (branch of TestUnion) collides with 'a-b' (branch of TestUnion)
+tests/qapi-schema/union-clash-branches.json:4: 'a_b' (branch of TestUnion) collides with 'a-b' (branch of TestUnion)
tests/qapi-schema/union-clash-branches.json +0 -4
index 6615665..3bece8c 100644
@@ -1,9 +1,5 @@
 # Union branch name collision
 # Reject a union that would result in a collision in generated C names (this
 # would try to generate two members 'a_b').
-
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'data': { 'a-b': 'int', 'a_b': 'str' } }
tests/qapi-schema/union-empty.err +1 -1
index 749bc76..12c2022 100644
@@ -1 +1 @@
-tests/qapi-schema/union-empty.json:6: Union 'Union' cannot have empty 'data'
+tests/qapi-schema/union-empty.json:2: Union 'Union' cannot have empty 'data'
tests/qapi-schema/union-empty.json +0 -4
index c9b0a1e..1f0b13c 100644
@@ -1,6 +1,2 @@
 # unions cannot be empty
-
-##
-# @Union:
-##
 { 'union': 'Union', 'data': { } }
tests/qapi-schema/union-invalid-base.err +1 -1
index 41e238f..03d7b97 100644
@@ -1 +1 @@
-tests/qapi-schema/union-invalid-base.json:18: 'base' for union 'TestUnion' cannot use built-in type 'int'
+tests/qapi-schema/union-invalid-base.json:8: 'base' for union 'TestUnion' cannot use built-in type 'int'
tests/qapi-schema/union-invalid-base.json +0 -10
index fd837cb..92be39d 100644
@@ -1,20 +1,10 @@
 # a union base type must be a struct
-
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'int',
   'discriminator': 'int',
tests/qapi-schema/union-optional-branch.err +1 -1
index 60523c0..3ada133 100644
@@ -1 +1 @@
-tests/qapi-schema/union-optional-branch.json:6: Member of union 'Union' does not allow optional name '*a'
+tests/qapi-schema/union-optional-branch.json:2: Member of union 'Union' does not allow optional name '*a'
tests/qapi-schema/union-optional-branch.json +0 -4
index 7d2ee4c..591615f 100644
@@ -1,6 +1,2 @@
 # union branches cannot be optional
-
-##
-# @Union:
-##
 { 'union': 'Union', 'data': { '*a': 'int', 'b': 'str' } }
tests/qapi-schema/union-unknown.err +1 -1
index 5568302..54fe456 100644
@@ -1 +1 @@
-tests/qapi-schema/union-unknown.json:6: Member 'unknown' of union 'Union' uses unknown type 'MissingType'
+tests/qapi-schema/union-unknown.json:2: Member 'unknown' of union 'Union' uses unknown type 'MissingType'
tests/qapi-schema/union-unknown.json +0 -4
index 5042b23..aa7e814 100644
@@ -1,7 +1,3 @@
 # we reject a union with unknown type in branch
-
-##
-# @Union:
-##
 { 'union': 'Union',
   'data': { 'unknown': 'MissingType' } }
tests/qapi-schema/unknown-escape.err +1 -1
index 1a4ead6..000e30d 100644
@@ -1 +1 @@
-tests/qapi-schema/unknown-escape.json:7:21: Unknown escape \x
+tests/qapi-schema/unknown-escape.json:3:21: Unknown escape \x
tests/qapi-schema/unknown-escape.json +0 -4
index e3ae679..8e6891e 100644
@@ -1,7 +1,3 @@
 # we only recognize JSON escape sequences, plus our \' extension (no \x)
-
-##
-# @foo:
-##
 # { 'command': 'foo', 'data': {} }
 { 'command': 'foo', 'dat\x61':{} }
tests/qapi-schema/unknown-expr-key.err +1 -1
index b19a668..12f5ed5 100644
@@ -1 +1 @@
-tests/qapi-schema/unknown-expr-key.json:6: Unknown key 'bogus' in struct 'bar'
+tests/qapi-schema/unknown-expr-key.json:2: Unknown key 'bogus' in struct 'bar'
tests/qapi-schema/unknown-expr-key.json +0 -4
index 1b764c7..3b2be00 100644
@@ -1,6 +1,2 @@
 # we reject an expression with unknown top-level keys
-
-##
-# @bar:
-##
 { 'struct': 'bar', 'data': { 'string': 'str'}, 'bogus': { } }
Signature · 1 line
2.7.4
Reviewed-by on v1 3/47
#8 lore raw

Re: [Qemu-devel] [PATCH for-2.9 03/47] qapi: Back out doc comments added just to please qapi.py

Quoted 5 lines · Markus Armbruster

This reverts commit 3313b61's changes to tests/qapi-schema/, except for tests/qapi-schema/doc-*.

---

Tested by doing:

$ git checkout 3313b61
$ git cherry-pick 07c7b92 # the current id on your qapi-doc branch
$ git diff HEAD^^ --stat tests/qapi-schema | grep -v /doc-
 72 files changed, 164 insertions(+)
Quoted 1 line
 200 files changed, 92 insertions(+), 1074 deletions(-)

It's a shame we did that much busywork adding test documentation in the first place. But it was incomplete (as I found out when trying to convert some existing tests of failures into new tests of success, by adding features like anonymous bases to flat unions), and indeed does not add much value.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#9 lore raw

Re: [Qemu-devel] [PATCH for-2.9 03/47] qapi: Back out doc comments added just to please qapi.py

Quoted 16 lines · Eric Blake
Quoted 5 lines · Markus Armbruster

This reverts commit 3313b61's changes to tests/qapi-schema/, except for tests/qapi-schema/doc-*.

---

Tested by doing:

$ git checkout 3313b61
$ git cherry-pick 07c7b92 # the current id on your qapi-doc branch
$ git diff HEAD^^ --stat tests/qapi-schema | grep -v /doc-
 72 files changed, 164 insertions(+)
Quoted 7 lines
Quoted 1 line
 200 files changed, 92 insertions(+), 1074 deletions(-)

It's a shame we did that much busywork adding test documentation in the first place. But it was incomplete (as I found out when trying to convert some existing tests of failures into new tests of success, by adding features like anonymous bases to flat unions), and indeed does not add much value.

Marc-André initially reported missing documentation errors only in qapi2texi.py. I asked why in review of v5, he pointed to tests, I said "good point" and asked to put the explanation in the commit message. Got back "I fixed the tests instead (after all, we have complete control on what to accept or not. that was boring but now it's done)", felt a bit bad, and then felt bad some more when I made this patch.

#10 lore raw

Re: [Qemu-devel] [PATCH for-2.9 03/47] qapi: Back out doc comments added just to please qapi.py

In reply to Markus Armbruster

Hi

Quoted 4 lines · Markus Armbruster

This reverts commit 3313b61's changes to tests/qapi-schema/, except for tests/qapi-schema/doc-*.

Do we expect those files to change? If not, or not much, I think i't s rather better to keep the docs to exercise the parser in various situations. It doesn't reduce the merits of the doc pragma though for other cases, which I wish I would have suggested (but I didn't like the initial series to grow more features)

Quoted 130 lines
---
 tests/qapi-schema/alternate-any.err                |   2 +-
 tests/qapi-schema/alternate-any.json               |   4 -
 tests/qapi-schema/alternate-array.err              |   2 +-
 tests/qapi-schema/alternate-array.json             |   7 -
 tests/qapi-schema/alternate-base.err               |   2 +-
 tests/qapi-schema/alternate-base.json              |   7 -
 tests/qapi-schema/alternate-clash.err              |   2 +-
 tests/qapi-schema/alternate-clash.json             |   4 -
 tests/qapi-schema/alternate-conflict-dict.err      |   2 +-
 tests/qapi-schema/alternate-conflict-dict.json     |  10 -
 tests/qapi-schema/alternate-conflict-string.err    |   2 +-
 tests/qapi-schema/alternate-conflict-string.json   |   7 -
 tests/qapi-schema/alternate-empty.err              |   2 +-
 tests/qapi-schema/alternate-empty.json             |   4 -
 tests/qapi-schema/alternate-nested.err             |   2 +-
 tests/qapi-schema/alternate-nested.json            |   7 -
 tests/qapi-schema/alternate-unknown.err            |   2 +-
 tests/qapi-schema/alternate-unknown.json           |   4 -
 tests/qapi-schema/args-alternate.err               |   2 +-
 tests/qapi-schema/args-alternate.json              |   8 -
 tests/qapi-schema/args-any.err                     |   2 +-
 tests/qapi-schema/args-any.json                    |   4 -
 tests/qapi-schema/args-array-empty.err             |   2 +-
 tests/qapi-schema/args-array-empty.json            |   4 -
 tests/qapi-schema/args-array-unknown.err           |   2 +-
 tests/qapi-schema/args-array-unknown.json          |   4 -
 tests/qapi-schema/args-bad-boxed.err               |   2 +-
 tests/qapi-schema/args-bad-boxed.json              |   4 -
 tests/qapi-schema/args-boxed-anon.err              |   2 +-
 tests/qapi-schema/args-boxed-anon.json             |   4 -
 tests/qapi-schema/args-boxed-empty.err             |   2 +-
 tests/qapi-schema/args-boxed-empty.json            |   8 -
 tests/qapi-schema/args-boxed-string.err            |   2 +-
 tests/qapi-schema/args-boxed-string.json           |   4 -
 tests/qapi-schema/args-int.err                     |   2 +-
 tests/qapi-schema/args-int.json                    |   4 -
 tests/qapi-schema/args-invalid.err                 |   2 +-
 tests/qapi-schema/args-invalid.json                |   3 -
 tests/qapi-schema/args-member-array-bad.err        |   2 +-
 tests/qapi-schema/args-member-array-bad.json       |   4 -
 tests/qapi-schema/args-member-case.err             |   2 +-
 tests/qapi-schema/args-member-case.json            |   4 -
 tests/qapi-schema/args-member-unknown.err          |   2 +-
 tests/qapi-schema/args-member-unknown.json         |   4 -
 tests/qapi-schema/args-name-clash.err              |   2 +-
 tests/qapi-schema/args-name-clash.json             |   4 -
 tests/qapi-schema/args-union.err                   |   2 +-
 tests/qapi-schema/args-union.json                  |   7 -
 tests/qapi-schema/args-unknown.err                 |   2 +-
 tests/qapi-schema/args-unknown.json                |   4 -
 tests/qapi-schema/bad-base.err                     |   2 +-
 tests/qapi-schema/bad-base.json                    |   7 -
 tests/qapi-schema/bad-data.err                     |   2 +-
 tests/qapi-schema/bad-data.json                    |   4 -
 tests/qapi-schema/bad-ident.err                    |   2 +-
 tests/qapi-schema/bad-ident.json                   |   4 -
 tests/qapi-schema/bad-type-bool.err                |   2 +-
 tests/qapi-schema/bad-type-bool.json               |   4 -
 tests/qapi-schema/bad-type-dict.err                |   2 +-
 tests/qapi-schema/bad-type-dict.json               |   4 -
 tests/qapi-schema/base-cycle-direct.err            |   2 +-
 tests/qapi-schema/base-cycle-direct.json           |   4 -
 tests/qapi-schema/base-cycle-indirect.err          |   2 +-
 tests/qapi-schema/base-cycle-indirect.json         |   7 -
 tests/qapi-schema/command-int.err                  |   2 +-
 tests/qapi-schema/command-int.json                 |   4 -
 tests/qapi-schema/comments.json                    |   4 -
 tests/qapi-schema/comments.out                     |   1 -
 tests/qapi-schema/double-type.err                  |   2 +-
 tests/qapi-schema/double-type.json                 |   4 -
 tests/qapi-schema/enum-bad-name.err                |   2 +-
 tests/qapi-schema/enum-bad-name.json               |   4 -
 tests/qapi-schema/enum-bad-prefix.err              |   2 +-
 tests/qapi-schema/enum-bad-prefix.json             |   4 -
 tests/qapi-schema/enum-clash-member.err            |   2 +-
 tests/qapi-schema/enum-clash-member.json           |   4 -
 tests/qapi-schema/enum-dict-member.err             |   2 +-
 tests/qapi-schema/enum-dict-member.json            |   4 -
 tests/qapi-schema/enum-member-case.err             |   2 +-
 tests/qapi-schema/enum-member-case.json            |   7 -
 tests/qapi-schema/enum-missing-data.err            |   2 +-
 tests/qapi-schema/enum-missing-data.json           |   4 -
 tests/qapi-schema/enum-wrong-data.err              |   2 +-
 tests/qapi-schema/enum-wrong-data.json             |   4 -
 tests/qapi-schema/event-boxed-empty.err            |   2 +-
 tests/qapi-schema/event-boxed-empty.json           |   4 -
 tests/qapi-schema/event-case.json                  |   4 -
 tests/qapi-schema/event-case.out                   |   1 -
 tests/qapi-schema/event-nest-struct.err            |   2 +-
 tests/qapi-schema/event-nest-struct.json           |   4 -
 tests/qapi-schema/flat-union-array-branch.err      |   2 +-
 tests/qapi-schema/flat-union-array-branch.json     |  12 --
 tests/qapi-schema/flat-union-bad-base.err          |   2 +-
 tests/qapi-schema/flat-union-bad-base.json         |  13 --
 tests/qapi-schema/flat-union-bad-discriminator.err |   2 +-
 .../qapi-schema/flat-union-bad-discriminator.json  |  16 --
 tests/qapi-schema/flat-union-base-any.err          |   2 +-
 tests/qapi-schema/flat-union-base-any.json         |  13 --
 tests/qapi-schema/flat-union-base-union.err        |   2 +-
 tests/qapi-schema/flat-union-base-union.json       |  16 --
 tests/qapi-schema/flat-union-clash-member.err      |   2 +-
 tests/qapi-schema/flat-union-clash-member.json     |  16 --
 tests/qapi-schema/flat-union-empty.err             |   2 +-
 tests/qapi-schema/flat-union-empty.json            |  10 -
 tests/qapi-schema/flat-union-incomplete-branch.err |   2 +-
 .../qapi-schema/flat-union-incomplete-branch.json  |  10 -
 tests/qapi-schema/flat-union-inline.err            |   2 +-
 tests/qapi-schema/flat-union-inline.json           |  10 -
 tests/qapi-schema/flat-union-int-branch.err        |   2 +-
 tests/qapi-schema/flat-union-int-branch.json       |  13 --
 .../qapi-schema/flat-union-invalid-branch-key.err  |   2 +-
 .../qapi-schema/flat-union-invalid-branch-key.json |  15 --
 .../flat-union-invalid-discriminator.err           |   2 +-
 .../flat-union-invalid-discriminator.json          |  15 --
 tests/qapi-schema/flat-union-no-base.err           |   2 +-
 tests/qapi-schema/flat-union-no-base.json          |  13 --
 .../flat-union-optional-discriminator.err          |   2 +-
 .../flat-union-optional-discriminator.json         |  13 --
 .../flat-union-string-discriminator.err            |   2 +-
 .../flat-union-string-discriminator.json           |  15 --
 tests/qapi-schema/ident-with-escape.json           |   4 -
 tests/qapi-schema/ident-with-escape.out            |   1 -
 tests/qapi-schema/include-relpath-sub.json         |   3 -
 tests/qapi-schema/include-relpath.out              |   1 -
 tests/qapi-schema/include-repetition.out           |   1 -
 tests/qapi-schema/include-simple-sub.json          |   3 -
 tests/qapi-schema/include-simple.out               |   1 -
 tests/qapi-schema/indented-expr.json               |   6 -
Quoted 9 lines
 tests/qapi-schema/indented-expr.out                |   2 -
 tests/qapi-schema/missing-type.err                 |   2 +-
 tests/qapi-schema/missing-type.json                |   4 -
 tests/qapi-schema/nested-struct-data.err           |   2 +-
 tests/qapi-schema/nested-struct-data.json          |   4 -
 tests/qapi-schema/qapi-schema-test.json            | 213
---------------------
 tests/qapi-schema/qapi-schema-test.out             | 130 -------------

At least here some docs should probably remain, or there won't be much positive cases left.

Quoted 1,785 lines
 tests/qapi-schema/redefined-builtin.err            |   2 +-
 tests/qapi-schema/redefined-builtin.json           |   4 -
 tests/qapi-schema/redefined-command.err            |   2 +-
 tests/qapi-schema/redefined-command.json           |   7 -
 tests/qapi-schema/redefined-event.err              |   2 +-
 tests/qapi-schema/redefined-event.json             |   7 -
 tests/qapi-schema/redefined-type.err               |   2 +-
 tests/qapi-schema/redefined-type.json              |   7 -
 tests/qapi-schema/reserved-command-q.err           |   2 +-
 tests/qapi-schema/reserved-command-q.json          |   7 -
 tests/qapi-schema/reserved-enum-q.err              |   2 +-
 tests/qapi-schema/reserved-enum-q.json             |   4 -
 tests/qapi-schema/reserved-member-has.err          |   2 +-
 tests/qapi-schema/reserved-member-has.json         |   4 -
 tests/qapi-schema/reserved-member-q.err            |   2 +-
 tests/qapi-schema/reserved-member-q.json           |   4 -
 tests/qapi-schema/reserved-member-u.err            |   2 +-
 tests/qapi-schema/reserved-member-u.json           |   4 -
 tests/qapi-schema/reserved-member-underscore.err   |   2 +-
 tests/qapi-schema/reserved-member-underscore.json  |   4 -
 tests/qapi-schema/reserved-type-kind.err           |   2 +-
 tests/qapi-schema/reserved-type-kind.json          |   4 -
 tests/qapi-schema/reserved-type-list.err           |   2 +-
 tests/qapi-schema/reserved-type-list.json          |   4 -
 tests/qapi-schema/returns-alternate.err            |   2 +-
 tests/qapi-schema/returns-alternate.json           |   7 -
 tests/qapi-schema/returns-array-bad.err            |   2 +-
 tests/qapi-schema/returns-array-bad.json           |   4 -
 tests/qapi-schema/returns-dict.err                 |   2 +-
 tests/qapi-schema/returns-dict.json                |   4 -
 tests/qapi-schema/returns-unknown.err              |   2 +-
 tests/qapi-schema/returns-unknown.json             |   4 -
 tests/qapi-schema/returns-whitelist.err            |   2 +-
 tests/qapi-schema/returns-whitelist.json           |  16 --
 tests/qapi-schema/struct-base-clash-deep.err       |   2 +-
 tests/qapi-schema/struct-base-clash-deep.json      |  10 -
 tests/qapi-schema/struct-base-clash.err            |   2 +-
 tests/qapi-schema/struct-base-clash.json           |   7 -
 tests/qapi-schema/struct-data-invalid.err          |   2 +-
 tests/qapi-schema/struct-data-invalid.json         |   3 -
 tests/qapi-schema/struct-member-invalid.err        |   2 +-
 tests/qapi-schema/struct-member-invalid.json       |   3 -
 tests/qapi-schema/test-qapi.py                     |  14 --
 tests/qapi-schema/type-bypass-bad-gen.err          |   2 +-
 tests/qapi-schema/type-bypass-bad-gen.json         |   4 -
 tests/qapi-schema/unicode-str.err                  |   2 +-
 tests/qapi-schema/unicode-str.json                 |   4 -
 tests/qapi-schema/union-base-no-discriminator.err  |   2 +-
 tests/qapi-schema/union-base-no-discriminator.json |  12 --
 tests/qapi-schema/union-branch-case.err            |   2 +-
 tests/qapi-schema/union-branch-case.json           |   4 -
 tests/qapi-schema/union-clash-branches.err         |   2 +-
 tests/qapi-schema/union-clash-branches.json        |   4 -
 tests/qapi-schema/union-empty.err                  |   2 +-
 tests/qapi-schema/union-empty.json                 |   4 -
 tests/qapi-schema/union-invalid-base.err           |   2 +-
 tests/qapi-schema/union-invalid-base.json          |  10 -
 tests/qapi-schema/union-optional-branch.err        |   2 +-
 tests/qapi-schema/union-optional-branch.json       |   4 -
 tests/qapi-schema/union-unknown.err                |   2 +-
 tests/qapi-schema/union-unknown.json               |   4 -
 tests/qapi-schema/unknown-escape.err               |   2 +-
 tests/qapi-schema/unknown-escape.json              |   4 -
 tests/qapi-schema/unknown-expr-key.err             |   2 +-
 tests/qapi-schema/unknown-expr-key.json            |   4 -
 200 files changed, 92 insertions(+), 1074 deletions(-)
tests/qapi-schema/alternate-any.err +0 -1
index 395c8ab..aaa0154 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-any.json:6: Alternate 'Alt' member 'one'

cannot use type 'any' +tests/qapi-schema/alternate-any.json:2: Alternate 'Alt' member 'one' cannot use type 'any'

tests/qapi-schema/alternate-any.json +0 -4
index c958776..e47a73a 100644
@@ -1,8 +1,4 @@
 # we do not allow the 'any' type as an alternate branch
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'any',
             'two': 'int' } }
tests/qapi-schema/alternate-array.err +0 -1
index 09628e9..7b930c6 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-array.json:12: Member 'two' of alternate

'Alt' cannot be an array +tests/qapi-schema/alternate-array.json:5: Member 'two' of alternate 'Alt' cannot be an array

tests/qapi-schema/alternate-array.json +0 -7
index c2f98ad..f241aac 100644
@@ -1,14 +1,7 @@
 # we do not allow array branches in alternates
-
-##
-# @One:
-##
 # TODO: should we support this?
 { 'struct': 'One',
   'data': { 'name': 'str' } }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'One',
             'two': [ 'int' ] } }
tests/qapi-schema/alternate-base.err +0 -1
index 3b67914..30d8a34 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-base.json:11: Unknown key 'base' in alternate

'Alt'
+tests/qapi-schema/alternate-base.json:4: Unknown key 'base' in alternate 'Alt'

tests/qapi-schema/alternate-base.json +0 -7
index 9612b79..529430ec 100644
@@ -1,13 +1,6 @@
 # we reject alternate with base type
-
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'string': 'str' } }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'base': 'Base',
   'data': { 'number': 'int' } }
tests/qapi-schema/alternate-clash.err +0 -1
index f07c3e8..604d849 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-clash.json:11: 'a_b' (branch of Alt1)

collides with 'a-b' (branch of Alt1) +tests/qapi-schema/alternate-clash.json:7: 'a_b' (branch of Alt1) collides with 'a-b' (branch of Alt1)

tests/qapi-schema/alternate-clash.json +0 -4
index 97ca7c8..6d73bc5 100644
@@ -4,9 +4,5 @@
 # TODO: In the future, if alternates are simplified to not generate
 # the implicit Alt1Kind enum, we would still have a collision with the
 # resulting C union trying to have two members named 'a_b'.
-
-##
-# @Alt1:
-##
 { 'alternate': 'Alt1',
   'data': { 'a-b': 'str', 'a_b': 'int' } }
tests/qapi-schema/alternate-conflict-dict.err +0 -1
index 7cb023f..0f411f4 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-conflict-dict.json:16: Alternate 'Alt' member

'two' can't be distinguished from member 'one' +tests/qapi-schema/alternate-conflict-dict.json:6: Alternate 'Alt' member 'two' can't be distinguished from member 'one'

tests/qapi-schema/alternate-conflict-dict.json +0 -10
index 9f9d97f..d566cca 100644
@@ -1,18 +1,8 @@
 # we reject alternates with multiple object branches
-
-##
-# @One:
-##
 { 'struct': 'One',
   'data': { 'name': 'str' } }
-##
-# @Two:
-##
 { 'struct': 'Two',
   'data': { 'value': 'int' } }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'One',
             'two': 'Two' } }
tests/qapi-schema/alternate-conflict-string.err +0 -1
index 6dbbacd..fc523b0 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-conflict-string.json:11: Alternate 'Alt'

member 'two' can't be distinguished from member 'one' +tests/qapi-schema/alternate-conflict-string.json:4: Alternate 'Alt' member 'two' can't be distinguished from member 'one'

tests/qapi-schema/alternate-conflict-string.json +0 -7
index 12aafab..72f04a8 100644
@@ -1,13 +1,6 @@
 # we reject alternates with multiple string-like branches
-
-##
-# @Enum:
-##
 { 'enum': 'Enum',
   'data': [ 'hello', 'world' ] }
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'one': 'str',
             'two': 'Enum' } }
tests/qapi-schema/alternate-empty.err +0 -1
index 8245ce3..bb06c5b 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-empty.json:6: Alternate 'Alt' should have at

least two branches in 'data' +tests/qapi-schema/alternate-empty.json:2: Alternate 'Alt' should have at least two branches in 'data'

tests/qapi-schema/alternate-empty.json +0 -4
index db54405..fff15ba 100644
@@ -1,6 +1,2 @@
 # alternates must list at least two types to be useful
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt', 'data': { 'i': 'int' } }
tests/qapi-schema/alternate-nested.err +0 -1
index 1804ffb..4d1187e 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-nested.json:11: Member 'nested' of alternate

'Alt2' cannot use alternate type 'Alt1' +tests/qapi-schema/alternate-nested.json:4: Member 'nested' of alternate 'Alt2' cannot use alternate type 'Alt1'

tests/qapi-schema/alternate-nested.json +0 -7
index 9f83ebe..8e22186 100644
@@ -1,12 +1,5 @@
 # we reject a nested alternate branch
-
-##
-# @Alt1:
-##
 { 'alternate': 'Alt1',
   'data': { 'name': 'str', 'value': 'int' } }
-##
-# @Alt2:
-##
 { 'alternate': 'Alt2',
   'data': { 'nested': 'Alt1', 'b': 'bool' } }
tests/qapi-schema/alternate-unknown.err +0 -1
index cf5b9b6..dea45dc 100644
@@ -1 +1 @@
-tests/qapi-schema/alternate-unknown.json:6: Member 'unknown' of alternate

'Alt' uses unknown type 'MissingType' +tests/qapi-schema/alternate-unknown.json:2: Member 'unknown' of alternate 'Alt' uses unknown type 'MissingType'

tests/qapi-schema/alternate-unknown.json +0 -4
index 941ba1f..08c80dc 100644
@@ -1,7 +1,3 @@
 # we reject an alternate with unknown type in branch
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt',
   'data': { 'unknown': 'MissingType', 'i': 'int' } }
tests/qapi-schema/args-alternate.err +0 -1
index 2e6bf54..3086eae 100644
@@ -1 +1 @@
-tests/qapi-schema/args-alternate.json:11: 'data' for command 'oops'

cannot use alternate type 'Alt' +tests/qapi-schema/args-alternate.json:3: 'data' for command 'oops' cannot use alternate type 'Alt'

tests/qapi-schema/args-alternate.json +0 -8
index 49d0211..69e94d4 100644
@@ -1,11 +1,3 @@
 # we do not allow alternate arguments
-
-##
-# @Alt:
-##
 { 'alternate': 'Alt', 'data': { 'case1': 'int', 'case2': 'str' } }
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'Alt' }
tests/qapi-schema/args-any.err +0 -1
index 955504b..bf9b5e0 100644
@@ -1 +1 @@
-tests/qapi-schema/args-any.json:6: 'data' for command 'oops' cannot use

built-in type 'any'
+tests/qapi-schema/args-any.json:2: 'data' for command 'oops' cannot use built-in type 'any'

tests/qapi-schema/args-any.json +0 -4
index f494479..58fe5e4 100644
@@ -1,6 +1,2 @@
 # we do not allow an 'any' argument
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'any' }
tests/qapi-schema/args-array-empty.err +0 -1
index e85f791..cb7ed33 100644
@@ -1 +1 @@
-tests/qapi-schema/args-array-empty.json:6: Member 'empty' of 'data' for

command 'oops': array type must contain single type name +tests/qapi-schema/args-array-empty.json:2: Member 'empty' of 'data' for command 'oops': array type must contain single type name

tests/qapi-schema/args-array-empty.json +0 -4
index 78a0b88..652dcfb 100644
@@ -1,6 +1,2 @@
 # we reject an array for data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'empty': [ ] } }
tests/qapi-schema/args-array-unknown.err +0 -1
index 77788de..cd7a0f9 100644
@@ -1 +1 @@
-tests/qapi-schema/args-array-unknown.json:6: Member 'array' of 'data' for

command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-array-unknown.json:2: Member 'array' of 'data' for command 'oops' uses unknown type 'NoSuchType'

tests/qapi-schema/args-array-unknown.json +0 -4
index f680fc1..6f3e883 100644
@@ -1,6 +1,2 @@
 # we reject an array for data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'array': [ 'NoSuchType' ] } }
tests/qapi-schema/args-bad-boxed.err +0 -1
index 87a9061..ad0d417 100644
@@ -1 +1 @@
-tests/qapi-schema/args-bad-boxed.json:6: 'boxed' of command 'foo' should

only use true value
+tests/qapi-schema/args-bad-boxed.json:2: 'boxed' of command 'foo' should only use true value

tests/qapi-schema/args-bad-boxed.json +0 -4
index 4c0b28f..dea0cd0 100644
@@ -1,6 +1,2 @@
 # 'boxed' should only appear with value true
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': false }
tests/qapi-schema/args-boxed-anon.err +0 -1
index 3cfac0b..f24f345 100644
@@ -1 +1 @@
-tests/qapi-schema/args-boxed-anon.json:6: 'data' for command 'foo' should

be a type name
+tests/qapi-schema/args-boxed-anon.json:2: 'data' for command 'foo' should be a type name

tests/qapi-schema/args-boxed-anon.json +0 -4
index 2358e6a..95f60da 100644
@@ -1,6 +1,2 @@
 # 'boxed' can only be used with named types
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': true, 'data': { 'string': 'str' } }
tests/qapi-schema/args-boxed-empty.err +0 -1
index 963f495..039603e 100644
@@ -1 +1 @@
-tests/qapi-schema/args-boxed-empty.json:11: Cannot use 'boxed' with empty

type
+tests/qapi-schema/args-boxed-empty.json:3: Cannot use 'boxed' with empty type

tests/qapi-schema/args-boxed-empty.json +0 -8
index 8e8cc26..52717e0 100644
@@ -1,11 +1,3 @@
 # 'boxed' requires a non-empty type
-
-##
-# @Empty:
-##
 { 'struct': 'Empty', 'data': {} }
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': true, 'data': 'Empty' }
tests/qapi-schema/args-boxed-string.err +0 -1
index 7623755..d326b48 100644
@@ -1 +1 @@
-tests/qapi-schema/args-boxed-string.json:6: 'data' for command 'foo'

cannot use built-in type 'str' +tests/qapi-schema/args-boxed-string.json:2: 'data' for command 'foo' cannot use built-in type 'str'

tests/qapi-schema/args-boxed-string.json +0 -4
index aecdf97..f91a150 100644
@@ -1,6 +1,2 @@
 # 'boxed' requires a complex (not built-in) type
-
-##
-# @foo:
-##
 { 'command': 'foo', 'boxed': true, 'data': 'str' }
tests/qapi-schema/args-int.err +0 -1
index 38b3202..dc1d250 100644
@@ -1 +1 @@
-tests/qapi-schema/args-int.json:6: 'data' for command 'oops' cannot use

built-in type 'int'
+tests/qapi-schema/args-int.json:2: 'data' for command 'oops' cannot use built-in type 'int'

tests/qapi-schema/args-int.json +0 -4
index 7f4e1b7..a334d92 100644
@@ -1,6 +1,2 @@
 # we reject commands where data is not an array or complex type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'int' }
tests/qapi-schema/args-invalid.err +0 -1
index 5d3568d..fe1e949 100644
@@ -1 +1 @@
-tests/qapi-schema/args-invalid.json:4: 'data' for command 'foo' should be

a dictionary or type name +tests/qapi-schema/args-invalid.json:1: 'data' for command 'foo' should be a dictionary or type name

tests/qapi-schema/args-invalid.json +0 -3
index 1a7e63b..db09813 100644
@@ -1,5 +1,2 @@
-##
-# @foo:
-##
 { 'command': 'foo',
   'data': false }
tests/qapi-schema/args-member-array-bad.err +0 -1
index 825ffca..881b4d9 100644
@@ -1 +1 @@
-tests/qapi-schema/args-member-array-bad.json:6: Member 'member' of 'data'

for command 'oops': array type must contain single type name +tests/qapi-schema/args-member-array-bad.json:2: Member 'member' of 'data' for command 'oops': array type must contain single type name

tests/qapi-schema/args-member-array-bad.json +0 -4
index e934f5c..b2ff144 100644
@@ -1,6 +1,2 @@
 # we reject data if it does not contain a valid array type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'member': [ { 'nested': 'str' } ] } }
tests/qapi-schema/args-member-case.err +0 -1
index a3fb2bd..19c4426 100644
@@ -1 +1 @@
-tests/qapi-schema/args-member-case.json:6: 'Arg' (parameter of

no-way-this-will-get-whitelisted) should not use uppercase +tests/qapi-schema/args-member-case.json:2: 'Arg' (parameter of no-way-this-will-get-whitelisted) should not use uppercase

tests/qapi-schema/args-member-case.json +0 -0
index 811e658..93439be 100644
@@ -1,6 +1,2 @@
 # Member names should be 'lower-case' unless the struct/command is

whitelisted

tests/qapi-schema/args-member-case.json +0 -4
-
-##
-# @no-way-this-will-get-whitelisted:
-##
 { 'command': 'no-way-this-will-get-whitelisted', 'data': { 'Arg': 'int' }

}

tests/qapi-schema/args-member-unknown.err +0 -1
index 3db452b..f6f8282 100644
@@ -1 +1 @@
-tests/qapi-schema/args-member-unknown.json:6: Member 'member' of 'data'

for command 'oops' uses unknown type 'NoSuchType' +tests/qapi-schema/args-member-unknown.json:2: Member 'member' of 'data' for command 'oops' uses unknown type 'NoSuchType'

tests/qapi-schema/args-member-unknown.json +0 -4
index e2fef9c..342a41e 100644
@@ -1,6 +1,2 @@
 # we reject data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'member': 'NoSuchType' } }
tests/qapi-schema/args-name-clash.err +0 -1
index 23988cb..d953e8d 100644
@@ -1 +1 @@
-tests/qapi-schema/args-name-clash.json:8: 'a_b' (parameter of oops)

collides with 'a-b' (parameter of oops) +tests/qapi-schema/args-name-clash.json:4: 'a_b' (parameter of oops) collides with 'a-b' (parameter of oops)

tests/qapi-schema/args-name-clash.json +0 -0
index 991323b..61423cb 100644
@@ -1,8 +1,4 @@
 # C member name collision
 # Reject members that clash when mapped to C names (we would have two

'a_b'
# members).

tests/qapi-schema/args-name-clash.json +0 -4
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': { 'a-b': 'str', 'a_b': 'str' } }
tests/qapi-schema/args-union.err +0 -1
index ce0a34e..f8ad223 100644
@@ -1 +1 @@
-tests/qapi-schema/args-union.json:10: 'data' for command 'oops' cannot

use union type 'Uni'
+tests/qapi-schema/args-union.json:3: 'data' for command 'oops' cannot use union type 'Uni'

tests/qapi-schema/args-union.json +0 -7
index 57284b4..2fcaeaa 100644
@@ -1,10 +1,3 @@
 # use of union arguments requires 'boxed':true
-
-##
-# @Uni:
-##
 { 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } }
-##
-# oops:
-##
 { 'command': 'oops', 'data': 'Uni' }
tests/qapi-schema/args-unknown.err +0 -1
index ba6c6cf..4d91ec8 100644
@@ -1 +1 @@
-tests/qapi-schema/args-unknown.json:6: 'data' for command 'oops' uses

unknown type 'NoSuchType' +tests/qapi-schema/args-unknown.json:2: 'data' for command 'oops' uses unknown type 'NoSuchType'

tests/qapi-schema/args-unknown.json +0 -4
index 12666dc..32aba43 100644
@@ -1,6 +1,2 @@
 # we reject data if it does not contain a known type
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': 'NoSuchType' }
tests/qapi-schema/bad-base.err +0 -1
index e668761..154274b 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-base.json:10: 'base' for struct 'MyType' cannot use

union type 'Union'
+tests/qapi-schema/bad-base.json:3: 'base' for struct 'MyType' cannot use union type 'Union'

tests/qapi-schema/bad-base.json +0 -7
index c3faa82..a634331 100644
@@ -1,10 +1,3 @@
 # we reject a base that is not a struct
-
-##
-# @Union:
-##
 { 'union': 'Union', 'data': { 'a': 'int', 'b': 'str' } }
-##
-# @MyType:
-##
 { 'struct': 'MyType', 'base': 'Union', 'data': { 'c': 'int' } }
tests/qapi-schema/bad-data.err +0 -1
index c1b9e35..8523ac4 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-data.json:6: 'data' for command 'oops' cannot be an

array
+tests/qapi-schema/bad-data.json:2: 'data' for command 'oops' cannot be an array

tests/qapi-schema/bad-data.json +0 -4
index 51c444f..832eeb7 100644
@@ -1,6 +1,2 @@
 # we ensure 'data' is a dictionary for all but enums
-
-##
-# @oops:
-##
 { 'command': 'oops', 'data': [ ] }
tests/qapi-schema/bad-ident.err +0 -1
index b757aa2..c419060 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-ident.json:6: 'struct' does not allow optional name

'*oops'
+tests/qapi-schema/bad-ident.json:2: 'struct' does not allow optional name '*oops'

tests/qapi-schema/bad-ident.json +0 -4
index b43df7a..763627a 100644
@@ -1,6 +1,2 @@
 # we reject creating a type name with bad name
-
-##
-# @*oops:
-##
 { 'struct': '*oops', 'data': { 'i': 'int' } }
tests/qapi-schema/bad-type-bool.err +0 -1
index 72e026b..62fd70b 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-type-bool.json:6: 'struct' key must have a string

value
+tests/qapi-schema/bad-type-bool.json:2: 'struct' key must have a string value

tests/qapi-schema/bad-type-bool.json +0 -4
index 1f9eddf..bde17b5 100644
@@ -1,6 +1,2 @@
 # we reject an expression with a metatype that is not a string
-
-##
-# @true:
-##
 { 'struct': true, 'data': { } }
tests/qapi-schema/bad-type-dict.err +0 -1
index d0d1f60..0b2a2ae 100644
@@ -1 +1 @@
-tests/qapi-schema/bad-type-dict.json:6: 'command' key must have a string

value
+tests/qapi-schema/bad-type-dict.json:2: 'command' key must have a string value

tests/qapi-schema/bad-type-dict.json +0 -4
index 5952caa..2a91b24 100644
@@ -1,6 +1,2 @@
 # we reject an expression with a metatype that is not a string
-
-##
-# @foo:
-##
 { 'command': { } }
tests/qapi-schema/base-cycle-direct.err +1 -1
index dd7f5aa..9c68f65 100644
@@ -1 +1 @@
-tests/qapi-schema/base-cycle-direct.json:6: Object Loopy contains itself
+tests/qapi-schema/base-cycle-direct.json:2: Object Loopy contains itself
tests/qapi-schema/base-cycle-direct.json +0 -4
index 9780f7e..4fc66d0 100644
@@ -1,6 +1,2 @@
 # we reject a loop in base classes
-
-##
-# @Loopy:
-##
 { 'struct': 'Loopy', 'base': 'Loopy', 'data': {} }
tests/qapi-schema/base-cycle-indirect.err +1 -1
index f4198e4..fc92fe4 100644
@@ -1 +1 @@
-tests/qapi-schema/base-cycle-indirect.json:6: Object Base1 contains itself
+tests/qapi-schema/base-cycle-indirect.json:2: Object Base1 contains itself
tests/qapi-schema/base-cycle-indirect.json +0 -7
index 99926c4..2866772 100644
@@ -1,10 +1,3 @@
 # we reject a loop in base classes
-
-##
-# @Base1:
-##
 { 'struct': 'Base1', 'base': 'Base2', 'data': {} }
-##
-# @Base2:
-##
 { 'struct': 'Base2', 'base': 'Base1', 'data': {} }
tests/qapi-schema/command-int.err +1 -1
index 3c834a9..0f93006 100644
@@ -1 +1 @@
-tests/qapi-schema/command-int.json:6: built-in 'int' is already defined
+tests/qapi-schema/command-int.json:2: built-in 'int' is already defined
tests/qapi-schema/command-int.json +0 -4
index 5b51bf1..9a62554 100644
@@ -1,6 +1,2 @@
 # we reject collisions between commands and types
-
-##
-# @int:
-##
 { 'command': 'int', 'data': { 'character': 'str' } }
tests/qapi-schema/comments.json +0 -4
index d31ef0d..e643f3a 100644
@@ -1,8 +1,4 @@
 # Unindented comment
-
-##
-# @Status:
-##
 { 'enum': 'Status',             # Comment to the right of code
   # Indented comment
   'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/comments.out +0 -0
index a962fb2..5d7c13c 100644
@@ -2,4 +2,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict',

'qlist', 'qfloat', 'qbo
prefix QTYPE
enum Status ['good', 'bad', 'ugly']
object q_empty

tests/qapi-schema/comments.out +0 -1
-doc symbol=Status expr=('enum', 'Status')
tests/qapi-schema/double-type.err +0 -1
index 424df9b..f9613c6 100644
@@ -1 +1 @@
-tests/qapi-schema/double-type.json:6: Unknown key 'command' in struct

'bar'
+tests/qapi-schema/double-type.json:2: Unknown key 'command' in struct 'bar'

tests/qapi-schema/double-type.json +0 -4
index ab59523..911fa7a 100644
@@ -1,6 +1,2 @@
 # we reject an expression with ambiguous metatype
-
-##
-# @foo:
-##
 { 'command': 'foo', 'struct': 'bar', 'data': { } }
tests/qapi-schema/enum-bad-name.err +0 -1
index 157d1b0..9c3c100 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-bad-name.json:6: Member of enum 'MyEnum' uses

invalid name 'not^possible' +tests/qapi-schema/enum-bad-name.json:2: Member of enum 'MyEnum' uses invalid name 'not^possible'

tests/qapi-schema/enum-bad-name.json +0 -4
index 978cb88..8506562 100644
@@ -1,6 +1,2 @@
 # we ensure all enum names can map to C
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ 'not^possible' ] }
tests/qapi-schema/enum-bad-prefix.err +0 -1
index 918915f..399f5f7 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-bad-prefix.json:6: Enum 'MyEnum' requires a string

for 'prefix'
+tests/qapi-schema/enum-bad-prefix.json:2: Enum 'MyEnum' requires a string for 'prefix'

tests/qapi-schema/enum-bad-prefix.json +0 -4
index 25f17a7..996f628 100644
@@ -1,6 +1,2 @@
 # The prefix must be a string type
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ 'one' ], 'prefix': [ 'fish' ] }
tests/qapi-schema/enum-clash-member.err +0 -1
index 25249b6..5403c78 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-clash-member.json:6: 'one_two' (member of MyEnum)

collides with 'one-two' (member of MyEnum) +tests/qapi-schema/enum-clash-member.json:2: 'one_two' (member of MyEnum) collides with 'one-two' (member of MyEnum)

tests/qapi-schema/enum-clash-member.json +0 -4
index fd52751..b6928b8 100644
@@ -1,6 +1,2 @@
 # we reject enums where members will clash when mapped to C enum
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ 'one-two', 'one_two' ] }
tests/qapi-schema/enum-dict-member.err +0 -1
index 9b7d2f1..8ca146e 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-dict-member.json:6: Member of enum 'MyEnum'

requires a string name +tests/qapi-schema/enum-dict-member.json:2: Member of enum 'MyEnum' requires a string name

tests/qapi-schema/enum-dict-member.json +0 -4
index 69d30f0..79672e0 100644
@@ -1,6 +1,2 @@
 # we reject any enum member that is not a string
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': [ { 'value': 'str' } ] }
tests/qapi-schema/enum-member-case.err +0 -1
index df96e22..b652e9a 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-member-case.json:10: 'Value' (member of

NoWayThisWillGetWhitelisted) should not use uppercase +tests/qapi-schema/enum-member-case.json:3: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase

tests/qapi-schema/enum-member-case.json +0 -7
index d2e4aba..2096b35 100644
@@ -1,10 +1,3 @@
 # Member names should be 'lower-case' unless the enum is whitelisted
-
-##
-# @UuidInfo:
-##
 { 'enum': 'UuidInfo', 'data': [ 'Value' ] } # UuidInfo is whitelisted
-##
-# @NoWayThisWillGetWhitelisted:
-##
 { 'enum': 'NoWayThisWillGetWhitelisted', 'data': [ 'Value' ] }
tests/qapi-schema/enum-missing-data.err +0 -1
index de4b9e8..ba4873a 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-missing-data.json:6: Key 'data' is missing from

enum 'MyEnum'
+tests/qapi-schema/enum-missing-data.json:2: Key 'data' is missing from enum 'MyEnum'

tests/qapi-schema/enum-missing-data.json +0 -4
index d7601f9..558fd35 100644
@@ -1,6 +1,2 @@
 # we require that all QAPI enums have a data array
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum' }
tests/qapi-schema/enum-wrong-data.err +0 -1
index c44e9b5..11b4347 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-wrong-data.json:6: Enum 'MyEnum' requires an array

for 'data'
+tests/qapi-schema/enum-wrong-data.json:2: Enum 'MyEnum' requires an array for 'data'

tests/qapi-schema/enum-wrong-data.json +0 -4
index 4b9e978..7b3e255 100644
@@ -1,6 +1,2 @@
 # we require that all qapi enums have an array for data
-
-##
-# @MyEnum:
-##
 { 'enum': 'MyEnum', 'data': { 'value': 'str' } }
tests/qapi-schema/event-boxed-empty.err +1 -1
index defe656..68ec6f2 100644
@@ -1 +1 @@
-tests/qapi-schema/event-boxed-empty.json:6: Use of 'boxed' requires 'data'
+tests/qapi-schema/event-boxed-empty.json:2: Use of 'boxed' requires 'data'
tests/qapi-schema/event-boxed-empty.json +0 -4
index 63b870b..cb145f1 100644
@@ -1,6 +1,2 @@
 # 'boxed' requires a non-empty type
-
-##
-# @FOO:
-##
 { 'event': 'FOO', 'boxed': true }
tests/qapi-schema/event-case.json +0 -0
index 6b05c5d..3a92d8b 100644
@@ -1,7 +1,3 @@
 # TODO: might be nice to enforce naming conventions; but until then this

works

 # even though events should usually be ALL_CAPS
tests/qapi-schema/event-case.json +0 -4
-
-##
-# @oops:
-##
 { 'event': 'oops' }
tests/qapi-schema/event-case.out +0 -0
index 2865714..5a0f2bf 100644
@@ -3,4 +3,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict',

'qlist', 'qfloat', 'qbo
event oops None
boxed=False
object q_empty

tests/qapi-schema/event-case.out +0 -1
-doc symbol=oops expr=('event', 'oops')
tests/qapi-schema/event-nest-struct.err +0 -1
index 17a6c3c..5a42701 100644
@@ -1 +1 @@
-tests/qapi-schema/event-nest-struct.json:5: Member 'a' of 'data' for

event 'EVENT_A' should be a type name +tests/qapi-schema/event-nest-struct.json:1: Member 'a' of 'data' for event 'EVENT_A' should be a type name

tests/qapi-schema/event-nest-struct.json +0 -4
index 328e0a6..ee6f3ec 100644
@@ -1,6 +1,2 @@
-##
-# @EVENT_A:
-# event-nest-struct
-##
 { 'event': 'EVENT_A',
   'data': { 'a' : { 'string' : 'str', 'integer': 'int' }, 'b' : 'str' } }
tests/qapi-schema/flat-union-array-branch.err +0 -1
index e456094..8ea91ea 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-array-branch.json:20: Member 'value1' of

union 'TestUnion' cannot be an array +tests/qapi-schema/flat-union-array-branch.json:8: Member 'value1' of union 'TestUnion' cannot be an array

tests/qapi-schema/flat-union-array-branch.json +0 -12
index 51dde10..0b98820 100644
@@ -1,22 +1,10 @@
-##
-# @TestEnum:
-##
 # we require flat union branches to be a struct
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-bad-base.err +0 -1
index 072ffba..bee24a2 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-bad-base.json:21: 'string' (member of

TestTypeA) collides with 'string' (base of TestUnion) +tests/qapi-schema/flat-union-bad-base.json:8: 'string' (member of TestTypeA) collides with 'string' (base of TestUnion)

tests/qapi-schema/flat-union-bad-base.json +0 -13
index 7713e7f..74dd421 100644
@@ -1,23 +1,10 @@
 # we allow anonymous base, but enforce no duplicate keys
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': { 'enum1': 'TestEnum', 'string': 'str' },
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-bad-discriminator.err +0 -1
index 1be4e7b..c38cc8e 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-bad-discriminator.json:27: Discriminator of

flat union 'TestUnion' requires a string name +tests/qapi-schema/flat-union-bad-discriminator.json:11: Discriminator of flat union 'TestUnion' requires a string name

tests/qapi-schema/flat-union-bad-discriminator.json +0 -0
index ef92f9b..cd10b9d 100644
@@ -1,29 +1,13 @@
 # we require the discriminator to be a string naming a base-type member
 # this tests the old syntax for anonymous unions before we added

alternates

tests/qapi-schema/flat-union-bad-discriminator.json +0 -16
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum', 'kind': 'str' } }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': {},
tests/qapi-schema/flat-union-base-any.err +0 -1
index c1ea2d7..646f1c9 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-base-any.json:21: 'base' for union

'TestUnion' cannot use built-in type 'any' +tests/qapi-schema/flat-union-base-any.json:8: 'base' for union 'TestUnion' cannot use built-in type 'any'

tests/qapi-schema/flat-union-base-any.json +0 -13
index 3dfb02f..fe66b71 100644
@@ -1,23 +1,10 @@
 # we require the base to be an existing struct
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'any',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-base-union.err +0 -1
index ccc5e85..f138395 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-base-union.json:30: 'base' for union

'TestUnion' cannot use union type 'UnionBase' +tests/qapi-schema/flat-union-base-union.json:14: 'base' for union 'TestUnion' cannot use union type 'UnionBase'

tests/qapi-schema/flat-union-base-union.json +0 -16
index c63c613..98b4eba 100644
@@ -2,31 +2,15 @@
 # TODO: It would be possible to allow a union as a base, as long as all
 # permutations of QMP names exposed by base do not clash with any QMP
 # member names added by local variants.
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @UnionBase:
-##
 { 'union': 'UnionBase',
   'data': { 'kind1': 'TestTypeA',
             'kind2': 'TestTypeB' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'UnionBase',
   'discriminator': 'type',
tests/qapi-schema/flat-union-clash-member.err +0 -1
index fe12a07..2adf697 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-clash-member.json:27: 'name' (member of

Branch1) collides with 'name' (member of Base) +tests/qapi-schema/flat-union-clash-member.json:11: 'name' (member of Branch1) collides with 'name' (member of Base)

tests/qapi-schema/flat-union-clash-member.json +0 -16
index 9000b94..9efc771 100644
@@ -1,29 +1,13 @@
 # We check for no duplicate keys between branch members and base
 # base's member 'name' clashes with Branch1's
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum', '*name': 'str' } }
-##
-# @Branch1:
-##
 { 'struct': 'Branch1',
   'data': { 'name': 'str' } }
-##
-# @Branch2:
-##
 { 'struct': 'Branch2',
   'data': { 'value': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-empty.err +0 -1
index ead7bd4..15754f5 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-empty.json:14: Union 'Union' cannot have

empty 'data'
+tests/qapi-schema/flat-union-empty.json:4: Union 'Union' cannot have empty 'data'

tests/qapi-schema/flat-union-empty.json +0 -10
index afa8988..77f1d9a 100644
@@ -1,14 +1,4 @@
 # flat unions cannot be empty
-
-##
-# @Empty:
-##
 { 'enum': 'Empty', 'data': [ ] }
-##
-# @Base:
-##
 { 'struct': 'Base', 'data': { 'type': 'Empty' } }
-##
-# @Union:
-##
 { 'union': 'Union', 'base': 'Base', 'discriminator': 'type', 'data': { } }
tests/qapi-schema/flat-union-incomplete-branch.err +0 -1
index c655bbf..e826bf0 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-incomplete-branch.json:16: Union 'TestUnion'

data missing 'value2' branch +tests/qapi-schema/flat-union-incomplete-branch.json:6: Union 'TestUnion' data missing 'value2' branch

tests/qapi-schema/flat-union-incomplete-branch.json +0 -10
index dea0377..25a411b 100644
@@ -1,18 +1,8 @@
 # we require all branches of the union to be covered
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': { 'type': 'TestEnum' },
   'discriminator': 'type',
tests/qapi-schema/flat-union-inline.err +0 -1
index c2c3f76..2333358 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-inline.json:17: Member 'value1' of union

'TestUnion' should be a type name +tests/qapi-schema/flat-union-inline.json:7: Member 'value1' of union 'TestUnion' should be a type name

tests/qapi-schema/flat-union-inline.json +0 -10
index 400f081..62c7cda 100644
@@ -1,19 +1,9 @@
 # we require branches to be a struct name
 # TODO: should we allow anonymous inline branch types?
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum', 'kind': 'str' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-int-branch.err +0 -1
index 299cbb2..faf0157 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-int-branch.json:21: Member 'value1' of union

'TestUnion' cannot use built-in type 'int' +tests/qapi-schema/flat-union-int-branch.json:8: Member 'value1' of union 'TestUnion' cannot use built-in type 'int'

tests/qapi-schema/flat-union-int-branch.json +0 -13
index 9603e17..9370c34 100644
@@ -1,23 +1,10 @@
 # we require flat union branches to be a struct
-
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { 'enum1': 'TestEnum' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'Base',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-invalid-branch-key.err +0 -1
index 455f2dc..ccf72d2 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-invalid-branch-key.json:28: Discriminator

value 'value_wrong' is not found in enum 'TestEnum' +tests/qapi-schema/flat-union-invalid-branch-key.json:13: Discriminator value 'value_wrong' is not found in enum 'TestEnum'

tests/qapi-schema/flat-union-invalid-branch-key.json +0 -15
index 00f2896..95ff774 100644
@@ -1,30 +1,15 @@
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum' } }
 
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': 'enum1',
tests/qapi-schema/flat-union-invalid-discriminator.err +0 -1
index f0e427b..5f40556 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-invalid-discriminator.json:28: Discriminator

'enum_wrong' is not a member of base struct 'TestBase' +tests/qapi-schema/flat-union-invalid-discriminator.json:13: Discriminator 'enum_wrong' is not a member of base struct 'TestBase'

tests/qapi-schema/flat-union-invalid-discriminator.json +0 -15
index c8700c7..48b94c3 100644
@@ -1,30 +1,15 @@
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum' } }
 
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': 'enum_wrong',
tests/qapi-schema/flat-union-no-base.err +0 -1
index a2d0a81..841c93b 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-no-base.json:22: Flat union 'TestUnion' must

have a base
+tests/qapi-schema/flat-union-no-base.json:9: Flat union 'TestUnion' must have a base

tests/qapi-schema/flat-union-no-base.json +0 -13
index 641f68a..ffc4c6f 100644
@@ -1,24 +1,11 @@
 # flat unions require a base
 # TODO: simple unions should be able to use an enum discriminator
-
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
-##
-# @Enum:
-##
 { 'enum': 'Enum',
   'data': [ 'value1', 'value2' ] }
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'discriminator': 'Enum',
   'data': { 'value1': 'TestTypeA',
tests/qapi-schema/flat-union-optional-discriminator.err +0 -1
index e15f856..aaabedb 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-optional-discriminator.json:19:

Discriminator of flat union 'MyUnion' does not allow optional name '*switch' +tests/qapi-schema/flat-union-optional-discriminator.json:6: Discriminator of flat union 'MyUnion' does not allow optional name '*switch'

tests/qapi-schema/flat-union-optional-discriminator.json +0 -13
index 9f19af5..08a8f7e 100644
@@ -1,21 +1,8 @@
 # we require the discriminator to be non-optional
-
-##
-# @Enum:
-##
 { 'enum': 'Enum', 'data': [ 'one', 'two' ] }
-##
-# @Base:
-##
 { 'struct': 'Base',
   'data': { '*switch': 'Enum' } }
-##
-# @Branch:
-##
 { 'struct': 'Branch', 'data': { 'name': 'str' } }
-##
-# @MyUnion:
-##
 { 'union': 'MyUnion',
   'base': 'Base',
   'discriminator': '*switch',
tests/qapi-schema/flat-union-string-discriminator.err +0 -1
index bc0c133..200016b 100644
@@ -1 +1 @@
-tests/qapi-schema/flat-union-string-discriminator.json:28: Discriminator

'kind' must be of enumeration type +tests/qapi-schema/flat-union-string-discriminator.json:13: Discriminator 'kind' must be of enumeration type

tests/qapi-schema/flat-union-string-discriminator.json +0 -15
index 47a17d2..8af6033 100644
@@ -1,30 +1,15 @@
-##
-# @TestEnum:
-##
 { 'enum': 'TestEnum',
   'data': [ 'value1', 'value2' ] }
 
-##
-# @TestBase:
-##
 { 'struct': 'TestBase',
   'data': { 'enum1': 'TestEnum', 'kind': 'str' } }
 
-##
-# @TestTypeA:
-##
 { 'struct': 'TestTypeA',
   'data': { 'string': 'str' } }
 
-##
-# @TestTypeB:
-##
 { 'struct': 'TestTypeB',
   'data': { 'integer': 'int' } }
 
-##
-# @TestUnion:
-##
 { 'union': 'TestUnion',
   'base': 'TestBase',
   'discriminator': 'kind',
tests/qapi-schema/ident-with-escape.json +0 -4
index c03404b..5661750 100644
@@ -1,8 +1,4 @@
 # we allow escape sequences in strings, if they map back to ASCII
 # { 'command': 'fooA', 'data': { 'bar1': 'str' } }
-
-##
-# @fooA:
-##
 { 'c\u006fmmand': '\u0066\u006f\u006FA',
   'd\u0061ta': { '\u0062\u0061\u00721': '\u0073\u0074\u0072' } }
tests/qapi-schema/ident-with-escape.out +0 -1
index 69fc908..1d2722c 100644
@@ -5,4 +5,3 @@ command fooA q_obj_fooA-arg -> None
 object q_empty
 object q_obj_fooA-arg
     member bar1: str optional=False
-doc symbol=fooA expr=('command', 'fooA')
tests/qapi-schema/include-relpath-sub.json +0 -3
index b4bd8a2..4bd4af4 100644
@@ -1,5 +1,2 @@
-##
-# @Status:
-##
 { 'enum': 'Status',
   'data': [ 'good', 'bad', 'ugly' ] }
tests/qapi-schema/include-relpath.out +0 -0
index a962fb2..5d7c13c 100644
@@ -2,4 +2,3 @@ enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict',

'qlist', 'qfloat', 'qbo
prefix QTYPE
enum Status ['good', 'bad', 'ugly']
object q_empty

tests/qapi-schema/include-relpath.out +0 -1
-doc symbol=Status expr=('enum', 'Status')
(quoted diff) +0 -0
Signature · 1 line
Marc-André Lureau
#11 lore raw

Re: [Qemu-devel] [PATCH for-2.9 03/47] qapi: Back out doc comments added just to please qapi.py

Quoted 5 lines · Marc-André Lureau

Hi

On Mon, Mar 13, 2017 at 10:36 AM Markus Armbruster <[email protected]> wrote:

Quoted 7 lines
Quoted 4 lines

This reverts commit 3313b61's changes to tests/qapi-schema/, except for tests/qapi-schema/doc-*.

Do we expect those files to change? If not, or not much, I think i't s rather better to keep the docs to exercise the parser in various situations.

Point taken, but I think the proper way to exercise doc comments is systematic test cases in qapi-schema-test.json, or perhaps a separate test schema we create just for exercising doc comments. Probably should include a qapi2texi.py run complete with diff to golden .texi.

Quoted 3 lines

It doesn't reduce the merits of the doc pragma though for other
cases, which I wish I would have suggested (but I didn't like the initial series to grow more features)

We were both pretty desperate to get your work in without further delays.

#12 lore raw

PATCH 4/47 docs/qapi-code-gen.txt: Drop confusing reference to 'gen'

In reply to Markus Armbruster

Section "Commands" qualifies its rules on permitted argument and return types "with one exception noted below when 'gen' is used". The note went away in commit 2d21291. Clean up the dangling references.

---
 docs/qapi-code-gen.txt | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
docs/qapi-code-gen.txt +8 -10
index 88de5c7..d9c1f91 100644
@@ -555,22 +555,20 @@ The 'data' argument maps to the "arguments" dictionary passed in as
 part of a Client JSON Protocol command.  The 'data' member is optional
 and defaults to {} (an empty dictionary).  If present, it must be the
 string name of a complex type, or a dictionary that declares an
-anonymous type with the same semantics as a 'struct' expression, with
-one exception noted below when 'gen' is used.
+anonymous type with the same semantics as a 'struct' expression.
 
 The 'returns' member describes what will appear in the "return" member
 of a Client JSON Protocol reply on successful completion of a command.
 The member is optional from the command declaration; if absent, the
 "return" member will be an empty dictionary.  If 'returns' is present,
 it must be the string name of a complex or built-in type, a
-one-element array containing the name of a complex or built-in type,
-with one exception noted below when 'gen' is used.  Although it is
-permitted to have the 'returns' member name a built-in type or an
-array of built-in types, any command that does this cannot be extended
-to return additional information in the future; thus, new commands
-should strongly consider returning a dictionary-based type or an array
-of dictionaries, even if the dictionary only contains one member at the
-present.
+one-element array containing the name of a complex or built-in type.
+Although it is permitted to have the 'returns' member name a built-in
+type or an array of built-in types, any command that does this cannot
+be extended to return additional information in the future; thus, new
+commands should strongly consider returning a dictionary-based type or
+an array of dictionaries, even if the dictionary only contains one
+member at the present.
 
 All commands in Client JSON Protocol use a dictionary to report
 failure, with no way to specify that in QAPI.  Where the error return
Signature · 1 line
2.7.4
Reviewed-by on v1 4/47
#13 lore raw

Re: [Qemu-devel] [PATCH for-2.9 04/47] docs/qapi-code-gen.txt: Drop confusing reference to 'gen'

Quoted 9 lines · Markus Armbruster

Section "Commands" qualifies its rules on permitted argument and return types "with one exception noted below when 'gen' is used". The note went away in commit 2d21291. Clean up the dangling references.

---
 docs/qapi-code-gen.txt | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Reviewed-by on v1 4/47
#14 lore raw

Re: [Qemu-devel] [PATCH for-2.9 04/47] docs/qapi-code-gen.txt: Drop confusing reference to 'gen'

In reply to Markus Armbruster

Hi

Quoted 6 lines · Markus Armbruster

Section "Commands" qualifies its rules on permitted argument and return types "with one exception noted below when 'gen' is used". The note went away in commit 2d21291. Clean up the dangling references.

Quoted 44 lines
---
 docs/qapi-code-gen.txt | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
docs/qapi-code-gen.txt +0 -0
index 88de5c7..d9c1f91 100644
@@ -555,22 +555,20 @@ The 'data' argument maps to the "arguments"

dictionary passed in as
part of a Client JSON Protocol command. The 'data' member is optional and defaults to {} (an empty dictionary). If present, it must be the string name of a complex type, or a dictionary that declares an

docs/qapi-code-gen.txt +8 -11
-anonymous type with the same semantics as a 'struct' expression, with
-one exception noted below when 'gen' is used.
+anonymous type with the same semantics as a 'struct' expression.
 
 The 'returns' member describes what will appear in the "return" member
 of a Client JSON Protocol reply on successful completion of a command.
 The member is optional from the command declaration; if absent, the
 "return" member will be an empty dictionary.  If 'returns' is present,
 it must be the string name of a complex or built-in type, a
-one-element array containing the name of a complex or built-in type,
-with one exception noted below when 'gen' is used.  Although it is
-permitted to have the 'returns' member name a built-in type or an
-array of built-in types, any command that does this cannot be extended
-to return additional information in the future; thus, new commands
-should strongly consider returning a dictionary-based type or an array
-of dictionaries, even if the dictionary only contains one member at the
-present.
+one-element array containing the name of a complex or built-in type.
+Although it is permitted to have the 'returns' member name a built-in
+type or an array of built-in types, any command that does this cannot
+be extended to return additional information in the future; thus, new
+commands should strongly consider returning a dictionary-based type or
+an array of dictionaries, even if the dictionary only contains one
+member at the present.
 
 All commands in Client JSON Protocol use a dictionary to report
 failure, with no way to specify that in QAPI.  Where the error return
--

2.7.4

Quoted 1 line

--

Marc-André Lureau

#15 lore raw

PATCH 5/47 qapi: Have each QAPI schema declare its returns white-list

In reply to Markus Armbruster

qapi.py has a hardcoded white-list of command names that may violate the rules on permitted return types. Add a new pragma directive 'returns-whitelist', and use it to replace the hard-coded white-list.

---
 docs/qapi-code-gen.txt                   | 13 +++++++------
 qapi-schema.json                         | 12 ++++++++++++
 qga/qapi-schema.json                     | 15 +++++++++++++++
 scripts/qapi.py                          | 30 +++++++++---------------------
 tests/qapi-schema/qapi-schema-test.json  |  7 +++++++
 tests/qapi-schema/returns-whitelist.err  |  2 +-
 tests/qapi-schema/returns-whitelist.json |  4 ++++
 7 files changed, 55 insertions(+), 28 deletions(-)
docs/qapi-code-gen.txt +7 -6
index d9c1f91..e907e57 100644
@@ -315,6 +315,9 @@ The dictionary's entries are pragma names and values.
 Pragma 'doc-required' takes a boolean value.  If true, documentation
 is required.  Default is false.
 
+Pragma 'returns-whitelist' takes a list of command names that may
+violate the rules on permitted return types.  Default is none.
+
 
 === Struct types ===
 
@@ -563,12 +566,10 @@ The member is optional from the command declaration; if absent, the
 "return" member will be an empty dictionary.  If 'returns' is present,
 it must be the string name of a complex or built-in type, a
 one-element array containing the name of a complex or built-in type.
-Although it is permitted to have the 'returns' member name a built-in
-type or an array of built-in types, any command that does this cannot
-be extended to return additional information in the future; thus, new
-commands should strongly consider returning a dictionary-based type or
-an array of dictionaries, even if the dictionary only contains one
-member at the present.
+To return anything else, you have to list the command in pragma
+'returns-whitelist'.  If you do this, the command cannot be extended
+to return additional information in the future.  Use of
+'returns-whitelist' for new commands is strongly discouraged.
 
 All commands in Client JSON Protocol use a dictionary to report
 failure, with no way to specify that in QAPI.  Where the error return
qapi-schema.json +12 -0
index d5438ee..93e9e98 100644
@@ -51,6 +51,18 @@
 
 { 'pragma': { 'doc-required': true } }
 
+# Whitelists to permit QAPI rule violations; think twice before you
+# add to them!
+{ 'pragma': {
+    # Commands allowed to return a non-dictionary:
+    'returns-whitelist': [
+        'human-monitor-command',
+        'qom-get',
+        'query-migrate-cache-size',
+        'query-tpm-models',
+        'query-tpm-types',
+        'ringbuf-read' ] } }
+
 # QAPI common definitions
 { 'include': 'qapi/common.json' }
 
qga/qapi-schema.json +15 -0
index 3f3d428..a8e4bda 100644
@@ -13,6 +13,21 @@
 
 { 'pragma': { 'doc-required': true } }
 
+# Whitelists to permit QAPI rule violations; think twice before you
+# add to them!
+{ 'pragma': {
+    # Commands allowed to return a non-dictionary:
+    'returns-whitelist': [
+        'guest-file-open',
+        'guest-fsfreeze-freeze',
+        'guest-fsfreeze-freeze-list',
+        'guest-fsfreeze-status',
+        'guest-fsfreeze-thaw',
+        'guest-get-time',
+        'guest-set-vcpus',
+        'guest-sync',
+        'guest-sync-delimited' ] } }
+
 ##
 # @guest-sync-delimited:
 #
scripts/qapi.py +9 -21
index 29a8b77..a90b682 100644
@@ -41,26 +41,7 @@ builtin_types = {
 doc_required = False
 
 # Whitelist of commands allowed to return a non-dictionary
-returns_whitelist = [
-    # From QMP:
-    'human-monitor-command',
-    'qom-get',
-    'query-migrate-cache-size',
-    'query-tpm-models',
-    'query-tpm-types',
-    'ringbuf-read',
-
-    # From QGA:
-    'guest-file-open',
-    'guest-fsfreeze-freeze',
-    'guest-fsfreeze-freeze-list',
-    'guest-fsfreeze-status',
-    'guest-fsfreeze-thaw',
-    'guest-get-time',
-    'guest-set-vcpus',
-    'guest-sync',
-    'guest-sync-delimited',
-]
+returns_whitelist = []
 
 # Whitelist of entities allowed to violate case conventions
 case_whitelist = [
@@ -317,12 +298,19 @@ class QAPISchemaParser(object):
         self.docs.extend(exprs_include.docs)
 
     def _pragma(self, name, value, info):
-        global doc_required
+        global doc_required, returns_whitelist
         if name == 'doc-required':
             if not isinstance(value, bool):
                 raise QAPISemError(info,
                                    "Pragma 'doc-required' must be boolean")
             doc_required = value
+        elif name == 'returns-whitelist':
+            if (not isinstance(value, list)
+                    or any([not isinstance(elt, str) for elt in value])):
+                raise QAPISemError(info,
+                                   "Pragma returns-whitelist must be"
+                                   " a list of strings")
+            returns_whitelist = value
         else:
             raise QAPISemError(info, "Unknown pragma '%s'" % name)
 
tests/qapi-schema/qapi-schema-test.json +7 -0
index 1719463..842ea3c 100644
@@ -3,6 +3,13 @@
 # This file is a stress test of supported qapi constructs that must
 # parse and compile correctly.
 
+# Whitelists to permit QAPI rule violations
+{ 'pragma': {
+    # Commands allowed to return a non-dictionary:
+    'returns-whitelist': [
+        'guest-get-time',
+        'guest-sync' ] } }
+
 { 'struct': 'TestStruct',
   'data': { 'integer': 'int', 'boolean': 'bool', 'string': 'str' } }
 
tests/qapi-schema/returns-whitelist.err +1 -1
index f47c1ee..b2ba7a9 100644
@@ -1 +1 @@
-tests/qapi-schema/returns-whitelist.json:10: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int'
+tests/qapi-schema/returns-whitelist.json:14: 'returns' for command 'no-way-this-will-get-whitelisted' cannot use built-in type 'int'
tests/qapi-schema/returns-whitelist.json +4 -0
index e8b3cea..da20932 100644
@@ -1,4 +1,8 @@
 # we enforce that 'returns' be a dict or array of dict unless whitelisted
+
+{ 'pragma': { 'returns-whitelist': [
+    'human-monitor-command', 'query-tpm-models', 'guest-get-time' ] } }
+
 { 'command': 'human-monitor-command',
   'data': {'command-line': 'str', '*cpu-index': 'int'},
   'returns': 'str' }
Signature · 1 line
2.7.4
Reviewed-by on v1 5/47
#16 lore raw

Re: [Qemu-devel] [PATCH for-2.9 05/47] qapi: Have each QAPI schema declare its returns white-list

Quoted 3 lines · Markus Armbruster

qapi.py has a hardcoded white-list of command names that may violate the rules on permitted return types. Add a new pragma directive 'returns-whitelist', and use it to replace the hard-coded white-list.

So now the list is per-client, rather than global. Nice idea!

Quoted 11 lines

---

+++ b/qapi-schema.json

qapi-schema.json +2 -0
@@ -51,6 +51,18 @@
 
 { 'pragma': { 'doc-required': true } }
 
+# Whitelists to permit QAPI rule violations; think twice before you
+# add to them!

qapi-schema.json line 65

Quoted 10 lines
qapi-schema.json +10 -0
+{ 'pragma': {
+    # Commands allowed to return a non-dictionary:
+    'returns-whitelist': [
+        'human-monitor-command',
+        'qom-get',
+        'query-migrate-cache-size',
+        'query-tpm-models',
+        'query-tpm-types',
+        'ringbuf-read' ] } }
+

If I'm understanding the code right, we could have also written this all as one pragma with a larger dict instead of two pragmas with one-element dicts:

{ 'pragma': { 'doc-required': true,

              'returns-whitelist': [ ... ] } }

But see below about another potential for rewriting that I thought of before reading your full patch [1]...

Quoted 7 lines
scripts/qapi.py +1 -1
@@ -317,12 +298,19 @@ class QAPISchemaParser(object):
         self.docs.extend(exprs_include.docs)
 
     def _pragma(self, name, value, info):
-        global doc_required
+        global doc_required, returns_whitelist
         if name == 'doc-required':

scripts/qapi.py class QAPISchemaParser(object): · line 312

Quoted 10 lines
scripts/qapi.py +6 -0
             if not isinstance(value, bool):
                 raise QAPISemError(info,
                                    "Pragma 'doc-required' must be boolean")
             doc_required = value
+        elif name == 'returns-whitelist':
+            if (not isinstance(value, list)
+                    or any([not isinstance(elt, str) for elt in value])):
+                raise QAPISemError(info,
+                                   "Pragma returns-whitelist must be"
+                                   " a list of strings")

Again, a new error message with no testsuite coverage.

scripts/qapi.py class QAPISchemaParser(object): · line 313

Quoted 1 line
scripts/qapi.py +1 -0
+            returns_whitelist = value

[1] Hmm, this precludes the converse direction of specifying things. You cannot usefully list the whitelist pragma more than once, because only the last one wins. Why would we want to allow it to be more than once? because we could do:

{ 'pragma': 'returns-whitelist': [ 'human-monitor-command' ] } { 'pragma': 'returns-whitelist': [ 'qom-get' ] }

and then spread out the uses of the pragma to be closer to the violations, rather than bunched up front.

Or maybe you want to consider rejecting a second whitelist, instead of silently losing the first one, if you want to force that all violations are bunched up front into a single pragma.

But that's food for thought - I'm leaving it up to you if you want to spin a v2 (making non-trivial changes based on my comments), or leave improvements (like any testsuite additions) for a followup patch. If you use this patch as-is, you can add:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#17 lore raw

Re: [Qemu-devel] [PATCH for-2.9 05/47] qapi: Have each QAPI schema declare its returns white-list

Quoted 33 lines · Eric Blake
Quoted 3 lines · Markus Armbruster

qapi.py has a hardcoded white-list of command names that may violate the rules on permitted return types. Add a new pragma directive 'returns-whitelist', and use it to replace the hard-coded white-list.

So now the list is per-client, rather than global. Nice idea!

Quoted 11 lines

---

+++ b/qapi-schema.json

qapi-schema.json +2 -0
@@ -51,6 +51,18 @@
 
 { 'pragma': { 'doc-required': true } }
 
+# Whitelists to permit QAPI rule violations; think twice before you
+# add to them!

qapi-schema.json line 65

Quoted 10 lines
qapi-schema.json +10 -0
+{ 'pragma': {
+    # Commands allowed to return a non-dictionary:
+    'returns-whitelist': [
+        'human-monitor-command',
+        'qom-get',
+        'query-migrate-cache-size',
+        'query-tpm-models',
+        'query-tpm-types',
+        'ringbuf-read' ] } }
+

If I'm understanding the code right, we could have also written this all as one pragma with a larger dict instead of two pragmas with one-element dicts:

Quoted 2 lines

{ 'pragma': { 'doc-required': true,

              'returns-whitelist': [ ... ] } }

Yes. Separating them let me make the comment stand out more.

Quoted 6 lines

But see below about another potential for rewriting that I thought of before reading your full patch [1]...

Quoted 3 lines
scripts/qapi.py +0 -0
@@ -317,12 +298,19 @@ class QAPISchemaParser(object):
         self.docs.extend(exprs_include.docs)
 
Quoted 16 lines
Quoted 4 lines
scripts/qapi.py +1 -1
     def _pragma(self, name, value, info):
-        global doc_required
+        global doc_required, returns_whitelist
         if name == 'doc-required':

scripts/qapi.py class QAPISchemaParser(object): · line 312

Quoted 10 lines
scripts/qapi.py +6 -0
             if not isinstance(value, bool):
                 raise QAPISemError(info,
                                    "Pragma 'doc-required' must be boolean")
             doc_required = value
+        elif name == 'returns-whitelist':
+            if (not isinstance(value, list)
+                    or any([not isinstance(elt, str) for elt in value])):
+                raise QAPISemError(info,
+                                   "Pragma returns-whitelist must be"
+                                   " a list of strings")

Again, a new error message with no testsuite coverage.

Okay.

    $ git-ls-files tests/qapi-schema/ | grep -c 'json$'
    157

What's half a dozen more...

Quoted 10 lines

scripts/qapi.py class QAPISchemaParser(object): · line 313

Quoted 1 line
scripts/qapi.py +1 -0
+            returns_whitelist = value

[1] Hmm, this precludes the converse direction of specifying things. You cannot usefully list the whitelist pragma more than once, because only the last one wins. Why would we want to allow it to be more than once? because we could do:

{ 'pragma': 'returns-whitelist': [ 'human-monitor-command' ] } { 'pragma': 'returns-whitelist': [ 'qom-get' ] }

Quoted 6 lines

and then spread out the uses of the pragma to be closer to the violations, rather than bunched up front.

Or maybe you want to consider rejecting a second whitelist, instead of silently losing the first one, if you want to force that all violations are bunched up front into a single pragma.

Where to put the pragma is a question of style. As is, the patch supports only "put them first", because we actually use the white-list in a later pass, where only the last pragma value is visible. To fix that, we'd have to compute *current* pragma values throughout that later pass.

As long as we don't, accepting only one whitelist is better than silently ignoring all but the last.

Computing current pragma values shouldn't be hard, but I'm not sure it's worthwhile.

Quoted 6 lines

But that's food for thought - I'm leaving it up to you if you want to spin a v2 (making non-trivial changes based on my comments), or leave improvements (like any testsuite additions) for a followup patch. If you use this patch as-is, you can add:

Thanks!

#18 lore raw

PATCH 6/47 qapi: Have each QAPI schema declare its name rule violations

In reply to Markus Armbruster

qapi.py has a hardcoded white-list of type names that may violate the rule on use of upper and lower case. Add a new pragma directive 'name-case-whitelist', and use it to replace the hard-coded white-list.

---
 docs/qapi-code-gen.txt                  |  6 ++++++
 qapi-schema.json                        | 11 ++++++++++-
 scripts/qapi.py                         | 22 ++++++++++------------
 tests/qapi-schema/enum-member-case.err  |  2 +-
 tests/qapi-schema/enum-member-case.json |  1 +
 5 files changed, 28 insertions(+), 14 deletions(-)
docs/qapi-code-gen.txt +6 -0
index e907e57..349dc02 100644
@@ -252,6 +252,9 @@ Any name (command, event, type, member, or enum value) beginning with
 "x-" is marked experimental, and may be withdrawn or changed
 incompatibly in a future release.
 
+Pragma 'name-case-whitelist' lets you violate the rules on use of
+upper and lower case.  Use for new code is strongly discouraged.
+
 In the rest of this document, usage lines are given for each
 expression type, with literal strings written in lower case and
 placeholders written in capitals.  If a literal string includes a
@@ -318,6 +321,9 @@ is required.  Default is false.
 Pragma 'returns-whitelist' takes a list of command names that may
 violate the rules on permitted return types.  Default is none.
 
+Pragma 'name-case-whitelist' takes a list of names that may violate
+rules on use of upper- vs. lower-case letters.  Default is none.
+
 
 === Struct types ===
 
qapi-schema.json +10 -1
index 93e9e98..17c766e 100644
@@ -61,7 +61,16 @@
         'query-migrate-cache-size',
         'query-tpm-models',
         'query-tpm-types',
-        'ringbuf-read' ] } }
+        'ringbuf-read' ],
+    'name-case-whitelist': [
+        'ACPISlotType',         # DIMM, visible through query-acpi-ospm-status
+        'CpuInfoMIPS',          # PC, visible through query-cpu
+        'CpuInfoTricore',       # PC, visible through query-cpu
+        'QapiErrorClass',       # all members, visible through errors
+        'UuidInfo',             # UUID, visible through query-uuid
+        'X86CPURegister32',     # all members, visible indirectly through qom-get
+        'q_obj_CpuInfo-base'    # CPU, visible through query-cpu
+    ] } }
 
 # QAPI common definitions
 { 'include': 'qapi/common.json' }
scripts/qapi.py +10 -12
index a90b682..e98fd0c 100644
@@ -44,16 +44,7 @@ doc_required = False
 returns_whitelist = []
 
 # Whitelist of entities allowed to violate case conventions
-case_whitelist = [
-    # From QMP:
-    'ACPISlotType',         # DIMM, visible through query-acpi-ospm-status
-    'CpuInfoMIPS',          # PC, visible through query-cpu
-    'CpuInfoTricore',       # PC, visible through query-cpu
-    'QapiErrorClass',       # all members, visible through errors
-    'UuidInfo',             # UUID, visible through query-uuid
-    'X86CPURegister32',     # all members, visible indirectly through qom-get
-    'q_obj_CpuInfo-base',   # CPU, visible through query-cpu
-]
+name_case_whitelist = []
 
 enum_types = []
 struct_types = []
@@ -298,7 +289,7 @@ class QAPISchemaParser(object):
         self.docs.extend(exprs_include.docs)
 
     def _pragma(self, name, value, info):
-        global doc_required, returns_whitelist
+        global doc_required, returns_whitelist, name_case_whitelist
         if name == 'doc-required':
             if not isinstance(value, bool):
                 raise QAPISemError(info,
@@ -311,6 +302,13 @@ class QAPISchemaParser(object):
                                    "Pragma returns-whitelist must be"
                                    " a list of strings")
             returns_whitelist = value
+        elif name == 'name-case-whitelist':
+            if (not isinstance(value, list)
+                    or any([not isinstance(elt, str) for elt in value])):
+                raise QAPISemError(info,
+                                   "Pragma name-case-whitelist must be"
+                                   " a list of strings")
+            name_case_whitelist = value
         else:
             raise QAPISemError(info, "Unknown pragma '%s'" % name)
 
@@ -1283,7 +1281,7 @@ class QAPISchemaMember(object):
 
     def check_clash(self, info, seen):
         cname = c_name(self.name)
-        if cname.lower() != cname and self.owner not in case_whitelist:
+        if cname.lower() != cname and self.owner not in name_case_whitelist:
             raise QAPISemError(info,
                                "%s should not use uppercase" % self.describe())
         if cname in seen:
tests/qapi-schema/enum-member-case.err +1 -1
index b652e9a..3c67a3a 100644
@@ -1 +1 @@
-tests/qapi-schema/enum-member-case.json:3: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase
+tests/qapi-schema/enum-member-case.json:4: 'Value' (member of NoWayThisWillGetWhitelisted) should not use uppercase
tests/qapi-schema/enum-member-case.json +1 -0
index 2096b35..f8af3e4 100644
@@ -1,3 +1,4 @@
 # Member names should be 'lower-case' unless the enum is whitelisted
+{ 'pragma': { 'name-case-whitelist': [ 'UuidInfo' ] } }
 { 'enum': 'UuidInfo', 'data': [ 'Value' ] } # UuidInfo is whitelisted
 { 'enum': 'NoWayThisWillGetWhitelisted', 'data': [ 'Value' ] }
Signature · 1 line
2.7.4
Reviewed-by on v1 6/47
#19 lore raw

Re: [Qemu-devel] [PATCH for-2.9 06/47] qapi: Have each QAPI schema declare its name rule violations

Quoted 21 lines · Markus Armbruster

qapi.py has a hardcoded white-list of type names that may violate the rule on use of upper and lower case. Add a new pragma directive 'name-case-whitelist', and use it to replace the hard-coded white-list.

---
 docs/qapi-code-gen.txt                  |  6 ++++++
 qapi-schema.json                        | 11 ++++++++++-
 scripts/qapi.py                         | 22 ++++++++++------------
 tests/qapi-schema/enum-member-case.err  |  2 +-
 tests/qapi-schema/enum-member-case.json |  1 +
 5 files changed, 28 insertions(+), 14 deletions(-)

+++ b/qapi-schema.json

qapi-schema.json +0 -1
@@ -61,7 +61,16 @@
         'query-migrate-cache-size',
         'query-tpm-models',
         'query-tpm-types',
-        'ringbuf-read' ] } }

qapi-schema.json line 73

Quoted 10 lines
qapi-schema.json +10 -0
+        'ringbuf-read' ],
+    'name-case-whitelist': [
+        'ACPISlotType',         # DIMM, visible through query-acpi-ospm-status
+        'CpuInfoMIPS',          # PC, visible through query-cpu
+        'CpuInfoTricore',       # PC, visible through query-cpu
+        'QapiErrorClass',       # all members, visible through errors
+        'UuidInfo',             # UUID, visible through query-uuid
+        'X86CPURegister32',     # all members, visible indirectly through qom-get
+        'q_obj_CpuInfo-base'    # CPU, visible through query-cpu
+    ] } }

Interesting - here you bunch up 2 of the 3 pragmas into one dict, while still leaving the third related to documentation in its own dict.

That 'q_obj_CpuInfo-base' is ugly, and I had a patch around previously that used a saner name rather than making callers reverse-engineer the implicit naming rules. Related to my work on anonymous bases to flat unions, so I'll get to rebase that work and post it on top of yours. But not a show-stopper for this patch, where it is just moving the location.

scripts/qapi.py class QAPISchemaParser(object): · line 311

Quoted 11 lines
scripts/qapi.py +7 -0
@@ -311,6 +302,13 @@ class QAPISchemaParser(object):
                                    "Pragma returns-whitelist must be"
                                    " a list of strings")
             returns_whitelist = value
+        elif name == 'name-case-whitelist':
+            if (not isinstance(value, list)
+                    or any([not isinstance(elt, str) for elt in value])):
+                raise QAPISemError(info,
+                                   "Pragma name-case-whitelist must be"
+                                   " a list of strings")
+            name_case_whitelist = value

Same comments as before - new error message with no testsuite coverage, and no checking for duplicate assignment where last one silently wins; but where I'm okay with deferring if you don't want to delay 2.9 for a v2 respin.

So if you use it unchanged,

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#20 lore raw

Re: [Qemu-devel] [PATCH for-2.9 06/47] qapi: Have each QAPI schema declare its name rule violations

Quoted 36 lines · Eric Blake
Quoted 21 lines · Markus Armbruster

qapi.py has a hardcoded white-list of type names that may violate the rule on use of upper and lower case. Add a new pragma directive 'name-case-whitelist', and use it to replace the hard-coded white-list.

---
 docs/qapi-code-gen.txt                  |  6 ++++++
 qapi-schema.json                        | 11 ++++++++++-
 scripts/qapi.py                         | 22 ++++++++++------------
 tests/qapi-schema/enum-member-case.err  |  2 +-
 tests/qapi-schema/enum-member-case.json |  1 +
 5 files changed, 28 insertions(+), 14 deletions(-)

+++ b/qapi-schema.json

qapi-schema.json +0 -1
@@ -61,7 +61,16 @@
         'query-migrate-cache-size',
         'query-tpm-models',
         'query-tpm-types',
-        'ringbuf-read' ] } }

qapi-schema.json line 73

Quoted 10 lines
qapi-schema.json +10 -0
+        'ringbuf-read' ],
+    'name-case-whitelist': [
+        'ACPISlotType',         # DIMM, visible through query-acpi-ospm-status
+        'CpuInfoMIPS',          # PC, visible through query-cpu
+        'CpuInfoTricore',       # PC, visible through query-cpu
+        'QapiErrorClass',       # all members, visible through errors
+        'UuidInfo',             # UUID, visible through query-uuid
+        'X86CPURegister32',     # all members, visible indirectly through qom-get
+        'q_obj_CpuInfo-base'    # CPU, visible through query-cpu
+    ] } }

Interesting - here you bunch up 2 of the 3 pragmas into one dict, while still leaving the third related to documentation in its own dict.

Quoted 5 lines

That 'q_obj_CpuInfo-base' is ugly, and I had a patch around previously that used a saner name rather than making callers reverse-engineer the implicit naming rules. Related to my work on anonymous bases to flat unions, so I'll get to rebase that work and post it on top of yours. But not a show-stopper for this patch, where it is just moving the location.

... to a more visible place :)

Regarding flat unions: what I really want is unifying struct and both kinds of unions into a single object type. Something like

{ 'object': STRING, # type name
'*base': STRING-OR-DICT, # base type
'*data': DICT, # common members
'*tag': STRING, # tag name, must be in base or common
'*variant': DICT } # map tag value -> variant members

Introspection already works that way.

Note no sugar for "simple" unions. They become syntactically non-simple. Feature.

Flat unions become syntactically non-horrible.

Quoted 17 lines

scripts/qapi.py class QAPISchemaParser(object): · line 311

Quoted 11 lines
scripts/qapi.py +7 -0
@@ -311,6 +302,13 @@ class QAPISchemaParser(object):
                                    "Pragma returns-whitelist must be"
                                    " a list of strings")
             returns_whitelist = value
+        elif name == 'name-case-whitelist':
+            if (not isinstance(value, list)
+                    or any([not isinstance(elt, str) for elt in value])):
+                raise QAPISemError(info,
+                                   "Pragma name-case-whitelist must be"
+                                   " a list of strings")
+            name_case_whitelist = value

Same comments as before - new error message with no testsuite coverage, and no checking for duplicate assignment where last one silently wins; but where I'm okay with deferring if you don't want to delay 2.9 for a v2 respin.

Quoted 2 lines

So if you use it unchanged,

Thanks!

#21 lore raw

PATCH 7/47 qapi: Clean up build of generated documentation

In reply to Markus Armbruster

Rename intermediate qemu-qapi.texi to qemu-qmp-qapi.texi to match its user qemu-qmp-ref.texi, just like qemu-ga-qapi.texi matches qemu-ga-ref.texi.

Build the intermediate .texi next to the sources and the final output in docs/ instead of dumping them into the build root.

Fix version.texi dependencies so that only the targets that actually need it depend on it.

---
 .gitignore             | 10 +++++-----
 Makefile               | 27 +++++++++++++++------------
 docs/qemu-qmp-ref.texi |  2 +-
 rules.mak              |  2 +-
 4 files changed, 22 insertions(+), 19 deletions(-)
.gitignore +5 -5
index 2849d75..0e99e6a 100644
@@ -103,11 +103,11 @@
 /docs/qemu-ga-ref.txt
 /docs/qemu-qmp-ref.html
 /docs/qemu-qmp-ref.txt
-docs/qemu-ga-ref.info*
-docs/qemu-qmp-ref.info*
-/qemu-ga-qapi.texi
-/qemu-qapi.texi
-/version.texi
+/docs/qemu-ga-ref.info*
+/docs/qemu-qmp-ref.info*
+/docs/qemu-ga-qapi.texi
+/docs/qemu-qmp-qapi.texi
+/docs/version.texi
 *.tps
 .stgit-*
 cscope.*
Makefile +15 -12
index 1c4c04f..35d32ee 100644
@@ -516,7 +516,7 @@ distclean: clean
 	rm -f qemu-doc.vr qemu-doc.txt
 	rm -f config.log
 	rm -f linux-headers/asm
-	rm -f qemu-ga-qapi.texi qemu-qapi.texi version.texi
+	rm -f docs/qemu-ga-qapi.texi docs/qemu-qmp-qapi.texi docs/version.texi
 	rm -f docs/qemu-qmp-ref.7 docs/qemu-ga-ref.7
 	rm -f docs/qemu-qmp-ref.txt docs/qemu-ga-ref.txt
 	rm -f docs/qemu-qmp-ref.pdf docs/qemu-ga-ref.pdf
@@ -663,25 +663,28 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
 
 # documentation
 MAKEINFO=makeinfo
-MAKEINFOFLAGS=--no-split --number-sections
+MAKEINFOFLAGS=--no-split --number-sections -I docs
 TEXIFLAG=$(if $(V),,--quiet)
 
-version.texi: $(SRC_PATH)/VERSION
+docs/version.texi: $(SRC_PATH)/VERSION
 	$(call quiet-command,echo "@set VERSION $(VERSION)" > $@,"GEN","$@")
 
-%.html: %.texi version.texi
+%.html: %.texi
 	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
 	--html $< -o $@,"GEN","$@")
 
-%.info: %.texi version.texi
+%.info: %.texi
 	$(call quiet-command,$(MAKEINFO) $(MAKEINFOFLAGS) $< -o $@,"GEN","$@")
 
-%.txt: %.texi version.texi
+%.txt: %.texi
 	$(call quiet-command,LC_ALL=C $(MAKEINFO) $(MAKEINFOFLAGS) --no-headers \
 	--plaintext $< -o $@,"GEN","$@")
 
-%.pdf: %.texi version.texi
-	$(call quiet-command,texi2pdf $(TEXIFLAG) -I $(SRC_PATH) -I . $< -o $@,"GEN","$@")
+%.pdf: %.texi
+	$(call quiet-command,texi2pdf $(TEXIFLAG) -I $(SRC_PATH) -I docs $< -o $@,"GEN","$@")
+
+docs/qemu-ga-ref.html docs/qemu-ga-ref.info docs/qemu-ga-ref.txt docs/qemu-ga-ref.pdf docs/qemu-ga-ref.7.pod: docs/version.texi
+docs/qemu-qmp-ref.html docs/qemu-qmp-ref.info docs/qemu-qmp-ref.txt docs/qemu-qmp-ref.pdf docs/qemu-qmp-ref.pod: docs/version.texi
 
 qemu-options.texi: $(SRC_PATH)/qemu-options.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
@@ -695,10 +698,10 @@ qemu-monitor-info.texi: $(SRC_PATH)/hmp-commands-info.hx $(SRC_PATH)/scripts/hxt
 qemu-img-cmds.texi: $(SRC_PATH)/qemu-img-cmds.hx $(SRC_PATH)/scripts/hxtool
 	$(call quiet-command,sh $(SRC_PATH)/scripts/hxtool -t < $< > $@,"GEN","$@")
 
-qemu-qapi.texi: $(qapi-modules) $(qapi-py)
+docs/qemu-qmp-qapi.texi: $(qapi-modules) $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@")
 
-qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
+docs/qemu-ga-qapi.texi: $(SRC_PATH)/qga/qapi-schema.json $(qapi-py)
 	$(call quiet-command,$(PYTHON) $(SRC_PATH)/scripts/qapi2texi.py $< > $@,"GEN","$@")
 
 qemu.1: qemu-doc.texi qemu-options.texi qemu-monitor.texi qemu-monitor-info.texi
@@ -719,10 +722,10 @@ qemu-doc.html qemu-doc.info qemu-doc.pdf qemu-doc.txt: \
 	qemu-monitor-info.texi
 
 docs/qemu-ga-ref.dvi docs/qemu-ga-ref.html docs/qemu-ga-ref.info docs/qemu-ga-ref.pdf docs/qemu-ga-ref.txt docs/qemu-ga-ref.7: \
-docs/qemu-ga-ref.texi qemu-ga-qapi.texi
+docs/qemu-ga-ref.texi docs/qemu-ga-qapi.texi
 
 docs/qemu-qmp-ref.dvi docs/qemu-qmp-ref.html docs/qemu-qmp-ref.info docs/qemu-qmp-ref.pdf docs/qemu-qmp-ref.txt docs/qemu-qmp-ref.7: \
-docs/qemu-qmp-ref.texi qemu-qapi.texi
+docs/qemu-qmp-ref.texi docs/qemu-qmp-qapi.texi
 
 
 ifdef CONFIG_WIN32
docs/qemu-qmp-ref.texi +1 -1
index 0a00569..bb25758 100644
@@ -65,7 +65,7 @@ along with this manual.  If not, see http://www.gnu.org/licenses/.
 @c for texi2pod:
 @c man begin DESCRIPTION
 
-@include qemu-qapi.texi
+@include qemu-qmp-qapi.texi
 
 @c man end
 
rules.mak +1 -1
index 83d6dd1..1c0eabb 100644
@@ -380,7 +380,7 @@ define unnest-vars
 endef
 
 TEXI2MAN = $(call quiet-command, \
-	perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl $< [email protected] && \
+	perl -Ww -- $(SRC_PATH)/scripts/texi2pod.pl -I docs $< [email protected] && \
 	$(POD2MAN) --section=$(subst .,,$(suffix $@)) --center=" " --release=" " [email protected] > $@, \
 	"GEN","$@")
 
Signature · 1 line
2.7.4
Reviewed-by on v1 7/47
#22 lore raw

Re: [Qemu-devel] [PATCH for-2.9 07/47] qapi: Clean up build of generated documentation

Quoted 23 lines · Markus Armbruster

Rename intermediate qemu-qapi.texi to qemu-qmp-qapi.texi to match its user qemu-qmp-ref.texi, just like qemu-ga-qapi.texi matches qemu-ga-ref.texi.

Build the intermediate .texi next to the sources and the final output in docs/ instead of dumping them into the build root.

Fix version.texi dependencies so that only the targets that actually need it depend on it.

---
 .gitignore             | 10 +++++-----
 Makefile               | 27 +++++++++++++++------------
 docs/qemu-qmp-ref.texi |  2 +-
 rules.mak              |  2 +-
 4 files changed, 22 insertions(+), 19 deletions(-)
.gitignore +0 -0
index 2849d75..0e99e6a 100644

.gitignore line 103

Quoted 1 line
.gitignore +0 -0
@@ -103,11 +103,11 @@
 /docs/qemu-ga-ref.txt

[1]

.gitignore line 106

Quoted 8 lines
.gitignore +1 -5
 /docs/qemu-qmp-ref.html
 /docs/qemu-qmp-ref.txt
-docs/qemu-ga-ref.info*
-docs/qemu-qmp-ref.info*
-/qemu-ga-qapi.texi
-/qemu-qapi.texi
-/version.texi
+/docs/qemu-ga-ref.info*

worth sorting this line up by [1]?

.gitignore ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ · line 666

Quoted 13 lines
.gitignore +5 -1
+/docs/qemu-qmp-ref.info*
+/docs/qemu-ga-qapi.texi
+/docs/qemu-qmp-qapi.texi
+/docs/version.texi
 *.tps
 .stgit-*
 cscope.*
@@ -663,25 +663,28 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
 
 # documentation
 MAKEINFO=makeinfo
-MAKEINFOFLAGS=--no-split --number-sections
+MAKEINFOFLAGS=--no-split --number-sections -I docs

Will this cause grief on any older makinfo versions (such as RHEL 6)? I didn't test myself on those setups. I guess if a buildbot doesn't flag you, it's okay.

The sorting issue is worth fixing, but trivial, so you can add:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#23 lore raw

Re: [Qemu-devel] [PATCH for-2.9 07/47] qapi: Clean up build of generated documentation

Quoted 28 lines · Eric Blake
Quoted 23 lines · Markus Armbruster

Rename intermediate qemu-qapi.texi to qemu-qmp-qapi.texi to match its user qemu-qmp-ref.texi, just like qemu-ga-qapi.texi matches qemu-ga-ref.texi.

Build the intermediate .texi next to the sources and the final output in docs/ instead of dumping them into the build root.

Fix version.texi dependencies so that only the targets that actually need it depend on it.

---
 .gitignore             | 10 +++++-----
 Makefile               | 27 +++++++++++++++------------
 docs/qemu-qmp-ref.texi |  2 +-
 rules.mak              |  2 +-
 4 files changed, 22 insertions(+), 19 deletions(-)
.gitignore +0 -0
index 2849d75..0e99e6a 100644

.gitignore line 103

Quoted 1 line
.gitignore +0 -0
@@ -103,11 +103,11 @@
 /docs/qemu-ga-ref.txt

[1]

Quoted 10 lines

.gitignore line 106

Quoted 8 lines
.gitignore +1 -5
 /docs/qemu-qmp-ref.html
 /docs/qemu-qmp-ref.txt
-docs/qemu-ga-ref.info*
-docs/qemu-qmp-ref.info*
-/qemu-ga-qapi.texi
-/qemu-qapi.texi
-/version.texi
+/docs/qemu-ga-ref.info*

worth sorting this line up by [1]?

Fine with me, except I think we should either not mess with the order, or go all the way, i.e. ...

Quoted 2 lines

.gitignore line 108

Quoted 2 lines
.gitignore +2 -0
+/docs/qemu-qmp-ref.info*
+/docs/qemu-ga-qapi.texi

... move this one, too. Feeding to sort leads to this incremental patch:

@@ -99,14 +99,14 @@
/pc-bios/optionrom/kvmvapic.img
/pc-bios/s390-ccw/s390-ccw.elf
/pc-bios/s390-ccw/s390-ccw.img
+/docs/qemu-ga-qapi.texi
/docs/qemu-ga-ref.html
+/docs/qemu-ga-ref.info*
/docs/qemu-ga-ref.txt
+/docs/qemu-qmp-qapi.texi
/docs/qemu-qmp-ref.html
-/docs/qemu-qmp-ref.txt
-/docs/qemu-ga-ref.info*
/docs/qemu-qmp-ref.info*
-/docs/qemu-ga-qapi.texi
-/docs/qemu-qmp-qapi.texi
+/docs/qemu-qmp-ref.txt
/docs/version.texi
*.tps
.stgit-*

Quoted 7 lines
Quoted 7 lines
.gitignore +2 -0
+/docs/qemu-qmp-qapi.texi
+/docs/version.texi
 *.tps
 .stgit-*
 cscope.*
@@ -663,25 +663,28 @@ ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \
 
Quoted 8 lines

.gitignore ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ · line 666

Quoted 4 lines
.gitignore +1 -1
 # documentation
 MAKEINFO=makeinfo
-MAKEINFOFLAGS=--no-split --number-sections
+MAKEINFOFLAGS=--no-split --number-sections -I docs

Will this cause grief on any older makinfo versions (such as RHEL 6)? I didn't test myself on those setups. I guess if a buildbot doesn't flag you, it's okay.

RHEL-6 has texinfo 4.13, and its manual page documents -I. No mention in NEWS, which goes back to 2.2.

Quoted 3 lines

The sorting issue is worth fixing, but trivial, so you can add:

Thanks!

#24 lore raw

Re: [Qemu-devel] [PATCH for-2.9 07/47] qapi: Clean up build of generated documentation

Quoted 35 lines · Markus Armbruster
Quoted 6 lines

.gitignore line 103

Quoted 3 lines

+++ b/.gitignore

.gitignore +0 -0
@@ -103,11 +103,11 @@
 /docs/qemu-ga-ref.txt

[1]

Quoted 10 lines

.gitignore line 106

Quoted 8 lines
.gitignore +1 -5
 /docs/qemu-qmp-ref.html
 /docs/qemu-qmp-ref.txt
-docs/qemu-ga-ref.info*
-docs/qemu-qmp-ref.info*
-/qemu-ga-qapi.texi
-/qemu-qapi.texi
-/version.texi
+/docs/qemu-ga-ref.info*

worth sorting this line up by [1]?

Fine with me, except I think we should either not mess with the order, or go all the way, i.e. ...

Quoted 2 lines

.gitignore line 108

Quoted 2 lines
.gitignore +2 -0
+/docs/qemu-qmp-ref.info*
+/docs/qemu-ga-qapi.texi

... move this one, too. Feeding to sort leads to this incremental patch:

(quoted diff) +3 -0
@@ -99,14 +99,14 @@
 /pc-bios/optionrom/kvmvapic.img
 /pc-bios/s390-ccw/s390-ccw.elf
 /pc-bios/s390-ccw/s390-ccw.img
+/docs/qemu-ga-qapi.texi
 /docs/qemu-ga-ref.html
+/docs/qemu-ga-ref.info*
 /docs/qemu-ga-ref.txt
+/docs/qemu-qmp-qapi.texi

Review line 112

Quoted 10 lines
(quoted diff) +1 -4
 /docs/qemu-qmp-ref.html
-/docs/qemu-qmp-ref.txt
-/docs/qemu-ga-ref.info*
 /docs/qemu-qmp-ref.info*
-/docs/qemu-ga-qapi.texi
-/docs/qemu-qmp-qapi.texi
+/docs/qemu-qmp-ref.txt
 /docs/version.texi
 *.tps
 .stgit-*

Works for me (I always find fully-sorted lists easier to modify, because I don't have to guess whether inserting new stuff is grouped sanely).

Quoted 10 lines
Quoted 7 lines

Makefile ui/console-gl.o: $(SRC_PATH)/ui/console-gl.c \ · line 666

Quoted 3 lines
Makefile +1 -1
 MAKEINFO=makeinfo
-MAKEINFOFLAGS=--no-split --number-sections
+MAKEINFOFLAGS=--no-split --number-sections -I docs

Will this cause grief on any older makinfo versions (such as RHEL 6)? I didn't test myself on those setups. I guess if a buildbot doesn't flag you, it's okay.

RHEL-6 has texinfo 4.13, and its manual page documents -I. No mention in NEWS, which goes back to 2.2.

Phew, we're safe then.

Quoted 7 lines
Quoted 4 lines

The sorting issue is worth fixing, but trivial, so you can add:

Thanks!

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#25 lore raw

PATCH 8/47 tests/qapi-schema: Cover empty union base

In reply to Markus Armbruster

The new test case shows off qapi.py choking on an empty union base.

---
 tests/Makefile.include                  |  1 +
 tests/qapi-schema/union-base-empty.err  | 10 ++++++++++
 tests/qapi-schema/union-base-empty.exit |  1 +
 tests/qapi-schema/union-base-empty.json |  9 +++++++++
 tests/qapi-schema/union-base-empty.out  |  0
 5 files changed, 21 insertions(+)
 create mode 100644 tests/qapi-schema/union-base-empty.err
 create mode 100644 tests/qapi-schema/union-base-empty.exit
 create mode 100644 tests/qapi-schema/union-base-empty.json
 create mode 100644 tests/qapi-schema/union-base-empty.out
tests/Makefile.include +1 -0
index 736dd15..9f4e890 100644
@@ -470,6 +470,7 @@ qapi-schema += unclosed-list.json
 qapi-schema += unclosed-object.json
 qapi-schema += unclosed-string.json
 qapi-schema += unicode-str.json
+qapi-schema += union-base-empty.json
 qapi-schema += union-base-no-discriminator.json
 qapi-schema += union-branch-case.json
 qapi-schema += union-clash-branches.json
tests/qapi-schema/union-base-empty.err new file +10 -0
new file mode 100644
index 0000000..61e6ec6
@@ -0,0 +1,10 @@
+Traceback (most recent call last):
+  File "tests/qapi-schema/test-qapi.py", line 56, in <module>
+    schema = QAPISchema(sys.argv[1])
+  File "scripts/qapi.py", line 1483, in __init__
+    self.exprs = check_exprs(parser.exprs)
+  File "scripts/qapi.py", line 917, in check_exprs
+    check_union(expr, info)
+  File "scripts/qapi.py", line 734, in check_union
+    assert base_members
+AssertionError
tests/qapi-schema/union-base-empty.exit new file +1 -0
new file mode 100644
index 0000000..d00491f
@@ -0,0 +1 @@
+1
tests/qapi-schema/union-base-empty.json new file +9 -0
new file mode 100644
index 0000000..d1843d3
@@ -0,0 +1,9 @@
+# Flat union with empty base and therefore without discriminator
+
+{ 'struct': 'Empty', 'data': { } }
+
+{ 'union': 'TestUnion',
+  'base': 'Empty',
+  'discriminator': 'type',
+  'data': { 'value1': 'int',
+            'value2': 'str' } }
tests/qapi-schema/union-base-empty.out new file +0 -0
new file mode 100644
index 0000000..e69de29
Signature · 1 line
2.7.4
Reviewed-by on v1 8/47
#26 lore raw

Re: [Qemu-devel] [PATCH for-2.9 08/47] tests/qapi-schema: Cover empty union base

Quoted 4 lines · Markus Armbruster

The new test case shows off qapi.py choking on an empty union base.

Quoted 73 lines
---
 tests/Makefile.include                  |  1 +
 tests/qapi-schema/union-base-empty.err  | 10 ++++++++++
 tests/qapi-schema/union-base-empty.exit |  1 +
 tests/qapi-schema/union-base-empty.json |  9 +++++++++
 tests/qapi-schema/union-base-empty.out  |  0
 5 files changed, 21 insertions(+)
 create mode 100644 tests/qapi-schema/union-base-empty.err
 create mode 100644 tests/qapi-schema/union-base-empty.exit
 create mode 100644 tests/qapi-schema/union-base-empty.json
 create mode 100644 tests/qapi-schema/union-base-empty.out
tests/Makefile.include +1 -0
index 736dd15..9f4e890 100644
@@ -470,6 +470,7 @@ qapi-schema += unclosed-list.json
 qapi-schema += unclosed-object.json
 qapi-schema += unclosed-string.json
 qapi-schema += unicode-str.json
+qapi-schema += union-base-empty.json
 qapi-schema += union-base-no-discriminator.json
 qapi-schema += union-branch-case.json
 qapi-schema += union-clash-branches.json
tests/qapi-schema/union-base-empty.err new file +10 -0
new file mode 100644
index 0000000..61e6ec6
@@ -0,0 +1,10 @@
+Traceback (most recent call last):
+  File "tests/qapi-schema/test-qapi.py", line 56, in <module>
+    schema = QAPISchema(sys.argv[1])
+  File "scripts/qapi.py", line 1483, in __init__
+    self.exprs = check_exprs(parser.exprs)
+  File "scripts/qapi.py", line 917, in check_exprs
+    check_union(expr, info)
+  File "scripts/qapi.py", line 734, in check_union
+    assert base_members
+AssertionError
tests/qapi-schema/union-base-empty.exit new file +1 -0
new file mode 100644
index 0000000..d00491f
@@ -0,0 +1 @@
+1
tests/qapi-schema/union-base-empty.json new file +9 -0
new file mode 100644
index 0000000..d1843d3
@@ -0,0 +1,9 @@
+# Flat union with empty base and therefore without discriminator
+
+{ 'struct': 'Empty', 'data': { } }
+
+{ 'union': 'TestUnion',
+  'base': 'Empty',
+  'discriminator': 'type',
+  'data': { 'value1': 'int',
+            'value2': 'str' } }
tests/qapi-schema/union-base-empty.out new file +0 -1
new file mode 100644
index 0000000..e69de29
--

2.7.4

Quoted 1 line

--

Marc-André Lureau

Reviewed-by on v1 8/47
#27 lore raw

Re: [Qemu-devel] [PATCH for-2.9 08/47] tests/qapi-schema: Cover empty union base

In reply to Markus Armbruster
Quoted 1 line · Markus Armbruster

The new test case shows off qapi.py choking on an empty union base.

We're still finding ways to choke the parser ;)

Quoted 3 lines

---

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#28 lore raw

Re: [Qemu-devel] [PATCH for-2.9 08/47] tests/qapi-schema: Cover empty union base

Quoted 4 lines · Eric Blake
Quoted 1 line · Markus Armbruster

The new test case shows off qapi.py choking on an empty union base.

We're still finding ways to choke the parser ;)

At least we're not finding dozens of ways without having to look hard anymore :)

Quoted 4 lines
Quoted 2 lines

---

Thanks!

#29 lore raw

PATCH 9/47 qapi: Fix to reject empty union base gracefully

In reply to Markus Armbruster

Common Python pitfall: 'assert base_members' fires on [] in addition to None. Correct to 'assert base_members is not None'.

---
 scripts/qapi.py                        |  2 +-
 tests/qapi-schema/union-base-empty.err | 11 +----------
 2 files changed, 2 insertions(+), 11 deletions(-)
scripts/qapi.py +1 -1
index e98fd0c..eec7bfb 100644
@@ -731,7 +731,7 @@ def check_union(expr, info):
             raise QAPISemError(info, "Flat union '%s' must have a base"
                                % name)
         base_members = find_base_members(base)
-        assert base_members
+        assert base_members is not None
 
         # The value of member 'discriminator' must name a non-optional
         # member of the base struct.
tests/qapi-schema/union-base-empty.err +1 -10
index 61e6ec6..7695806 100644
@@ -1,10 +1 @@
-Traceback (most recent call last):
-  File "tests/qapi-schema/test-qapi.py", line 56, in <module>
-    schema = QAPISchema(sys.argv[1])
-  File "scripts/qapi.py", line 1483, in __init__
-    self.exprs = check_exprs(parser.exprs)
-  File "scripts/qapi.py", line 917, in check_exprs
-    check_union(expr, info)
-  File "scripts/qapi.py", line 734, in check_union
-    assert base_members
-AssertionError
+tests/qapi-schema/union-base-empty.json:5: Discriminator 'type' is not a member of base struct 'Empty'
Signature · 1 line
2.7.4
Reviewed-by on v1 9/47
#30 lore raw

Re: [Qemu-devel] [PATCH for-2.9 09/47] qapi: Fix to reject empty union base gracefully

Hi

Quoted 5 lines · Markus Armbruster

Common Python pitfall: 'assert base_members' fires on [] in addition to None. Correct to 'assert base_members is not None'.

Quoted 40 lines
---
 scripts/qapi.py                        |  2 +-
 tests/qapi-schema/union-base-empty.err | 11 +----------
 2 files changed, 2 insertions(+), 11 deletions(-)
scripts/qapi.py +1 -1
index e98fd0c..eec7bfb 100644
@@ -731,7 +731,7 @@ def check_union(expr, info):
             raise QAPISemError(info, "Flat union '%s' must have a base"
                                % name)
         base_members = find_base_members(base)
-        assert base_members
+        assert base_members is not None
 
         # The value of member 'discriminator' must name a non-optional
         # member of the base struct.
tests/qapi-schema/union-base-empty.err +1 -10
index 61e6ec6..7695806 100644
@@ -1,10 +1 @@
-Traceback (most recent call last):
-  File "tests/qapi-schema/test-qapi.py", line 56, in <module>
-    schema = QAPISchema(sys.argv[1])
-  File "scripts/qapi.py", line 1483, in __init__
-    self.exprs = check_exprs(parser.exprs)
-  File "scripts/qapi.py", line 917, in check_exprs
-    check_union(expr, info)
-  File "scripts/qapi.py", line 734, in check_union
-    assert base_members
-AssertionError
+tests/qapi-schema/union-base-empty.json:5: Discriminator 'type' is not a

member of base struct 'Empty'
--
2.7.4

Quoted 1 line

--

Marc-André Lureau

Reviewed-by on v1 9/47
#31 lore raw

Re: [Qemu-devel] [PATCH for-2.9 09/47] qapi: Fix to reject empty union base gracefully

In reply to Markus Armbruster
Quoted 13 lines · Markus Armbruster

Common Python pitfall: 'assert base_members' fires on [] in addition to None. Correct to 'assert base_members is not None'.

---
 scripts/qapi.py                        |  2 +-
 tests/qapi-schema/union-base-empty.err | 11 +----------
 2 files changed, 2 insertions(+), 11 deletions(-)

+++ b/tests/qapi-schema/union-base-empty.err

tests/qapi-schema/union-base-empty.err +0 -1
@@ -1,10 +1 @@
-Traceback (most recent call last):

tests/qapi-schema/union-base-empty.err line 1

Quoted 10 lines
tests/qapi-schema/union-base-empty.err +1 -9
-  File "tests/qapi-schema/test-qapi.py", line 56, in <module>
-    schema = QAPISchema(sys.argv[1])
-  File "scripts/qapi.py", line 1483, in __init__
-    self.exprs = check_exprs(parser.exprs)
-  File "scripts/qapi.py", line 917, in check_exprs
-    check_union(expr, info)
-  File "scripts/qapi.py", line 734, in check_union
-    assert base_members
-AssertionError
+tests/qapi-schema/union-base-empty.json:5: Discriminator 'type' is not a member of base struct 'Empty'

Much nicer message.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#32 lore raw

PATCH 10/47 qapi2texi: Fix up output around #optional

In reply to Markus Armbruster

We use tag #optional to mark optional members, like this:

# @name: #optional The name of the guest

texi_body() strips #optional, but not whitespace around it. For the above, we get in qemu-qmp-qapi.texi

@item @code{'name'} (optional)
The name of the guest
@end table

The extra space can lead to artifacts in output, e.g in qemu-qmp-ref.7.pod

=item C<'name'> (optional)

The name of the guest

and then in qemu-qmp-ref.7

.IX Item "name (optional)"
.Vb 1
\& The name of the guest
.Ve

instead of intended plain

.IX Item "name (optional)"
The name of the guest

Get rid of these artifacts by removing whitespace around #optional along with it.

This turns three minus signs in qapi-schema.json into markup, because they're now at the beginning of the line. Drop them, they're unwanted there.

---
 qapi-schema.json     | 6 +++---
 scripts/qapi2texi.py | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
qapi-schema.json +3 -3
index 17c766e..52141cd 100644
@@ -3779,11 +3779,11 @@
 #
 # @dstport: #optional destination port - mandatory for udp, optional for ip
 #
-# @ipv6: #optional - force the use of ipv6
+# @ipv6: #optional force the use of ipv6
 #
-# @udp: #optional - use the udp version of l2tpv3 encapsulation
+# @udp: #optional use the udp version of l2tpv3 encapsulation
 #
-# @cookie64: #optional - use 64 bit coookies
+# @cookie64: #optional use 64 bit coookies
 #
 # @counter: #optional have sequence counter
 #
scripts/qapi2texi.py +2 -1
index 06d6abf..0f3e573 100755
@@ -137,7 +137,8 @@ def texi_body(doc):
             desc = str(section)
             opt = ''
             if "#optional" in desc:
-                desc = desc.replace("#optional", "")
+                desc = re.sub(r'^ *#optional *\n?|\n? *#optional *$|#optional',
+                              '', desc)
                 opt = ' (optional)'
             body += "@item @code{'%s'}%s\n%s\n" % (arg, opt,
                                                    texi_format(desc))
Signature · 1 line
2.7.4
Reviewed-by on v1 10/47
#33 lore raw

Re: [Qemu-devel] [PATCH for-2.9 10/47] qapi2texi: Fix up output around #optional

Quoted 30 lines · Markus Armbruster

We use tag #optional to mark optional members, like this:

# @name: #optional The name of the guest

texi_body() strips #optional, but not whitespace around it. For the above, we get in qemu-qmp-qapi.texi

@item @code{'name'} (optional)
The name of the guest
@end table

The extra space can lead to artifacts in output, e.g in qemu-qmp-ref.7.pod

=item C<'name'> (optional)

The name of the guest

and then in qemu-qmp-ref.7

.IX Item "name (optional)"
.Vb 1
\& The name of the guest
.Ve

instead of intended plain

.IX Item "name (optional)"
The name of the guest

Quoted 9 lines

Get rid of these artifacts by removing whitespace around #optional along with it.

This turns three minus signs in qapi-schema.json into markup, because they're now at the beginning of the line. Drop them, they're unwanted there.

Quoted 44 lines
---
 qapi-schema.json     | 6 +++---
 scripts/qapi2texi.py | 3 ++-
 2 files changed, 5 insertions(+), 4 deletions(-)
qapi-schema.json +0 -0
index 17c766e..52141cd 100644
@@ -3779,11 +3779,11 @@
 #
 # @dstport: #optional destination port - mandatory for udp, optional for

ip
#

qapi-schema.json +3 -3
-# @ipv6: #optional - force the use of ipv6
+# @ipv6: #optional force the use of ipv6
 #
-# @udp: #optional - use the udp version of l2tpv3 encapsulation
+# @udp: #optional use the udp version of l2tpv3 encapsulation
 #
-# @cookie64: #optional - use 64 bit coookies
+# @cookie64: #optional use 64 bit coookies
 #
 # @counter: #optional have sequence counter
 #
scripts/qapi2texi.py +2 -1
index 06d6abf..0f3e573 100755
@@ -137,7 +137,8 @@ def texi_body(doc):
             desc = str(section)
             opt = ''
             if "#optional" in desc:
-                desc = desc.replace("#optional", "")
+                desc = re.sub(r'^ *#optional *\n?|\n? *#optional
 *$|#optional',
+                              '', desc)
                 opt = ' (optional)'
             body += "@item @code{'%s'}%s\n%s\n" % (arg, opt,

texi_format(desc))
--
2.7.4

Quoted 1 line

--

Marc-André Lureau

#34 lore raw

PATCH 11/47 qapi: Avoid unwanted blank lines in QAPIDoc

In reply to Markus Armbruster

We silently fix missing #optional tags for QAPIDoc by appending a line "#optional" to the section's .content. However, this interferes with .__repr__ stripping trailing blank lines from .content.

Use new ArgSection instance variable .optional instead, and leave .content alone.

To permit testing .optional in texi_body(), clean up texi_enum()'s hack to add empty documentation for undocumented enum values: add an ArgSection instead of ''.

---
 scripts/qapi.py      | 5 +++--
 scripts/qapi2texi.py | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
scripts/qapi.py +3 -2
index eec7bfb..e6d023f 100644
@@ -107,6 +107,7 @@ class QAPIDoc(object):
             self.name = name
             # the list of lines for this section
             self.content = []
+            self.optional = False
 
         def append(self, line):
             self.content.append(line)
@@ -978,15 +979,15 @@ def check_definition_doc(doc, expr, info):
             desc = doc.args.get(arg)
         if not desc:
             continue
+        desc.optional = opt
         desc_opt = "#optional" in str(desc)
         if desc_opt and not opt:
             raise QAPISemError(info, "Description has #optional, "
                                "but the declaration doesn't")
         if not desc_opt and opt:
-            # silently fix the doc
             # TODO either fix the schema and make this an error,
             # or drop #optional entirely
-            desc.append("#optional")
+            pass
 
     doc_args = set(doc.args.keys())
     args = set([name.strip('*') for name in args])
scripts/qapi2texi.py +2 -2
index 0f3e573..0aaf45c 100755
@@ -136,7 +136,7 @@ def texi_body(doc):
         for arg, section in doc.args.iteritems():
             desc = str(section)
             opt = ''
-            if "#optional" in desc:
+            if section.optional:
                 desc = re.sub(r'^ *#optional *\n?|\n? *#optional *$|#optional',
                               '', desc)
                 opt = ' (optional)'
@@ -185,7 +185,7 @@ def texi_enum(expr, doc):
     """Format an enum to texi"""
     for i in expr['data']:
         if i not in doc.args:
-            doc.args[i] = ''
+            doc.args[i] = qapi.QAPIDoc.ArgSection(i)
     body = texi_body(doc)
     return TYPE_FMT(type="Enum",
                     name=doc.symbol,
Signature · 1 line
2.7.4
Reviewed-by on v1 11/47
#35 lore raw

Re: [Qemu-devel] [PATCH for-2.9 11/47] qapi: Avoid unwanted blank lines in QAPIDoc

Hi

Quoted 4 lines · Markus Armbruster

We silently fix missing #optional tags for QAPIDoc by appending a line "#optional" to the section's .content. However, this interferes with .__repr__ stripping trailing blank lines from .content.

Quoted 9 lines

Use new ArgSection instance variable .optional instead, and leave .content alone.

To permit testing .optional in texi_body(), clean up texi_enum()'s hack to add empty documentation for undocumented enum values: add an ArgSection instead of ''.

Quoted 50 lines
---
 scripts/qapi.py      | 5 +++--
 scripts/qapi2texi.py | 4 ++--
 2 files changed, 5 insertions(+), 4 deletions(-)
scripts/qapi.py +3 -2
index eec7bfb..e6d023f 100644
@@ -107,6 +107,7 @@ class QAPIDoc(object):
             self.name = name
             # the list of lines for this section
             self.content = []
+            self.optional = False
 
         def append(self, line):
             self.content.append(line)
@@ -978,15 +979,15 @@ def check_definition_doc(doc, expr, info):
             desc = doc.args.get(arg)
         if not desc:
             continue
+        desc.optional = opt
         desc_opt = "#optional" in str(desc)
         if desc_opt and not opt:
             raise QAPISemError(info, "Description has #optional, "
                                "but the declaration doesn't")
         if not desc_opt and opt:
-            # silently fix the doc
             # TODO either fix the schema and make this an error,
             # or drop #optional entirely
-            desc.append("#optional")
+            pass
 
     doc_args = set(doc.args.keys())
     args = set([name.strip('*') for name in args])
scripts/qapi2texi.py +1 -1
index 0f3e573..0aaf45c 100755
@@ -136,7 +136,7 @@ def texi_body(doc):
         for arg, section in doc.args.iteritems():
             desc = str(section)
             opt = ''
-            if "#optional" in desc:
+            if section.optional:
                 desc = re.sub(r'^ *#optional *\n?|\n? *#optional
 *$|#optional',
                               '', desc)
                 opt = ' (optional)'

scripts/qapi2texi.py def texi_enum(expr, doc): · line 188

Quoted 5 lines
scripts/qapi2texi.py +1 -1
@@ -185,7 +185,7 @@ def texi_enum(expr, doc):
     """Format an enum to texi"""
     for i in expr['data']:
         if i not in doc.args:
-            doc.args[i] = ''
+            doc.args[i] = qapi.QAPIDoc.ArgSection(i)

body = texi_body(doc)

Quoted 7 lines
scripts/qapi2texi.py +0 -1
     return TYPE_FMT(type="Enum",
                     name=doc.symbol,
--

2.7.4

--

Marc-André Lureau

#36 lore raw

PATCH 12/47 qapi/rocker: Fix up doc comment notes on optional members

In reply to Markus Armbruster

Talking about #optional like this

# Note: fields are marked #optional to indicate that they may or may # not appear ...

doesn't work so well in generated documentation, because the #optional tag is not visible there. Replace by

# Note: optional members may or may not appear ...

---
 qapi/rocker.json | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
qapi/rocker.json +10 -8
index 97e2b83..f374038 100644
@@ -1,3 +1,5 @@
+# -*- Mode: Python -*-
+
 ##
 # = Rocker switch device
 ##
@@ -137,8 +139,8 @@
 #
 # @ip-dst: #optional IP header destination address
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the flow key depending if they're relevant to the flow key.
+# Note: optional members may or may not appear in the flow key
+# depending if they're relevant to the flow key.
 #
 # Since: 2.4
 ##
@@ -167,8 +169,8 @@
 #
 # @ip-tos: #optional IP header TOS field
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the flow mask depending if they're relevant to the flow mask.
+# Note: optional members may or may not appear in the flow mask
+# depending if they're relevant to the flow mask.
 #
 # Since: 2.4
 ##
@@ -194,8 +196,8 @@
 #
 # @out-pport: #optional physical output port
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the flow action depending if they're relevant to the flow action.
+# Note: optional members may or may not appear in the flow action
+# depending if they're relevant to the flow action.
 #
 # Since: 2.4
 ##
@@ -288,8 +290,8 @@
 #
 # @ttl-check: #optional perform TTL check
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the group depending if they're relevant to the group type.
+# Note: optional members may or may not appear in the group depending
+# if they're relevant to the group type.
 #
 # Since: 2.4
 ##
Signature · 1 line
2.7.4
Reviewed-by on v1 12/47
#37 lore raw

Re: [Qemu-devel] [PATCH for-2.9 12/47] qapi/rocker: Fix up doc comment notes on optional members

Hi

Quoted 5 lines · Markus Armbruster

Talking about #optional like this

# Note: fields are marked #optional to indicate that they may or may # not appear ...

Quoted 7 lines

doesn't work so well in generated documentation, because the #optional tag is not visible there. Replace by

# Note: optional members may or may not appear ...

indeed,

Quoted 63 lines
---
 qapi/rocker.json | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
qapi/rocker.json +6 -6
index 97e2b83..f374038 100644
@@ -1,3 +1,5 @@
+# -*- Mode: Python -*-
+
 ##
 # = Rocker switch device
 ##
@@ -137,8 +139,8 @@
 #
 # @ip-dst: #optional IP header destination address
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the flow key depending if they're relevant to the flow key.
+# Note: optional members may or may not appear in the flow key
+# depending if they're relevant to the flow key.
 #
 # Since: 2.4
 ##
@@ -167,8 +169,8 @@
 #
 # @ip-tos: #optional IP header TOS field
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the flow mask depending if they're relevant to the flow mask.
+# Note: optional members may or may not appear in the flow mask
+# depending if they're relevant to the flow mask.
 #
 # Since: 2.4
 ##
@@ -194,8 +196,8 @@
 #
 # @out-pport: #optional physical output port
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the flow action depending if they're relevant to the flow

action.

qapi/rocker.json +4 -3
+# Note: optional members may or may not appear in the flow action
+# depending if they're relevant to the flow action.
 #
 # Since: 2.4
 ##
@@ -288,8 +290,8 @@
 #
 # @ttl-check: #optional perform TTL check
 #
-# Note: fields are marked #optional to indicate that they may or may not
-# appear in the group depending if they're relevant to the group type.
+# Note: optional members may or may not appear in the group depending
+# if they're relevant to the group type.
 #
 # Since: 2.4
 ##
--

2.7.4

Quoted 1 line

--

Marc-André Lureau

#38 lore raw

PATCH 13/47 qapi: Fix QAPISchemaEnumType.is_implicit() for 'QType'

In reply to Markus Armbruster

Missed in commit 7264f5c. Harmless, because nothing checks whether an enumeration type is implicit so far.

---
 scripts/qapi.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qapi.py +2 -2
index e6d023f..7a2b6ab 100644
@@ -1148,8 +1148,8 @@ class QAPISchemaEnumType(QAPISchemaType):
             v.check_clash(self.info, seen)
 
     def is_implicit(self):
-        # See QAPISchema._make_implicit_enum_type()
-        return self.name.endswith('Kind')
+        # See QAPISchema._make_implicit_enum_type() and ._def_predefineds()
+        return self.name.endswith('Kind') or self.name == 'QType'
 
     def c_type(self):
         return c_name(self.name)
Signature · 1 line
2.7.4
Reviewed-by on v1 13/47
#39 lore raw

Re: [Qemu-devel] [PATCH for-2.9 13/47] qapi: Fix QAPISchemaEnumType.is_implicit() for 'QType'

Quoted 2 lines · Markus Armbruster

Missed in commit 7264f5c. Harmless, because nothing checks whether an enumeration type is implicit so far.

Obviously, a later patch will care about implicit types, and choked without this ;)

Quoted 5 lines
---
 scripts/qapi.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Quoted 17 lines
scripts/qapi.py +2 -2
index e6d023f..7a2b6ab 100644
@@ -1148,8 +1148,8 @@ class QAPISchemaEnumType(QAPISchemaType):
             v.check_clash(self.info, seen)
 
     def is_implicit(self):
-        # See QAPISchema._make_implicit_enum_type()
-        return self.name.endswith('Kind')
+        # See QAPISchema._make_implicit_enum_type() and ._def_predefineds()
+        return self.name.endswith('Kind') or self.name == 'QType'
 
     def c_type(self):
         return c_name(self.name)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#40 lore raw

PATCH 14/47 qapi: Prepare for requiring more complete documentation

In reply to Markus Armbruster

We currently neglect to check all enumeration values, common members of object types and members of alternate types are documented. Unsurprisingly, many aren't.

Add the necessary plumbing to find undocumented ones, except for variant members of object types. Don't enforce anything just yet, but connect each QAPIDoc.ArgSection to its QAPISchemaMember.

---
 scripts/qapi.py | 110 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 65 insertions(+), 45 deletions(-)
scripts/qapi.py +65 -45
index 7a2b6ab..4886417 100644
@@ -116,7 +116,12 @@ class QAPIDoc(object):
             return "\n".join(self.content).strip()
 
     class ArgSection(Section):
-        pass
+        def __init__(self, name):
+            QAPIDoc.Section.__init__(self, name)
+            self.member = None
+
+        def connect(self, member):
+            self.member = member
 
     def __init__(self, parser, info):
         # self.parser is used to report errors with QAPIParseError.  The
@@ -216,6 +221,13 @@ class QAPIDoc(object):
             line = line.strip()
         self.section.append(line)
 
+    def connect_member(self, member):
+        if not member.name in self.args:
+            # Undocumented TODO outlaw
+            pass
+        else:
+            self.args[member.name].connect(member)
+
 
 class QAPISchemaParser(object):
 
@@ -1017,7 +1029,7 @@ def check_docs(docs):
 #
 
 class QAPISchemaEntity(object):
-    def __init__(self, name, info):
+    def __init__(self, name, info, doc):
         assert isinstance(name, str)
         self.name = name
         # For explicitly defined entities, info points to the (explicit)
@@ -1026,6 +1038,7 @@ class QAPISchemaEntity(object):
         # triggered the implicit definition (there may be more than one
         # such place).
         self.info = info
+        self.doc = doc
 
     def c_name(self):
         return c_name(self.name)
@@ -1107,7 +1120,7 @@ class QAPISchemaType(QAPISchemaEntity):
 
 class QAPISchemaBuiltinType(QAPISchemaType):
     def __init__(self, name, json_type, c_type):
-        QAPISchemaType.__init__(self, name, None)
+        QAPISchemaType.__init__(self, name, None, None)
         assert not c_type or isinstance(c_type, str)
         assert json_type in ('string', 'number', 'int', 'boolean', 'null',
                              'value')
@@ -1133,8 +1146,8 @@ class QAPISchemaBuiltinType(QAPISchemaType):
 
 
 class QAPISchemaEnumType(QAPISchemaType):
-    def __init__(self, name, info, values, prefix):
-        QAPISchemaType.__init__(self, name, info)
+    def __init__(self, name, info, doc, values, prefix):
+        QAPISchemaType.__init__(self, name, info, doc)
         for v in values:
             assert isinstance(v, QAPISchemaMember)
             v.set_owner(name)
@@ -1146,6 +1159,8 @@ class QAPISchemaEnumType(QAPISchemaType):
         seen = {}
         for v in self.values:
             v.check_clash(self.info, seen)
+            if self.doc:
+                self.doc.connect_member(v)
 
     def is_implicit(self):
         # See QAPISchema._make_implicit_enum_type() and ._def_predefineds()
@@ -1167,7 +1182,7 @@ class QAPISchemaEnumType(QAPISchemaType):
 
 class QAPISchemaArrayType(QAPISchemaType):
     def __init__(self, name, info, element_type):
-        QAPISchemaType.__init__(self, name, info)
+        QAPISchemaType.__init__(self, name, info, None)
         assert isinstance(element_type, str)
         self._element_type_name = element_type
         self.element_type = None
@@ -1190,11 +1205,11 @@ class QAPISchemaArrayType(QAPISchemaType):
 
 
 class QAPISchemaObjectType(QAPISchemaType):
-    def __init__(self, name, info, base, local_members, variants):
+    def __init__(self, name, info, doc, base, local_members, variants):
         # struct has local_members, optional base, and no variants
         # flat union has base, variants, and no local_members
         # simple union has local_members, variants, and no base
-        QAPISchemaType.__init__(self, name, info)
+        QAPISchemaType.__init__(self, name, info, doc)
         assert base is None or isinstance(base, str)
         for m in local_members:
             assert isinstance(m, QAPISchemaObjectTypeMember)
@@ -1224,6 +1239,8 @@ class QAPISchemaObjectType(QAPISchemaType):
         for m in self.local_members:
             m.check(schema)
             m.check_clash(self.info, seen)
+            if self.doc:
+                self.doc.connect_member(m)
         self.members = seen.values()
         if self.variants:
             self.variants.check(schema, seen)
@@ -1378,8 +1395,8 @@ class QAPISchemaObjectTypeVariant(QAPISchemaObjectTypeMember):
 
 
 class QAPISchemaAlternateType(QAPISchemaType):
-    def __init__(self, name, info, variants):
-        QAPISchemaType.__init__(self, name, info)
+    def __init__(self, name, info, doc, variants):
+        QAPISchemaType.__init__(self, name, info, doc)
         assert isinstance(variants, QAPISchemaObjectTypeVariants)
         assert variants.tag_member
         variants.set_owner(name)
@@ -1396,6 +1413,8 @@ class QAPISchemaAlternateType(QAPISchemaType):
         seen = {}
         for v in self.variants.variants:
             v.check_clash(self.info, seen)
+            if self.doc:
+                self.doc.connect_member(v)
 
     def c_type(self):
         return c_name(self.name) + pointer_suffix
@@ -1411,9 +1430,9 @@ class QAPISchemaAlternateType(QAPISchemaType):
 
 
 class QAPISchemaCommand(QAPISchemaEntity):
-    def __init__(self, name, info, arg_type, ret_type, gen, success_response,
-                 boxed):
-        QAPISchemaEntity.__init__(self, name, info)
+    def __init__(self, name, info, doc, arg_type, ret_type,
+                 gen, success_response, boxed):
+        QAPISchemaEntity.__init__(self, name, info, doc)
         assert not arg_type or isinstance(arg_type, str)
         assert not ret_type or isinstance(ret_type, str)
         self._arg_type_name = arg_type
@@ -1450,8 +1469,8 @@ class QAPISchemaCommand(QAPISchemaEntity):
 
 
 class QAPISchemaEvent(QAPISchemaEntity):
-    def __init__(self, name, info, arg_type, boxed):
-        QAPISchemaEntity.__init__(self, name, info)
+    def __init__(self, name, info, doc, arg_type, boxed):
+        QAPISchemaEntity.__init__(self, name, info, doc)
         assert not arg_type or isinstance(arg_type, str)
         self._arg_type_name = arg_type
         self.arg_type = None
@@ -1533,14 +1552,14 @@ class QAPISchema(object):
                   ('bool',   'boolean', 'bool'),
                   ('any',    'value',   'QObject' + pointer_suffix)]:
             self._def_builtin_type(*t)
-        self.the_empty_object_type = QAPISchemaObjectType('q_empty', None,
-                                                          None, [], None)
+        self.the_empty_object_type = QAPISchemaObjectType(
+            'q_empty', None, None, None, [], None)
         self._def_entity(self.the_empty_object_type)
         qtype_values = self._make_enum_members(['none', 'qnull', 'qint',
                                                 'qstring', 'qdict', 'qlist',
                                                 'qfloat', 'qbool'])
-        self._def_entity(QAPISchemaEnumType('QType', None, qtype_values,
-                                            'QTYPE'))
+        self._def_entity(QAPISchemaEnumType('QType', None, None,
+                                            qtype_values, 'QTYPE'))
 
     def _make_enum_members(self, values):
         return [QAPISchemaMember(v) for v in values]
@@ -1549,7 +1568,7 @@ class QAPISchema(object):
         # See also QAPISchemaObjectTypeMember._pretty_owner()
         name = name + 'Kind'   # Use namespace reserved by add_name()
         self._def_entity(QAPISchemaEnumType(
-            name, info, self._make_enum_members(values), None))
+            name, info, None, self._make_enum_members(values), None))
         return name
 
     def _make_array_type(self, element_type, info):
@@ -1558,22 +1577,22 @@ class QAPISchema(object):
             self._def_entity(QAPISchemaArrayType(name, info, element_type))
         return name
 
-    def _make_implicit_object_type(self, name, info, role, members):
+    def _make_implicit_object_type(self, name, info, doc, role, members):
         if not members:
             return None
         # See also QAPISchemaObjectTypeMember._pretty_owner()
         name = 'q_obj_%s-%s' % (name, role)
         if not self.lookup_entity(name, QAPISchemaObjectType):
-            self._def_entity(QAPISchemaObjectType(name, info, None,
+            self._def_entity(QAPISchemaObjectType(name, info, doc, None,
                                                   members, None))
         return name
 
-    def _def_enum_type(self, expr, info):
+    def _def_enum_type(self, expr, info, doc):
         name = expr['enum']
         data = expr['data']
         prefix = expr.get('prefix')
         self._def_entity(QAPISchemaEnumType(
-            name, info, self._make_enum_members(data), prefix))
+            name, info, doc, self._make_enum_members(data), prefix))
 
     def _make_member(self, name, typ, info):
         optional = False
@@ -1589,11 +1608,11 @@ class QAPISchema(object):
         return [self._make_member(key, value, info)
                 for (key, value) in data.iteritems()]
 
-    def _def_struct_type(self, expr, info):
+    def _def_struct_type(self, expr, info, doc):
         name = expr['struct']
         base = expr.get('base')
         data = expr['data']
-        self._def_entity(QAPISchemaObjectType(name, info, base,
+        self._def_entity(QAPISchemaObjectType(name, info, doc, base,
                                               self._make_members(data, info),
                                               None))
 
@@ -1605,10 +1624,10 @@ class QAPISchema(object):
             assert len(typ) == 1
             typ = self._make_array_type(typ[0], info)
         typ = self._make_implicit_object_type(
-            typ, info, 'wrapper', [self._make_member('data', typ, info)])
+            typ, info, None, 'wrapper', [self._make_member('data', typ, info)])
         return QAPISchemaObjectTypeVariant(case, typ)
 
-    def _def_union_type(self, expr, info):
+    def _def_union_type(self, expr, info, doc):
         name = expr['union']
         data = expr['data']
         base = expr.get('base')
@@ -1616,7 +1635,7 @@ class QAPISchema(object):
         tag_member = None
         if isinstance(base, dict):
             base = (self._make_implicit_object_type(
-                    name, info, 'base', self._make_members(base, info)))
+                    name, info, doc, 'base', self._make_members(base, info)))
         if tag_name:
             variants = [self._make_variant(key, value)
                         for (key, value) in data.iteritems()]
@@ -1629,24 +1648,24 @@ class QAPISchema(object):
             tag_member = QAPISchemaObjectTypeMember('type', typ, False)
             members = [tag_member]
         self._def_entity(
-            QAPISchemaObjectType(name, info, base, members,
+            QAPISchemaObjectType(name, info, doc, base, members,
                                  QAPISchemaObjectTypeVariants(tag_name,
                                                               tag_member,
                                                               variants)))
 
-    def _def_alternate_type(self, expr, info):
+    def _def_alternate_type(self, expr, info, doc):
         name = expr['alternate']
         data = expr['data']
         variants = [self._make_variant(key, value)
                     for (key, value) in data.iteritems()]
         tag_member = QAPISchemaObjectTypeMember('type', 'QType', False)
         self._def_entity(
-            QAPISchemaAlternateType(name, info,
+            QAPISchemaAlternateType(name, info, doc,
                                     QAPISchemaObjectTypeVariants(None,
                                                                  tag_member,
                                                                  variants)))
 
-    def _def_command(self, expr, info):
+    def _def_command(self, expr, info, doc):
         name = expr['command']
         data = expr.get('data')
         rets = expr.get('returns')
@@ -1655,38 +1674,39 @@ class QAPISchema(object):
         boxed = expr.get('boxed', False)
         if isinstance(data, OrderedDict):
             data = self._make_implicit_object_type(
-                name, info, 'arg', self._make_members(data, info))
+                name, info, doc, 'arg', self._make_members(data, info))
         if isinstance(rets, list):
             assert len(rets) == 1
             rets = self._make_array_type(rets[0], info)
-        self._def_entity(QAPISchemaCommand(name, info, data, rets, gen,
-                                           success_response, boxed))
+        self._def_entity(QAPISchemaCommand(name, info, doc, data, rets,
+                                           gen, success_response, boxed))
 
-    def _def_event(self, expr, info):
+    def _def_event(self, expr, info, doc):
         name = expr['event']
         data = expr.get('data')
         boxed = expr.get('boxed', False)
         if isinstance(data, OrderedDict):
             data = self._make_implicit_object_type(
-                name, info, 'arg', self._make_members(data, info))
-        self._def_entity(QAPISchemaEvent(name, info, data, boxed))
+                name, info, doc, 'arg', self._make_members(data, info))
+        self._def_entity(QAPISchemaEvent(name, info, doc, data, boxed))
 
     def _def_exprs(self):
         for expr_elem in self.exprs:
             expr = expr_elem['expr']
             info = expr_elem['info']
+            doc = expr_elem.get('doc')
             if 'enum' in expr:
-                self._def_enum_type(expr, info)
+                self._def_enum_type(expr, info, doc)
             elif 'struct' in expr:
-                self._def_struct_type(expr, info)
+                self._def_struct_type(expr, info, doc)
             elif 'union' in expr:
-                self._def_union_type(expr, info)
+                self._def_union_type(expr, info, doc)
             elif 'alternate' in expr:
-                self._def_alternate_type(expr, info)
+                self._def_alternate_type(expr, info, doc)
             elif 'command' in expr:
-                self._def_command(expr, info)
+                self._def_command(expr, info, doc)
             elif 'event' in expr:
-                self._def_event(expr, info)
+                self._def_event(expr, info, doc)
             else:
                 assert False
 
Signature · 1 line
2.7.4
Reviewed-by on v1 14/47
#41 lore raw

Re: [Qemu-devel] [PATCH for-2.9 14/47] qapi: Prepare for requiring more complete documentation

Quoted 3 lines · Markus Armbruster

We currently neglect to check all enumeration values, common members of object types and members of alternate types are documented. Unsurprisingly, many aren't.

And some, like QKeyCode, would be a pain to document.

Quoted 10 lines

Add the necessary plumbing to find undocumented ones, except for variant members of object types. Don't enforce anything just yet, but connect each QAPIDoc.ArgSection to its QAPISchemaMember.

---
 scripts/qapi.py | 110 +++++++++++++++++++++++++++++++++-----------------------
 1 file changed, 65 insertions(+), 45 deletions(-)

Lots of plumbing added, but I'm not spotting any obvious omissions.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#42 lore raw

PATCH 15/47 qapi: Conjure up QAPIDoc.ArgSection for undocumented members

In reply to Markus Armbruster

qapi2texi.py already conjures up ArgSections for undocumented enumeration values, in texi_enum). Drop that, and conjure them up for all kinds of "arguments" (enumeration values, object and alternate type members) in qapi.py instead.

Take care to keep generated documentation exactly the same for now.

---
 scripts/qapi.py      |  5 ++---
 scripts/qapi2texi.py | 31 ++++++++++++++++---------------
 2 files changed, 18 insertions(+), 18 deletions(-)
scripts/qapi.py +2 -3
index 4886417..2a2b33d 100644
@@ -224,9 +224,8 @@ class QAPIDoc(object):
     def connect_member(self, member):
         if not member.name in self.args:
             # Undocumented TODO outlaw
-            pass
-        else:
-            self.args[member.name].connect(member)
+            self.args[member.name] = QAPIDoc.ArgSection(member.name)
+        self.args[member.name].connect(member)
 
 
 class QAPISchemaParser(object):
scripts/qapi2texi.py +16 -15
index 0aaf45c..299dcf9 100755
@@ -123,7 +123,7 @@ def texi_format(doc):
     return "\n".join(lines)
 
 
-def texi_body(doc):
+def texi_body(doc, only_documented=False):
     """
     Format the body of a symbol documentation:
     - main body
@@ -131,17 +131,21 @@ def texi_body(doc):
     - followed by "Returns/Notes/Since/Example" sections
     """
     body = texi_format(str(doc.body)) + "\n"
-    if doc.args:
+
+    args = ''
+    for name, section in doc.args.iteritems():
+        if not section.content and not only_documented:
+            continue        # Undocumented TODO require doc and drop
+        desc = str(section)
+        opt = ''
+        if section.optional:
+            desc = re.sub(r'^ *#optional *\n?|\n? *#optional *$|#optional',
+                          '', desc)
+            opt = ' (optional)'
+        args += "@item @code{'%s'}%s\n%s\n" % (name, opt, texi_format(desc))
+    if args:
         body += "@table @asis\n"
-        for arg, section in doc.args.iteritems():
-            desc = str(section)
-            opt = ''
-            if section.optional:
-                desc = re.sub(r'^ *#optional *\n?|\n? *#optional *$|#optional',
-                              '', desc)
-                opt = ' (optional)'
-            body += "@item @code{'%s'}%s\n%s\n" % (arg, opt,
-                                                   texi_format(desc))
+        body += args
         body += "@end table\n"
 
     for section in doc.sections:
@@ -183,10 +187,7 @@ def texi_union(expr, doc):
 
 def texi_enum(expr, doc):
     """Format an enum to texi"""
-    for i in expr['data']:
-        if i not in doc.args:
-            doc.args[i] = qapi.QAPIDoc.ArgSection(i)
-    body = texi_body(doc)
+    body = texi_body(doc, True)
     return TYPE_FMT(type="Enum",
                     name=doc.symbol,
                     body=body)
Signature · 1 line
2.7.4
Reviewed-by on v1 15/47
#43 lore raw

Re: [Qemu-devel] [PATCH for-2.9 15/47] qapi: Conjure up QAPIDoc.ArgSection for undocumented members

Quoted 2 lines · Markus Armbruster

qapi2texi.py already conjures up ArgSections for undocumented enumeration values, in texi_enum). Drop that, and conjure them up for

Missing '('?

Quoted 11 lines

all kinds of "arguments" (enumeration values, object and alternate type members) in qapi.py instead.

Take care to keep generated documentation exactly the same for now.

---
 scripts/qapi.py      |  5 ++---
 scripts/qapi2texi.py | 31 ++++++++++++++++---------------
 2 files changed, 18 insertions(+), 18 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#44 lore raw

Re: [Qemu-devel] [PATCH for-2.9 15/47] qapi: Conjure up QAPIDoc.ArgSection for undocumented members

Quoted 5 lines · Eric Blake
Quoted 2 lines · Markus Armbruster

qapi2texi.py already conjures up ArgSections for undocumented enumeration values, in texi_enum). Drop that, and conjure them up for

Missing '('?

Or extra ')'. I'll clean it up.

Quoted 5 lines
Quoted 5 lines

all kinds of "arguments" (enumeration values, object and alternate type members) in qapi.py instead.

Take care to keep generated documentation exactly the same for now.

Quoted 8 lines
Quoted 6 lines
---
 scripts/qapi.py      |  5 ++---
 scripts/qapi2texi.py | 31 ++++++++++++++++---------------
 2 files changed, 18 insertions(+), 18 deletions(-)

Thanks!

#45 lore raw

PATCH 16/47 qapi2texi: Convert to QAPISchemaVisitor

In reply to Markus Armbruster

qapi2texi works with schema expression trees. Such a tight coupling to schema language syntax is not a good idea. Convert it to the visitor interface the other generators use.

No change to generated documentation.

---
 scripts/qapi2texi.py | 228 ++++++++++++++++++++++++++-------------------------
 1 file changed, 118 insertions(+), 110 deletions(-)
scripts/qapi2texi.py +118 -110
index 299dcf9..6d4e757 100755
@@ -123,31 +123,39 @@ def texi_format(doc):
     return "\n".join(lines)
 
 
-def texi_body(doc, only_documented=False):
-    """
-    Format the body of a symbol documentation:
-    - main body
-    - table of arguments
-    - followed by "Returns/Notes/Since/Example" sections
-    """
-    body = texi_format(str(doc.body)) + "\n"
-
-    args = ''
-    for name, section in doc.args.iteritems():
-        if not section.content and not only_documented:
-            continue        # Undocumented TODO require doc and drop
-        desc = str(section)
-        opt = ''
-        if section.optional:
-            desc = re.sub(r'^ *#optional *\n?|\n? *#optional *$|#optional',
-                          '', desc)
-            opt = ' (optional)'
-        args += "@item @code{'%s'}%s\n%s\n" % (name, opt, texi_format(desc))
-    if args:
-        body += "@table @asis\n"
-        body += args
-        body += "@end table\n"
+def texi_body(doc):
+    """Format the main documentation body"""
+    return texi_format(str(doc.body)) + '\n'
 
+
+def texi_enum_value(value):
+    """Format a table of members item for an enumeration value"""
+    return "@item @code{'%s'}\n" % value.name
+
+
+def texi_member(member):
+    """Format a table of members item for an object type member"""
+    return "@item @code{'%s'}%s\n" % (
+        member.name, ' (optional)' if member.optional else '')
+
+
+def texi_members(doc, member_func, show_undocumented):
+    """Format the table of members"""
+    items = ''
+    for section in doc.args.itervalues():
+        if not section.content and not show_undocumented:
+            continue          # Undocumented TODO require doc and drop
+        desc = re.sub(r'^ *#optional *\n?|\n? *#optional *$|#optional',
+                      '', str(section))
+        items += member_func(section.member) + texi_format(desc) + '\n'
+    if not items:
+        return ''
+    return '@table @asis\n' + items + '@end table\n'
+
+
+def texi_sections(doc):
+    """Format additional sections following arguments"""
+    body = ''
     for section in doc.sections:
         name, doc = (section.name, str(section))
         func = texi_format
@@ -159,94 +167,94 @@ def texi_body(doc, only_documented=False):
             body += "\n\n@b{%s:}\n" % name
 
         body += func(doc)
-
     return body
 
 
-def texi_alternate(expr, doc):
-    """Format an alternate to texi"""
-    body = texi_body(doc)
-    return TYPE_FMT(type="Alternate",
-                    name=doc.symbol,
-                    body=body)
-
-
-def texi_union(expr, doc):
-    """Format a union to texi"""
-    discriminator = expr.get("discriminator")
-    if discriminator:
-        union = "Flat Union"
-    else:
-        union = "Simple Union"
-
-    body = texi_body(doc)
-    return TYPE_FMT(type=union,
-                    name=doc.symbol,
-                    body=body)
-
-
-def texi_enum(expr, doc):
-    """Format an enum to texi"""
-    body = texi_body(doc, True)
-    return TYPE_FMT(type="Enum",
-                    name=doc.symbol,
-                    body=body)
-
-
-def texi_struct(expr, doc):
-    """Format a struct to texi"""
-    body = texi_body(doc)
-    return TYPE_FMT(type="Struct",
-                    name=doc.symbol,
-                    body=body)
-
-
-def texi_command(expr, doc):
-    """Format a command to texi"""
-    body = texi_body(doc)
-    return MSG_FMT(type="Command",
-                   name=doc.symbol,
-                   body=body)
-
-
-def texi_event(expr, doc):
-    """Format an event to texi"""
-    body = texi_body(doc)
-    return MSG_FMT(type="Event",
-                   name=doc.symbol,
-                   body=body)
-
-
-def texi_expr(expr, doc):
-    """Format an expr to texi"""
-    (kind, _) = expr.items()[0]
-
-    fmt = {"command": texi_command,
-           "struct": texi_struct,
-           "enum": texi_enum,
-           "union": texi_union,
-           "alternate": texi_alternate,
-           "event": texi_event}[kind]
-
-    return fmt(expr, doc)
-
-
-def texi(docs):
-    """Convert QAPI schema expressions to texi documentation"""
-    res = []
-    for doc in docs:
-        expr = doc.expr
-        if not expr:
-            res.append(texi_body(doc))
-            continue
-        try:
-            doc = texi_expr(expr, doc)
-            res.append(doc)
-        except:
-            print >>sys.stderr, "error at @%s" % doc.info
-            raise
-
-    return '\n'.join(res)
+def texi_entity(doc, member_func=texi_member, show_undocumented=False):
+    return (texi_body(doc)
+            + texi_members(doc, member_func, show_undocumented)
+            + texi_sections(doc))
+
+
+class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
+    def __init__(self):
+        self.out = None
+        self.cur_doc = None
+
+    def visit_begin(self, schema):
+        self.out = ''
+
+    def visit_enum_type(self, name, info, values, prefix):
+        doc = self.cur_doc
+        if self.out:
+            self.out += '\n'
+        self.out += TYPE_FMT(type='Enum',
+                             name=doc.symbol,
+                             body=texi_entity(doc,
+                                              member_func=texi_enum_value,
+                                              show_undocumented=True))
+
+    def visit_object_type(self, name, info, base, members, variants):
+        doc = self.cur_doc
+        if not variants:
+            typ = 'Struct'
+        elif variants._tag_name:        # TODO unclean member access
+            typ = 'Flat Union'
+        else:
+            typ = 'Simple Union'
+        if self.out:
+            self.out += '\n'
+        self.out += TYPE_FMT(type=typ,
+                             name=doc.symbol,
+                             body=texi_entity(doc))
+
+    def visit_alternate_type(self, name, info, variants):
+        doc = self.cur_doc
+        if self.out:
+            self.out += '\n'
+        self.out += TYPE_FMT(type='Alternate',
+                             name=doc.symbol,
+                             body=texi_entity(doc))
+
+    def visit_command(self, name, info, arg_type, ret_type,
+                      gen, success_response, boxed):
+        doc = self.cur_doc
+        if self.out:
+            self.out += '\n'
+        self.out += MSG_FMT(type='Command',
+                            name=doc.symbol,
+                            body=texi_entity(doc))
+
+    def visit_event(self, name, info, arg_type, boxed):
+        doc = self.cur_doc
+        if self.out:
+            self.out += '\n'
+        self.out += MSG_FMT(type='Event',
+                            name=doc.symbol,
+                            body=texi_entity(doc))
+
+    def symbol(self, doc, entity):
+        self.cur_doc = doc
+        entity.visit(self)
+        self.cur_doc = None
+
+    def freeform(self, doc):
+        assert not doc.args
+        if self.out:
+            self.out += '\n'
+        self.out += texi_body(doc) + texi_sections(doc)
+
+
+def texi_schema(schema):
+    """Convert QAPI schema documentation to Texinfo"""
+    gen = QAPISchemaGenDocVisitor()
+    gen.visit_begin(schema)
+    for doc in schema.docs:
+        if doc.symbol:
+            gen.symbol(doc, schema.lookup_entity(doc.symbol))
+        else:
+            gen.freeform(doc)
+    return gen.out
 
 
 def main(argv):
@@ -259,7 +267,7 @@ def main(argv):
     if not qapi.doc_required:
         print >>sys.stderr, ("%s: need pragma 'doc-required' "
                              "to generate documentation" % argv[0])
-    print texi(schema.docs)
+    print texi_schema(schema)
 
 
 if __name__ == "__main__":
Signature · 1 line
2.7.4
Reviewed-by on v1 16/47
#46 lore raw

Re: [Qemu-devel] [PATCH for-2.9 16/47] qapi2texi: Convert to QAPISchemaVisitor

Quoted 12 lines · Markus Armbruster

qapi2texi works with schema expression trees. Such a tight coupling to schema language syntax is not a good idea. Convert it to the visitor interface the other generators use.

No change to generated documentation.

---
 scripts/qapi2texi.py | 228 ++++++++++++++++++++++++++-------------------------
 1 file changed, 118 insertions(+), 110 deletions(-)

scripts/qapi2texi.py def texi_body(doc, only_documented=False): · line 204

Quoted 8 lines
scripts/qapi2texi.py +8 -0
+    def visit_object_type(self, name, info, base, members, variants):
+        doc = self.cur_doc
+        if not variants:
+            typ = 'Struct'
+        elif variants._tag_name:        # TODO unclean member access
+            typ = 'Flat Union'
+        else:
+            typ = 'Simple Union'

Do we even want to document this distinction to the end user? Introspection managed to hide the difference by introducing the appropriate generated wrapper types that demonstrate the additional {} nesting in a way compatible with rewriting simple unions into flat unions. If we don't explain the difference here, we can get rid of the unclean member access, but then again risk documentation that is not clear whether {} nesting is needed.

I guess there's also the fact that for this patch, you intentionally tried to make no difference to the generated docs (good); so any tweaks to union output should be later patches anyways.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#47 lore raw

Re: [Qemu-devel] [PATCH for-2.9 16/47] qapi2texi: Convert to QAPISchemaVisitor

Quoted 22 lines · Eric Blake
Quoted 12 lines · Markus Armbruster

qapi2texi works with schema expression trees. Such a tight coupling to schema language syntax is not a good idea. Convert it to the visitor interface the other generators use.

No change to generated documentation.

---
 scripts/qapi2texi.py | 228 ++++++++++++++++++++++++++-------------------------
 1 file changed, 118 insertions(+), 110 deletions(-)

scripts/qapi2texi.py def texi_body(doc, only_documented=False): · line 204

Quoted 8 lines
scripts/qapi2texi.py +8 -0
+    def visit_object_type(self, name, info, base, members, variants):
+        doc = self.cur_doc
+        if not variants:
+            typ = 'Struct'
+        elif variants._tag_name:        # TODO unclean member access
+            typ = 'Flat Union'
+        else:
+            typ = 'Simple Union'
Quoted 1 line

Do we even want to document this distinction to the end user?

No, we don't. '[PATCH for-2.9 29/47] qapi2texi: Use category "Object" for all object types' takes care of it.

Quoted 7 lines

Introspection managed to hide the difference by introducing the appropriate generated wrapper types that demonstrate the additional {} nesting in a way compatible with rewriting simple unions into flat unions. If we don't explain the difference here, we can get rid of the unclean member access, but then again risk documentation that is not clear whether {} nesting is needed.

Quoted 5 lines

I guess there's also the fact that for this patch, you intentionally tried to make no difference to the generated docs (good); so any tweaks to union output should be later patches anyways.

Thanks!

#48 lore raw

PATCH 17/47 qapi: The #optional tag is redundant, drop

In reply to Markus Armbruster

We traditionally mark optional members #optional in the doc comment. Before commit 3313b61, this was entirely manual.

Commit 3313b61 added some automation because its qapi2texi.py relied on #optional to determine whether a member is optional. This is no longer the case since the previous commit: the only thing qapi2texi.py still does with #optional is stripping it out. We still reject bogus qapi-schema.json and six places for qga/qapi-schema.json.

Thus, you can't actually rely on #optional to see whether something is optional. Yet we still make people add it manually. That's just busy-work.

Drop the code to check, fix up and strip out #optional, along with all instances of #optional. To keep it out, add code to reject it, to be dropped again once the dust settles.

No change to generated documentation.

---
 docs/qapi-code-gen.txt              |  16 +-
 docs/writing-qmp-commands.txt       |   4 +-
 qapi-schema.json                    | 378 ++++++++++++++++----------------
 qapi/block-core.json                | 418 ++++++++++++++++++------------------
 qapi/block.json                     |   8 +-
 qapi/crypto.json                    |  22 +-
 qapi/event.json                     |  10 +-
 qapi/introspect.json                |   6 +-
 qapi/rocker.json                    |  70 +++---
 qapi/trace.json                     |   6 +-
 qga/qapi-schema.json                |  38 ++--
 scripts/qapi.py                     |  23 +-
 scripts/qapi2texi.py                |   3 +-
 tests/Makefile.include              |   1 -
 tests/qapi-schema/doc-optional.err  |   1 -
 tests/qapi-schema/doc-optional.exit |   1 -
 tests/qapi-schema/doc-optional.json |   7 -
 tests/qapi-schema/doc-optional.out  |   0
 18 files changed, 491 insertions(+), 521 deletions(-)
 delete mode 100644 tests/qapi-schema/doc-optional.err
 delete mode 100644 tests/qapi-schema/doc-optional.exit
 delete mode 100644 tests/qapi-schema/doc-optional.json
 delete mode 100644 tests/qapi-schema/doc-optional.out
docs/qapi-code-gen.txt +7 -9
index 349dc02..4767825 100644
@@ -131,10 +131,8 @@ and optional tagged sections.
 
 FIXME: the parser accepts these things in almost any order.
 
-Optional arguments / members are tagged with the phrase '#optional',
-often with their default value; and extensions added after the
-expression was first released are also given a '(since x.y.z)'
-comment.
+Extensions added after the expression was first released carry a
+'(since x.y.z)' comment.
 
 A tagged section starts with one of the following words:
 "Note:"/"Notes:", "Since:", "Example"/"Examples", "Returns:", "TODO:".
@@ -150,10 +148,10 @@ For example:
 #
 # Statistics of a virtual block device or a block backing device.
 #
-# @device: #optional If the stats are for a virtual block device, the name
-#          corresponding to the virtual block device.
+# @device: If the stats are for a virtual block device, the name
+# corresponding to the virtual block device.
 #
-# @node-name: #optional The node name of the device. (since 2.3)
+# @node-name: The node name of the device. (since 2.3)
 #
 # ... more members ...
 #
@@ -168,8 +166,8 @@ For example:
 #
 # Query the @BlockStats for all virtual block devices.
 #
-# @query-nodes: #optional If true, the command will query all the
-#               block nodes ... explain, explain ...  (since 2.3)
+# @query-nodes: If true, the command will query all the block nodes
+# ... explain, explain ...  (since 2.3)
 #
 # Returns: A list of @BlockStats for each virtual block devices.
 #
docs/writing-qmp-commands.txt +2 -2
index 44c14db..1e63754 100644
@@ -252,7 +252,7 @@ here goes "hello-world"'s new entry for the qapi-schema.json file:
 #
 # Print a client provided string to the standard output stream.
 #
-# @message: #optional string to be printed
+# @message: string to be printed
 #
 # Returns: Nothing on success.
 #
@@ -358,7 +358,7 @@ The best way to return that data is to create a new QAPI type, as shown below:
 #
 # @clock-name: The alarm clock method's name.
 #
-# @next-deadline: #optional The time (in nanoseconds) the next alarm will fire.
+# @next-deadline: The time (in nanoseconds) the next alarm will fire.
 #
 # Since: 1.0
 ##
qapi-schema.json +188 -190

980 lines not on this page · raw message

qapi/block-core.json +209 -209

1,097 lines not on this page · raw message

qapi/block.json +4 -4
index 22da914..46fca0e 100644
@@ -163,11 +163,11 @@
 #
 # Ejects a device from a removable drive.
 #
-# @device:  #optional Block device name (deprecated, use @id instead)
+# @device:  Block device name (deprecated, use @id instead)
 #
-# @id:      #optional The name or QOM path of the guest device (since: 2.8)
+# @id:      The name or QOM path of the guest device (since: 2.8)
 #
-# @force:   #optional If true, eject regardless of whether the drive is locked.
+# @force:   If true, eject regardless of whether the drive is locked.
 #           If not specified, the default value is false.
 #
 # Returns:  Nothing on success
@@ -215,7 +215,7 @@
 # @device: The device name or node name of the node to be exported
 #
 # @writable: Whether clients should be able to write to the device via the
-#     NBD connection (default false). #optional
+#     NBD connection (default false).
 #
 # Returns: error if the device is already marked for export.
 #
qapi/crypto.json +11 -11
index 93a0474..6b6fde3 100644
@@ -152,7 +152,7 @@
 #
 # The options that apply to QCow/QCow2 AES-CBC encryption format
 #
-# @key-secret: #optional the ID of a QCryptoSecret object providing the
+# @key-secret: the ID of a QCryptoSecret object providing the
 #              decryption key. Mandatory except when probing image for
 #              metadata only.
 #
@@ -166,7 +166,7 @@
 #
 # The options that apply to LUKS encryption format
 #
-# @key-secret: #optional the ID of a QCryptoSecret object providing the
+# @key-secret: the ID of a QCryptoSecret object providing the
 #              decryption key. Mandatory except when probing image for
 #              metadata only.
 # Since: 2.6
@@ -180,17 +180,17 @@
 #
 # The options that apply to LUKS encryption format initialization
 #
-# @cipher-alg: #optional the cipher algorithm for data encryption
+# @cipher-alg: the cipher algorithm for data encryption
 #              Currently defaults to 'aes'.
-# @cipher-mode: #optional the cipher mode for data encryption
+# @cipher-mode: the cipher mode for data encryption
 #               Currently defaults to 'cbc'
-# @ivgen-alg: #optional the initialization vector generator
+# @ivgen-alg: the initialization vector generator
 #             Currently defaults to 'essiv'
-# @ivgen-hash-alg: #optional the initialization vector generator hash
+# @ivgen-hash-alg: the initialization vector generator hash
 #                  Currently defaults to 'sha256'
-# @hash-alg: #optional the master key hash algorithm
+# @hash-alg: the master key hash algorithm
 #            Currently defaults to 'sha256'
-# @iter-time: #optional number of milliseconds to spend in
+# @iter-time: number of milliseconds to spend in
 #             PBKDF passphrase processing. Currently defaults
 #             to 2000. (since 2.8)
 # Since: 2.6
@@ -257,8 +257,8 @@
 #
 # @active: whether the key slot is currently in use
 # @key-offset: offset to the key material in bytes
-# @iters: #optional number of PBKDF2 iterations for key material
-# @stripes: #optional number of stripes for splitting key material
+# @iters: number of PBKDF2 iterations for key material
+# @stripes: number of stripes for splitting key material
 #
 # Since: 2.7
 ##
@@ -277,7 +277,7 @@
 # @cipher-alg: the cipher algorithm for data encryption
 # @cipher-mode: the cipher mode for data encryption
 # @ivgen-alg: the initialization vector generator
-# @ivgen-hash-alg: #optional the initialization vector generator hash
+# @ivgen-hash-alg: the initialization vector generator hash
 # @hash-alg: the master key hash algorithm
 # @payload-offset: offset to the payload data in bytes
 # @master-key-iters: number of PBKDF2 iterations for key material
qapi/event.json +5 -5
index e02852c..e80f3f4 100644
@@ -186,7 +186,7 @@
 # At this point, it's safe to reuse the specified device ID. Device removal can
 # be initiated by the guest or by HMP/QMP commands.
 #
-# @device: #optional device name
+# @device: device name
 #
 # @path: device path
 #
@@ -209,7 +209,7 @@
 # Emitted once until the 'query-rx-filter' command is executed, the first event
 # will always be emitted
 #
-# @name: #optional net client name
+# @name: net client name
 #
 # @path: device path
 #
@@ -488,7 +488,7 @@
 #
 # @action: action that has been taken, currently always "pause"
 #
-# @info: #optional information about a panic (since 2.9)
+# @info: information about a panic (since 2.9)
 #
 # Since: 1.5
 #
@@ -533,7 +533,7 @@
 #
 # @type: quorum operation type (Since 2.6)
 #
-# @error: #optional error message. Only present on failure. This field
+# @error: error message. Only present on failure. This field
 #         contains a human-readable error message. There are no semantics other
 #         than that the block layer reported an error and clients should not
 #         try to interpret the error string.
@@ -620,7 +620,7 @@
 #
 # @result: DumpQueryResult type described in qapi-schema.json.
 #
-# @error: #optional human-readable error string that provides
+# @error: human-readable error string that provides
 #         hint on why dump failed. Only presents on failure. The
 #         user should not try to interpret the error string.
 #
qapi/introspect.json +3 -3
index f6adc43..1dbaef5 100644
@@ -163,10 +163,10 @@
 #
 # @members: the object type's (non-variant) members, in no particular order.
 #
-# @tag: #optional the name of the member serving as type tag.
+# @tag: the name of the member serving as type tag.
 #       An element of @members with this name must exist.
 #
-# @variants: #optional variant members, i.e. additional members that
+# @variants: variant members, i.e. additional members that
 #            depend on the type tag's value.  Present exactly when
 #            @tag is present.  The variants are in no particular order,
 #            and may even differ from the order of the values of the
@@ -190,7 +190,7 @@
 #
 # @type: the name of the member's type.
 #
-# @default: #optional default when used as command parameter.
+# @default: default when used as command parameter.
 #           If absent, the parameter is mandatory.
 #           If present, the value must be null.  The parameter is
 #           optional, and behavior when it's missing is not specified
qapi/rocker.json +35 -35

135 lines not on this page · raw message

qapi/trace.json +3 -3
index 2bfda7a..de6588d 100644
@@ -48,7 +48,7 @@
 # Query the state of events.
 #
 # @name: Event name pattern (case-sensitive glob).
-# @vcpu: #optional The vCPU to query (any by default; since 2.7).
+# @vcpu: The vCPU to query (any by default; since 2.7).
 #
 # Returns: a list of @TraceEventInfo for the matching events
 #
@@ -81,8 +81,8 @@
 #
 # @name: Event name pattern (case-sensitive glob).
 # @enable: Whether to enable tracing.
-# @ignore-unavailable: #optional Do not match unavailable events with @name.
-# @vcpu: #optional The vCPU to act upon (all by default; since 2.7).
+# @ignore-unavailable: Do not match unavailable events with @name.
+# @vcpu: The vCPU to act upon (all by default; since 2.7).
 #
 # An event's state is modified if:
 # - its name matches the @name pattern, and
qga/qapi-schema.json +19 -19
index a8e4bda..a02dbf2 100644
@@ -144,7 +144,7 @@
 # If that's the case users are advised to always pass a
 # value.
 #
-# @time: #optional time of nanoseconds, relative to the Epoch
+# @time: time of nanoseconds, relative to the Epoch
 #        of 1970-01-01 in UTC.
 #
 # Returns: Nothing on success.
@@ -203,7 +203,7 @@
 # Initiate guest-activated shutdown. Note: this is an asynchronous
 # shutdown request, with no guarantee of successful shutdown.
 #
-# @mode: #optional "halt", "powerdown" (default), or "reboot"
+# @mode: "halt", "powerdown" (default), or "reboot"
 #
 # This command does NOT return a response on success. Success condition
 # is indicated by the VM exiting with a zero exit status or, when
@@ -222,7 +222,7 @@
 #
 # @path: Full path to the file in the guest to open.
 #
-# @mode: #optional open mode, as per fopen(), "r" is the default.
+# @mode: open mode, as per fopen(), "r" is the default.
 #
 # Returns: Guest file handle on success.
 #
@@ -270,7 +270,7 @@
 #
 # @handle: filehandle returned by guest-file-open
 #
-# @count: #optional maximum number of bytes to read (default is 4KB)
+# @count: maximum number of bytes to read (default is 4KB)
 #
 # Returns: @GuestFileRead on success.
 #
@@ -304,7 +304,7 @@
 #
 # @buf-b64: base64-encoded string representing data to be written
 #
-# @count: #optional bytes to write (actual bytes, after base64-decode),
+# @count: bytes to write (actual bytes, after base64-decode),
 #         default is all content in buf-b64 buffer after base64 decoding
 #
 # Returns: @GuestFileWrite on success.
@@ -441,7 +441,7 @@
 #
 # Sync and freeze specified guest filesystems
 #
-# @mountpoints: #optional an array of mountpoints of filesystems to be frozen.
+# @mountpoints: an array of mountpoints of filesystems to be frozen.
 #               If omitted, every mounted filesystem is frozen.
 #
 # Returns: Number of file systems currently frozen. On error, all filesystems
@@ -670,7 +670,7 @@
 #
 # @online: Whether the VCPU is enabled.
 #
-# @can-offline: #optional Whether offlining the VCPU is possible. This member
+# @can-offline: Whether offlining the VCPU is possible. This member
 #               is always filled in by the guest agent when the structure is
 #               returned, and always ignored on input (hence it can be omitted
 #               then).
@@ -858,7 +858,7 @@
 #
 # @online: Whether the MEMORY BLOCK is enabled in guest.
 #
-# @can-offline: #optional Whether offlining the MEMORY BLOCK is possible.
+# @can-offline: Whether offlining the MEMORY BLOCK is possible.
 #               This member is always filled in by the guest agent when the
 #               structure is returned, and always ignored on input (hence it
 #               can be omitted then).
@@ -911,7 +911,7 @@
 #
 # @response: the result of memory block operation.
 #
-# @error-code: #optional the error number.
+# @error-code: the error number.
 #               When memory block operation fails, we assign the value of
 #               'errno' to this member, it indicates what goes wrong.
 #               When the operation succeeds, it will be omitted.
@@ -979,16 +979,16 @@
 # @GuestExecStatus:
 #
 # @exited: true if process has already terminated.
-# @exitcode: #optional process exit code if it was normally terminated.
-# @signal: #optional signal number (linux) or unhandled exception code
+# @exitcode: process exit code if it was normally terminated.
+# @signal: signal number (linux) or unhandled exception code
 #       (windows) if the process was abnormally terminated.
-# @out-data: #optional base64-encoded stdout of the process
-# @err-data: #optional base64-encoded stderr of the process
+# @out-data: base64-encoded stdout of the process
+# @err-data: base64-encoded stderr of the process
 #       Note: @out-data and @err-data are present only
 #       if 'capture-output' was specified for 'guest-exec'
-# @out-truncated: #optional true if stdout was not fully captured
+# @out-truncated: true if stdout was not fully captured
 #       due to size limitation.
-# @err-truncated: #optional true if stderr was not fully captured
+# @err-truncated: true if stderr was not fully captured
 #       due to size limitation.
 #
 # Since: 2.5
@@ -1028,10 +1028,10 @@
 # Execute a command in the guest
 #
 # @path: path or executable name to execute
-# @arg: #optional argument list to pass to executable
-# @env: #optional environment variables to pass to executable
-# @input-data: #optional data to be passed to process stdin (base64 encoded)
-# @capture-output: #optional bool flag to enable capture of
+# @arg: argument list to pass to executable
+# @env: environment variables to pass to executable
+# @input-data: data to be passed to process stdin (base64 encoded)
+# @capture-output: bool flag to enable capture of
 #                  stdout/stderr of running process. defaults to false.
 #
 # Returns: PID on success.
scripts/qapi.py +4 -19
index 2a2b33d..c580e76 100644
@@ -219,6 +219,10 @@ class QAPIDoc(object):
         if (in_arg or not self.section.name
                 or not self.section.name.startswith("Example")):
             line = line.strip()
+        # TODO Drop this once the dust has settled
+        if (isinstance(self.section, QAPIDoc.ArgSection)
+                and '#optional' in line):
+            raise QAPISemError(self.info, "Please drop the #optional tag")
         self.section.append(line)
 
     def connect_member(self, member):
@@ -981,25 +985,6 @@ def check_definition_doc(doc, expr, info):
             or (meta == 'union' and not expr.get('discriminator'))):
         args.append('type')
 
-    for arg in args:
-        if arg[0] == '*':
-            opt = True
-            desc = doc.args.get(arg[1:])
-        else:
-            opt = False
-            desc = doc.args.get(arg)
-        if not desc:
-            continue
-        desc.optional = opt
-        desc_opt = "#optional" in str(desc)
-        if desc_opt and not opt:
-            raise QAPISemError(info, "Description has #optional, "
-                               "but the declaration doesn't")
-        if not desc_opt and opt:
-            # TODO either fix the schema and make this an error,
-            # or drop #optional entirely
-            pass
-
     doc_args = set(doc.args.keys())
     args = set([name.strip('*') for name in args])
     if not doc_args.issubset(args):
scripts/qapi2texi.py +1 -2
index 6d4e757..4583477 100755
@@ -145,8 +145,7 @@ def texi_members(doc, member_func, show_undocumented):
     for section in doc.args.itervalues():
         if not section.content and not show_undocumented:
             continue          # Undocumented TODO require doc and drop
-        desc = re.sub(r'^ *#optional *\n?|\n? *#optional *$|#optional',
-                      '', str(section))
+        desc = str(section)
         items += member_func(section.member) + texi_format(desc) + '\n'
     if not items:
         return ''
tests/Makefile.include +0 -1
index 9f4e890..7230977 100644
@@ -385,7 +385,6 @@ qapi-schema += doc-missing.json
 qapi-schema += doc-missing-colon.json
 qapi-schema += doc-missing-expr.json
 qapi-schema += doc-missing-space.json
-qapi-schema += doc-optional.json
 qapi-schema += double-data.json
 qapi-schema += double-type.json
 qapi-schema += duplicate-key.json
tests/qapi-schema/doc-optional.err deleted +0 -1
deleted file mode 100644
index 20d405a..0000000
@@ -1 +0,0 @@
-tests/qapi-schema/doc-optional.json:3: Description has #optional, but the declaration doesn't
tests/qapi-schema/doc-optional.exit deleted +0 -1
deleted file mode 100644
index d00491f..0000000
@@ -1 +0,0 @@
-1
tests/qapi-schema/doc-optional.json deleted +0 -7
deleted file mode 100644
index 06c855e..0000000
@@ -1,7 +0,0 @@
-# Description #optional should match declaration
-
-##
-# @foo:
-# @a: a #optional
-##
-{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-optional.out deleted +0 -0
deleted file mode 100644
index e69de29..0000000
Signature · 1 line
2.7.4
Reviewed-by on v1 17/47
#49 lore raw

Re: [Qemu-devel] [PATCH for-2.9 17/47] qapi: The #optional tag is redundant, drop

Quoted 9 lines · Markus Armbruster

We traditionally mark optional members #optional in the doc comment. Before commit 3313b61, this was entirely manual.

Commit 3313b61 added some automation because its qapi2texi.py relied on #optional to determine whether a member is optional. This is no longer the case since the previous commit: the only thing qapi2texi.py still does with #optional is stripping it out. We still reject bogus qapi-schema.json and six places for qga/qapi-schema.json.

Quoted 3 lines

Thus, you can't actually rely on #optional to see whether something is optional. Yet we still make people add it manually. That's just busy-work.

Yay! Let the computer do the work for us!

Quoted 11 lines

Drop the code to check, fix up and strip out #optional, along with all instances of #optional. To keep it out, add code to reject it, to be dropped again once the dust settles.

No change to generated documentation.

---

docs/qapi-code-gen.txt For example: · line 152

Quoted 7 lines
docs/qapi-code-gen.txt +2 -2
@@ -150,10 +148,10 @@ For example:
 #
 # Statistics of a virtual block device or a block backing device.
 #
-# @device: #optional If the stats are for a virtual block device, the name
-#          corresponding to the virtual block device.
+# @device: If the stats are for a virtual block device, the name
+# corresponding to the virtual block device.

This loses the hanging indentation in the example, but I don't see you making that change in the actual .json files. It shouldn't matter in the long run, and is certainly easier if the way you generated this patch was with sed scripts (where computing correct hanging indentation after rewrapping is a lot harder than omitting it). I don't have any strong opinions about the change (less typing, but slightly harder to visually see that the following lines belong to the same parameter doc, if you don't have blank lines between distinct parameter docs). I'm not even sure if it you want to call it out in the commit message as an intentional reformat, particularly since you didn't do it everywhere.

qapi-schema.json line 157

Quoted 12 lines
qapi-schema.json +3 -2
+++ b/qapi-schema.json
@@ -150,10 +150,10 @@
 #
 # @fdname: file descriptor name previously passed via 'getfd' command
 #
-# @skipauth: #optional whether to skip authentication. Only applies
+# @skipauth: whether to skip authentication. Only applies
 #            to "vnc" and "spice" protocols
 #
-# @tls: #optional whether to perform TLS. Only applies to the "spice"
+# @tls: whether to perform TLS. Only applies to the "spice"
 #       protocol

Again, whitespace changes shouldn't affect generated output, so rewrapping lines like this would be more busy-work than necessary, even though this particular example would now fit on one line.

Quoted 2 lines
(quoted diff) +0 -0
@@ -667,45 +667,45 @@
 #

...

qapi-schema.json line 702

Quoted 7 lines

#

qapi-schema.json +1 -1
-# @setup-time: #optional amount of setup time in milliseconds _before_ the
+# @setup-time: amount of setup time in milliseconds _before_ the
 #        iterations begin but _after_ the QMP command is issued. This is designed
 #        to provide an accounting of any activities (such as RDMA pinning) which
 #        may be expensive, but do not actually occur during the iterative
 #        migration rounds themselves. (since 1.6)

Here's another place where wrapping now looks odd (short, followed by multiple longer lines). Again, the effort of rewrapping lines is not worth the churn (and it's actually easier to read diffs that _don't_ reflow text). So I'll just overlook wrapping oddities in the rest of the patch, as inconsequential to the end result.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#50 lore raw

Re: [Qemu-devel] [PATCH for-2.9 17/47] qapi: The #optional tag is redundant, drop

Quoted 26 lines · Eric Blake
Quoted 9 lines · Markus Armbruster

We traditionally mark optional members #optional in the doc comment. Before commit 3313b61, this was entirely manual.

Commit 3313b61 added some automation because its qapi2texi.py relied on #optional to determine whether a member is optional. This is no longer the case since the previous commit: the only thing qapi2texi.py still does with #optional is stripping it out. We still reject bogus qapi-schema.json and six places for qga/qapi-schema.json.

Quoted 3 lines

Thus, you can't actually rely on #optional to see whether something is optional. Yet we still make people add it manually. That's just busy-work.

Yay! Let the computer do the work for us!

Quoted 9 lines

Drop the code to check, fix up and strip out #optional, along with all instances of #optional. To keep it out, add code to reject it, to be dropped again once the dust settles.

No change to generated documentation.

---

Quoted 14 lines

docs/qapi-code-gen.txt For example: · line 152

Quoted 8 lines
docs/qapi-code-gen.txt +2 -2
@@ -150,10 +148,10 @@ For example:
 #
 # Statistics of a virtual block device or a block backing device.
 #
-# @device: #optional If the stats are for a virtual block device, the name
-#          corresponding to the virtual block device.
+# @device: If the stats are for a virtual block device, the name
+# corresponding to the virtual block device.

This loses the hanging indentation in the example, but I don't see you making that change in the actual .json files. It shouldn't matter in the long run, and is certainly easier if the way you generated this patch was with sed scripts (where computing correct hanging indentation after rewrapping is a lot harder than omitting it).

Obvious sed job.

Quoted 6 lines

I don't have any
strong opinions about the change (less typing, but slightly harder to visually see that the following lines belong to the same parameter doc, if you don't have blank lines between distinct parameter docs). I'm not even sure if it you want to call it out in the commit message as an intentional reformat, particularly since you didn't do it everywhere.

I'll touch up this patch to change qapi-code-gen.txt exactly like the schema.

Quoted 20 lines

qapi-schema.json line 157

Quoted 12 lines
qapi-schema.json +3 -2
+++ b/qapi-schema.json
@@ -150,10 +150,10 @@
 #
 # @fdname: file descriptor name previously passed via 'getfd' command
 #
-# @skipauth: #optional whether to skip authentication. Only applies
+# @skipauth: whether to skip authentication. Only applies
 #            to "vnc" and "spice" protocols
 #
-# @tls: #optional whether to perform TLS. Only applies to the "spice"
+# @tls: whether to perform TLS. Only applies to the "spice"
 #       protocol

Again, whitespace changes shouldn't affect generated output, so rewrapping lines like this would be more busy-work than necessary, even though this particular example would now fit on one line.

Quoted 2 lines
(quoted diff) +0 -0
@@ -667,45 +667,45 @@
 #

...

Quoted 13 lines

qapi-schema.json line 702

Quoted 7 lines

#

qapi-schema.json +1 -1
-# @setup-time: #optional amount of setup time in milliseconds _before_ the
+# @setup-time: amount of setup time in milliseconds _before_ the
 #        iterations begin but _after_ the QMP command is issued. This is designed
 #        to provide an accounting of any activities (such as RDMA pinning) which
 #        may be expensive, but do not actually occur during the iterative
 #        migration rounds themselves. (since 1.6)

Here's another place where wrapping now looks odd (short, followed by multiple longer lines). Again, the effort of rewrapping lines is not worth the churn (and it's actually easier to read diffs that _don't_ reflow text). So I'll just overlook wrapping oddities in the rest of the patch, as inconsequential to the end result.

A sufficiently clever Emacs macro could give us more pleasantly wrapped lines, at the cost of a messier diff. I'll experiment if time permits.

Quoted 1 line

Thanks!

#51 lore raw

Re: [Qemu-devel] [PATCH for-2.9 17/47] qapi: The #optional tag is redundant, drop

In reply to Markus Armbruster
Quoted 17 lines · Markus Armbruster

We traditionally mark optional members #optional in the doc comment. Before commit 3313b61, this was entirely manual.

Commit 3313b61 added some automation because its qapi2texi.py relied on #optional to determine whether a member is optional. This is no longer the case since the previous commit: the only thing qapi2texi.py still does with #optional is stripping it out. We still reject bogus qapi-schema.json and six places for qga/qapi-schema.json.

Thus, you can't actually rely on #optional to see whether something is optional. Yet we still make people add it manually. That's just busy-work.

Drop the code to check, fix up and strip out #optional, along with all instances of #optional. To keep it out, add code to reject it, to be dropped again once the dust settles.

Quoted 8 lines

No change to generated documentation.

---
 docs/qapi-code-gen.txt              |  16 +-
 docs/writing-qmp-commands.txt       |   4 +-
 qapi-schema.json                    | 378 ++++++++++++++++----------------
 qapi/block-core.json                | 418 ++++++++++++++++++------------------

You'll have to rebase this on master, due to ...

qapi/block-core.json line 2356

Quoted 10 lines
qapi/block-core.json +1 -1
@@ -2349,17 +2349,17 @@
 #
 # @volume:              Name of the Archipelago volume image
 #
-# @mport:               #optional The port number on which mapperd is
+# @mport:               The port number on which mapperd is
 #                       listening. This is optional
 #                       and if not specified, QEMU will make Archipelago
 #                       use the default port (1001).
 #

...commit e32ccbc killing broken archipelago

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#52 lore raw

Re: [Qemu-devel] [PATCH for-2.9 17/47] qapi: The #optional tag is redundant, drop

Quoted 30 lines · Eric Blake
Quoted 17 lines · Markus Armbruster

We traditionally mark optional members #optional in the doc comment. Before commit 3313b61, this was entirely manual.

Commit 3313b61 added some automation because its qapi2texi.py relied on #optional to determine whether a member is optional. This is no longer the case since the previous commit: the only thing qapi2texi.py still does with #optional is stripping it out. We still reject bogus qapi-schema.json and six places for qga/qapi-schema.json.

Thus, you can't actually rely on #optional to see whether something is optional. Yet we still make people add it manually. That's just busy-work.

Drop the code to check, fix up and strip out #optional, along with all instances of #optional. To keep it out, add code to reject it, to be dropped again once the dust settles.

Quoted 8 lines

No change to generated documentation.

---
 docs/qapi-code-gen.txt              |  16 +-
 docs/writing-qmp-commands.txt       |   4 +-
 qapi-schema.json                    | 378 ++++++++++++++++----------------
 qapi/block-core.json                | 418 ++++++++++++++++++------------------

You'll have to rebase this on master, due to ...

Quoted 12 lines

qapi/block-core.json line 2356

Quoted 10 lines
qapi/block-core.json +1 -1
@@ -2349,17 +2349,17 @@
 #
 # @volume:              Name of the Archipelago volume image
 #
-# @mport:               #optional The port number on which mapperd is
+# @mport:               The port number on which mapperd is
 #                       listening. This is optional
 #                       and if not specified, QEMU will make Archipelago
 #                       use the default port (1001).
 #

...commit e32ccbc killing broken archipelago

Yes. Thanks for the heads-up.

#53 lore raw

PATCH 18/47 qapi: Use raw strings for regular expressions consistently

In reply to Markus Armbruster
---
 scripts/qapi.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
scripts/qapi.py +4 -4
index c580e76..6d39ec9 100644
@@ -550,7 +550,7 @@ def discriminator_find_enum_define(expr):
 # Names must be letters, numbers, -, and _.  They must start with letter,
 # except for downstream extensions which must start with __RFQDN_.
 # Dots are only valid in the downstream extension prefix.
-valid_name = re.compile('^(__[a-zA-Z0-9.-]+_)?'
+valid_name = re.compile(r'^(__[a-zA-Z0-9.-]+_)?'
                         '[a-zA-Z][a-zA-Z0-9_-]*$')
 
 
@@ -1827,10 +1827,10 @@ def cgen(code, **kwds):
     if indent_level:
         indent = genindent(indent_level)
         # re.subn() lacks flags support before Python 2.7, use re.compile()
-        raw = re.subn(re.compile("^.", re.MULTILINE),
+        raw = re.subn(re.compile(r'^.', re.MULTILINE),
                       indent + r'\g<0>', raw)
         raw = raw[0]
-    return re.sub(re.escape(eatspace) + ' *', '', raw)
+    return re.sub(re.escape(eatspace) + r' *', '', raw)
 
 
 def mcgen(code, **kwds):
@@ -1964,7 +1964,7 @@ def parse_command_line(extra_options="", extra_long_options=[]):
     for oa in opts:
         o, a = oa
         if o in ("-p", "--prefix"):
-            match = re.match('([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
+            match = re.match(r'([A-Za-z_.-][A-Za-z0-9_.-]*)?', a)
             if match.end() != len(a):
                 print >>sys.stderr, \
                     "%s: 'funny character '%s' in argument of --prefix" \
Signature · 1 line
2.7.4
Reviewed-by on v1 18/47
#54 lore raw

Re: [Qemu-devel] [PATCH for-2.9 18/47] qapi: Use raw strings for regular expressions consistently

Quoted 5 lines · Markus Armbruster
---
 scripts/qapi.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#55 lore raw

PATCH 19/47 qapi: Prefer single-quoted strings more consistently

In reply to Markus Armbruster

PEP 8 advises:

In Python, single-quoted strings and double-quoted strings are the same. This PEP does not make a recommendation for this. Pick a rule and stick to it. When a string contains single or double quote characters, however, use the other one to avoid backslashes in the string. It improves readability.

The QAPI generators succeed at picking a rule, but fail at sticking to it. Convert a bunch of double-quoted strings to single-quoted ones.

---
 scripts/qapi-event.py      |  2 +-
 scripts/qapi-introspect.py |  4 +-
 scripts/qapi-types.py      |  4 +-
 scripts/qapi-visit.py      |  4 +-
 scripts/qapi.py            | 96 +++++++++++++++++++++++-----------------------
 scripts/qapi2texi.py       | 46 +++++++++++-----------
 6 files changed, 78 insertions(+), 78 deletions(-)
scripts/qapi-event.py +1 -1
index f4eb7f8..0485e39 100644
@@ -223,7 +223,7 @@ fdecl.write(mcgen('''
 ''',
                   prefix=prefix))
 
-event_enum_name = c_name(prefix + "QAPIEvent", protect=False)
+event_enum_name = c_name(prefix + 'QAPIEvent', protect=False)
 
 schema = QAPISchema(input_file)
 gen = QAPISchemaGenEventVisitor()
scripts/qapi-introspect.py +2 -2
index fb72c61..032bcea 100644
@@ -170,10 +170,10 @@ const char %(c_name)s[] = %(c_string)s;
 opt_unmask = False
 
 (input_file, output_dir, do_c, do_h, prefix, opts) = \
-    parse_command_line("u", ["unmask-non-abi-names"])
+    parse_command_line('u', ['unmask-non-abi-names'])
 
 for o, a in opts:
-    if o in ("-u", "--unmask-non-abi-names"):
+    if o in ('-u', '--unmask-non-abi-names'):
         opt_unmask = True
 
 c_comment = '''
scripts/qapi-types.py +2 -2
index dabc42e..b45e7b5 100644
@@ -244,10 +244,10 @@ class QAPISchemaGenTypeVisitor(QAPISchemaVisitor):
 do_builtins = False
 
 (input_file, output_dir, do_c, do_h, prefix, opts) = \
-    parse_command_line("b", ["builtins"])
+    parse_command_line('b', ['builtins'])
 
 for o, a in opts:
-    if o in ("-b", "--builtins"):
+    if o in ('-b', '--builtins'):
         do_builtins = True
 
 c_comment = '''
scripts/qapi-visit.py +2 -2
index 330b9f3..3d3936e 100644
@@ -335,10 +335,10 @@ class QAPISchemaGenVisitVisitor(QAPISchemaVisitor):
 do_builtins = False
 
 (input_file, output_dir, do_c, do_h, prefix, opts) = \
-    parse_command_line("b", ["builtins"])
+    parse_command_line('b', ['builtins'])
 
 for o, a in opts:
-    if o in ("-b", "--builtins"):
+    if o in ('-b', '--builtins'):
         do_builtins = True
 
 c_comment = '''
scripts/qapi.py +48 -48

267 lines not on this page · raw message

scripts/qapi2texi.py +23 -23

92 lines not on this page · raw message

Signature · 1 line
2.7.4
Reviewed-by on v1 19/47
#56 lore raw

Re: [Qemu-devel] [PATCH for-2.9 19/47] qapi: Prefer single-quoted strings more consistently

Quoted 12 lines · Markus Armbruster

PEP 8 advises:

In Python, single-quoted strings and double-quoted strings are the same. This PEP does not make a recommendation for this. Pick a rule and stick to it. When a string contains single or double quote characters, however, use the other one to avoid backslashes in the string. It improves readability.

The QAPI generators succeed at picking a rule, but fail at sticking to it. Convert a bunch of double-quoted strings to single-quoted ones.

Quoted 9 lines
---
 scripts/qapi-event.py      |  2 +-
 scripts/qapi-introspect.py |  4 +-
 scripts/qapi-types.py      |  4 +-
 scripts/qapi-visit.py      |  4 +-
 scripts/qapi.py            | 96 +++++++++++++++++++++++-----------------------
 scripts/qapi2texi.py       | 46 +++++++++++-----------
 6 files changed, 78 insertions(+), 78 deletions(-)

Purely stylistic, so I wouldn't do it as a lone patch. But as part of a larger series, I think you're fine.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#57 lore raw

PATCH 20/47 qapi2texi: Plainer enum value and member name formatting

In reply to Markus Armbruster

Use @code{%s} instead of @code{'%s'}. Impact, using @id as example:

* Texinfo
-@item @code{'id'}
+@item @code{id}

* HTML
-<dt><code>'id'</code></dt>
+<dt><code>id</code></dt>

* POD (for manual pages):
-=item C<'id'>
+=item C<id>

* Formatted manual pages:
-'id'
+"id"

* Plain text:
- ''id''
+ 'id'

---
 scripts/qapi2texi.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/qapi2texi.py +2 -2
index 91cd593..ecfaeda 100755
@@ -130,12 +130,12 @@ def texi_body(doc):
 
 def texi_enum_value(value):
     """Format a table of members item for an enumeration value"""
-    return "@item @code{'%s'}\n" % value.name
+    return '@item @code{%s}\n' % value.name
 
 
 def texi_member(member):
     """Format a table of members item for an object type member"""
-    return "@item @code{'%s'}%s\n" % (
+    return '@item @code{%s}%s\n' % (
         member.name, ' (optional)' if member.optional else '')
 
 
Signature · 1 line
2.7.4
Reviewed-by on v1 20/47
#58 lore raw

Re: [Qemu-devel] [PATCH for-2.9 20/47] qapi2texi: Plainer enum value and member name formatting

Quoted 18 lines · Markus Armbruster

Use @code{%s} instead of @code{'%s'}. Impact, using @id as example:

* Texinfo
-@item @code{'id'}
+@item @code{id}

* HTML
-<dt><code>'id'</code></dt>
+<dt><code>id</code></dt>

* POD (for manual pages):
-=item C<'id'>
+=item C<id>

* Formatted manual pages:
-'id'
+"id"

Quoted 8 lines

* Plain text:
- ''id''
+ 'id'

---
 scripts/qapi2texi.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#59 lore raw

PATCH 21/47 qapi2texi: Present the table of members more clearly

In reply to Markus Armbruster

The table of members follows the main descriptive text immediately. Makes it hard to see what it is about. Start a new paragraph, and lead with a line "Members:" for object and alternate types, "Values:" for enumeration types, and "Arguments:" for commands and events.

Example change (qemu-qmp-ref.txt):

-- Command: set_link

Sets the link status of a virtual network adapter.
+
+ Arguments:
'name'
the device name of the virtual network adapter
'up'
true to set the link status to be up

Returns: Nothing on success If 'name' is not a valid network device, DeviceNotFound

---
 scripts/qapi2texi.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
scripts/qapi2texi.py +10 -9
index ecfaeda..35e182d 100755
@@ -139,7 +139,7 @@ def texi_member(member):
         member.name, ' (optional)' if member.optional else '')
 
 
-def texi_members(doc, member_func, show_undocumented):
+def texi_members(doc, what, member_func, show_undocumented):
     """Format the table of members"""
     items = ''
     for section in doc.args.itervalues():
@@ -149,7 +149,7 @@ def texi_members(doc, member_func, show_undocumented):
         items += member_func(section.member) + texi_format(desc) + '\n'
     if not items:
         return ''
-    return '@table @asis\n' + items + '@end table\n'
+    return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items)
 
 
 def texi_sections(doc):
@@ -169,9 +169,10 @@ def texi_sections(doc):
     return body
 
 
-def texi_entity(doc, member_func=texi_member, show_undocumented=False):
+def texi_entity(doc, what, member_func=texi_member,
+                show_undocumented=False):
     return (texi_body(doc)
-            + texi_members(doc, member_func, show_undocumented)
+            + texi_members(doc, what, member_func, show_undocumented)
             + texi_sections(doc))
 
 
@@ -189,7 +190,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             self.out += '\n'
         self.out += TYPE_FMT(type='Enum',
                              name=doc.symbol,
-                             body=texi_entity(doc,
+                             body=texi_entity(doc, 'Values',
                                               member_func=texi_enum_value,
                                               show_undocumented=True))
 
@@ -205,7 +206,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             self.out += '\n'
         self.out += TYPE_FMT(type=typ,
                              name=doc.symbol,
-                             body=texi_entity(doc))
+                             body=texi_entity(doc, 'Members'))
 
     def visit_alternate_type(self, name, info, variants):
         doc = self.cur_doc
@@ -213,7 +214,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             self.out += '\n'
         self.out += TYPE_FMT(type='Alternate',
                              name=doc.symbol,
-                             body=texi_entity(doc))
+                             body=texi_entity(doc, 'Members'))
 
     def visit_command(self, name, info, arg_type, ret_type,
                       gen, success_response, boxed):
@@ -222,7 +223,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             self.out += '\n'
         self.out += MSG_FMT(type='Command',
                             name=doc.symbol,
-                            body=texi_entity(doc))
+                            body=texi_entity(doc, 'Arguments'))
 
     def visit_event(self, name, info, arg_type, boxed):
         doc = self.cur_doc
@@ -230,7 +231,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             self.out += '\n'
         self.out += MSG_FMT(type='Event',
                             name=doc.symbol,
-                            body=texi_entity(doc))
+                            body=texi_entity(doc, 'Arguments'))
 
     def symbol(self, doc, entity):
         self.cur_doc = doc
Signature · 1 line
2.7.4
Reviewed-by on v1 21/47
#60 lore raw

Re: [Qemu-devel] [PATCH for-2.9 21/47] qapi2texi: Present the table of members more clearly

Quoted 20 lines · Markus Armbruster

The table of members follows the main descriptive text immediately. Makes it hard to see what it is about. Start a new paragraph, and lead with a line "Members:" for object and alternate types, "Values:" for enumeration types, and "Arguments:" for commands and events.

Example change (qemu-qmp-ref.txt):

-- Command: set_link

Sets the link status of a virtual network adapter.

(quoted diff) +2 -0
+
+     Arguments:
      'name'
           the device name of the virtual network adapter
      'up'
           true to set the link status to be up
 
      Returns: Nothing on success If 'name' is not a valid network
      device, DeviceNotFound
Quoted 5 lines
---
 scripts/qapi2texi.py | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#61 lore raw

PATCH 22/47 qapi2texi: Explain enum value undocumentedness more clearly

In reply to Markus Armbruster

Instead of not saying anything when we have no documentation, say "Not documented".

Example change (qemu-qmp-ref.txt):

-- Enum: GuestPanicAction

An enumeration of the actions taken when guest OS panic is detected

Values:
'pause'
system pauses
'poweroff'
+ Not documented

      Since: 2.1 (poweroff since 2.8)
---
 scripts/qapi2texi.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
scripts/qapi2texi.py +4 -1
index 35e182d..1f01817 100755
@@ -145,7 +145,10 @@ def texi_members(doc, what, member_func, show_undocumented):
     for section in doc.args.itervalues():
         if not section.content and not show_undocumented:
             continue          # Undocumented TODO require doc and drop
-        desc = str(section)
+        if section.content:
+            desc = str(section)
+        else:
+            desc = 'Not documented'
         items += member_func(section.member) + texi_format(desc) + '\n'
     if not items:
         return ''
Signature · 1 line
2.7.4
Reviewed-by on v1 22/47
#62 lore raw

Re: [Qemu-devel] [PATCH for-2.9 22/47] qapi2texi: Explain enum value undocumentedness more clearly

Quoted 15 lines · Markus Armbruster

Instead of not saying anything when we have no documentation, say "Not documented".

Example change (qemu-qmp-ref.txt):

-- Enum: GuestPanicAction

An enumeration of the actions taken when guest OS panic is detected

Values:
'pause'
system pauses
'poweroff'
+ Not documented

Quoted 6 lines
      Since: 2.1 (poweroff since 2.8)
---
 scripts/qapi2texi.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#63 lore raw

PATCH 23/47 qapi2texi: Don't hide undocumented members and arguments

In reply to Markus Armbruster

Show undocumented object, alternate type members and command, event arguments exactly like undocumented enumeration type values.

Example change (qemu-qmp-ref.txt):

-- Command: query-rocker

Return rocker switch information.

+ Arguments:
+ 'name'
+ Not documented
+
Returns: 'Rocker' information

---
 scripts/qapi2texi.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
scripts/qapi2texi.py +4 -8
index 1f01817..df87441 100755
@@ -139,12 +139,10 @@ def texi_member(member):
         member.name, ' (optional)' if member.optional else '')
 
 
-def texi_members(doc, what, member_func, show_undocumented):
+def texi_members(doc, what, member_func):
     """Format the table of members"""
     items = ''
     for section in doc.args.itervalues():
-        if not section.content and not show_undocumented:
-            continue          # Undocumented TODO require doc and drop
         if section.content:
             desc = str(section)
         else:
@@ -172,10 +170,9 @@ def texi_sections(doc):
     return body
 
 
-def texi_entity(doc, what, member_func=texi_member,
-                show_undocumented=False):
+def texi_entity(doc, what, member_func=texi_member):
     return (texi_body(doc)
-            + texi_members(doc, what, member_func, show_undocumented)
+            + texi_members(doc, what, member_func)
             + texi_sections(doc))
 
 
@@ -194,8 +191,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
         self.out += TYPE_FMT(type='Enum',
                              name=doc.symbol,
                              body=texi_entity(doc, 'Values',
-                                              member_func=texi_enum_value,
-                                              show_undocumented=True))
+                                              member_func=texi_enum_value))
 
     def visit_object_type(self, name, info, base, members, variants):
         doc = self.cur_doc
Signature · 1 line
2.7.4
Reviewed-by on v1 23/47
#64 lore raw

Re: [Qemu-devel] [PATCH for-2.9 23/47] qapi2texi: Don't hide undocumented members and arguments

Quoted 15 lines · Markus Armbruster

Show undocumented object, alternate type members and command, event arguments exactly like undocumented enumeration type values.

Example change (qemu-qmp-ref.txt):

-- Command: query-rocker

Return rocker switch information.

(quoted diff) +4 -0
+     Arguments:
+     'name'
+          Not documented
+
      Returns: 'Rocker' information
Quoted 5 lines
---
 scripts/qapi2texi.py | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#65 lore raw

PATCH 24/47 qapi2texi: Implement boxed argument documentation

In reply to Markus Armbruster

This replaces manual references like "For the arguments, see the documentation of ..." by a generated reference "Arguments: the members of ...".

---
 qapi-schema.json     |  2 +-
 qapi/block-core.json | 10 ----------
 scripts/qapi2texi.py |  8 +++++++-
 3 files changed, 8 insertions(+), 12 deletions(-)
qapi-schema.json +1 -1
index d693033..1d7b1cd 100644
@@ -1017,7 +1017,7 @@
 ##
 # @migrate-set-parameters:
 #
-# Set various migration parameters.  See MigrationParameters for details.
+# Set various migration parameters.
 #
 # Since: 2.4
 #
qapi/block-core.json +0 -10
index 539649c..83601db 100644
@@ -1340,8 +1340,6 @@
 # The operation can be stopped before it has completed using the
 # block-job-cancel command.
 #
-# For the arguments, see the documentation of DriveBackup.
-#
 # Returns: nothing on success
 #          If @device is not a valid block device, GenericError
 #
@@ -1368,8 +1366,6 @@
 # The operation can be stopped before it has completed using the
 # block-job-cancel command.
 #
-# For the arguments, see the documentation of BlockdevBackup.
-#
 # Returns: nothing on success
 #          If @device is not a valid block device, DeviceNotFound
 #
@@ -1457,8 +1453,6 @@
 # format of the mirror image, default is to probe if mode='existing',
 # else the format of the source.
 #
-# See DriveMirror for parameter descriptions
-#
 # Returns: nothing on success
 #          If @device is not a valid block device, GenericError
 #
@@ -1730,8 +1724,6 @@
 # the device will be removed from its group and the rest of its
 # members will not be affected. The 'group' parameter is ignored.
 #
-# See BlockIOThrottle for parameter descriptions.
-#
 # Returns: Nothing on success
 #          If @device is not a valid block device, DeviceNotFound
 #
@@ -2944,8 +2936,6 @@
 # BlockBackend will be created; otherwise, @node-name is mandatory at the top
 # level and no BlockBackend will be created.
 #
-# For the arguments, see the documentation of BlockdevOptions.
-#
 # Note: This command is still a work in progress.  It doesn't support all
 # block drivers among other things.  Stay away from it unless you want
 # to help with its development.
scripts/qapi2texi.py +7 -1
index df87441..3dd0146 100755
@@ -220,9 +220,15 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
         doc = self.cur_doc
         if self.out:
             self.out += '\n'
+        if boxed:
+            body = texi_body(doc)
+            body += '\n@b{Arguments:} the members of @code{%s}' % arg_type.name
+            body += texi_sections(doc)
+        else:
+            body = texi_entity(doc, 'Arguments')
         self.out += MSG_FMT(type='Command',
                             name=doc.symbol,
-                            body=texi_entity(doc, 'Arguments'))
+                            body=body)
 
     def visit_event(self, name, info, arg_type, boxed):
         doc = self.cur_doc
Signature · 1 line
2.7.4
Reviewed-by on v1 24/47
#66 lore raw

Re: [Qemu-devel] [PATCH for-2.9 24/47] qapi2texi: Implement boxed argument documentation

Quoted 10 lines · Markus Armbruster

This replaces manual references like "For the arguments, see the documentation of ..." by a generated reference "Arguments: the members of ...".

---
 qapi-schema.json     |  2 +-
 qapi/block-core.json | 10 ----------
 scripts/qapi2texi.py |  8 +++++++-
 3 files changed, 8 insertions(+), 12 deletions(-)

Should be even more handy when you add html links to the type documentation from the command documentation, later in the series.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#67 lore raw

Re: [Qemu-devel] [PATCH for-2.9 24/47] qapi2texi: Implement boxed argument documentation

Quoted 12 lines · Eric Blake
Quoted 10 lines · Markus Armbruster

This replaces manual references like "For the arguments, see the documentation of ..." by a generated reference "Arguments: the members of ...".

---
 qapi-schema.json     |  2 +-
 qapi/block-core.json | 10 ----------
 scripts/qapi2texi.py |  8 +++++++-
 3 files changed, 8 insertions(+), 12 deletions(-)
Quoted 2 lines

Should be even more handy when you add html links to the type documentation from the command documentation, later in the series.

Yes, but actual links are left to a later series.

Quoted 1 line

Thanks!

#68 lore raw

PATCH 25/47 qapi2texi: Include member type in generated documentation

In reply to Markus Armbruster

The recent merge of docs/qmp-commands.txt and docs/qmp-events.txt into the schema lost type information. Fix this documentation regression.

Example change (qemu-qmp-ref.txt):

-- Struct: InputKeyEvent

Keyboard input event.

Members:
- 'button'
+ 'button: InputButton'
Which button this event is for.
- 'down'
+ 'down: boolean'
True for key-down and false for key-up events.

Since: 2.0

---
 scripts/qapi.py      | 14 ++++++++++++++
 scripts/qapi2texi.py |  8 ++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
scripts/qapi.py +14 -0
index 9430493..b82a2a6 100644
@@ -1101,6 +1101,11 @@ class QAPISchemaType(QAPISchemaEntity):
         }
         return json2qtype.get(self.json_type())
 
+    def doc_type(self):
+        if self.is_implicit():
+            return None
+        return self.name
+
 
 class QAPISchemaBuiltinType(QAPISchemaType):
     def __init__(self, name, json_type, c_type):
@@ -1125,6 +1130,9 @@ class QAPISchemaBuiltinType(QAPISchemaType):
     def json_type(self):
         return self._json_type_name
 
+    def doc_type(self):
+        return self.json_type()
+
     def visit(self, visitor):
         visitor.visit_builtin_type(self.name, self.info, self.json_type())
 
@@ -1184,6 +1192,12 @@ class QAPISchemaArrayType(QAPISchemaType):
     def json_type(self):
         return 'array'
 
+    def doc_type(self):
+        elt_doc_type = self.element_type.doc_type()
+        if not elt_doc_type:
+            return None
+        return 'array of ' + elt_doc_type
+
     def visit(self, visitor):
         visitor.visit_array_type(self.name, self.info, self.element_type)
 
scripts/qapi2texi.py +6 -2
index 3dd0146..993b652 100755
@@ -135,8 +135,12 @@ def texi_enum_value(value):
 
 def texi_member(member):
     """Format a table of members item for an object type member"""
-    return '@item @code{%s}%s\n' % (
-        member.name, ' (optional)' if member.optional else '')
+    typ = member.type.doc_type()
+    return '@item @code{%s%s%s}%s\n' % (
+        member.name,
+        ': ' if typ else '',
+        typ if typ else '',
+        ' (optional)' if member.optional else '')
 
 
 def texi_members(doc, what, member_func):
Signature · 1 line
2.7.4
Reviewed-by on v1 25/47
#69 lore raw

Re: [Qemu-devel] [PATCH for-2.9 25/47] qapi2texi: Include member type in generated documentation

Hi

Quoted 53 lines · Markus Armbruster

The recent merge of docs/qmp-commands.txt and docs/qmp-events.txt into the schema lost type information. Fix this documentation regression.

Example change (qemu-qmp-ref.txt):

-- Struct: InputKeyEvent

Keyboard input event.

Members:

(quoted diff) +2 -2
-     'button'
+     'button: InputButton'
           Which button this event is for.
-     'down'
+     'down: boolean'
           True for key-down and false for key-up events.
 
      Since: 2.0
---
 scripts/qapi.py      | 14 ++++++++++++++
 scripts/qapi2texi.py |  8 ++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
scripts/qapi.py +8 -0
index 9430493..b82a2a6 100644
@@ -1101,6 +1101,11 @@ class QAPISchemaType(QAPISchemaEntity):
         }
         return json2qtype.get(self.json_type())
 
+    def doc_type(self):
+        if self.is_implicit():
+            return None
+        return self.name
+
 
 class QAPISchemaBuiltinType(QAPISchemaType):
     def __init__(self, name, json_type, c_type):
@@ -1125,6 +1130,9 @@ class QAPISchemaBuiltinType(QAPISchemaType):
     def json_type(self):
         return self._json_type_name
 
+    def doc_type(self):
+        return self.json_type()
+
     def visit(self, visitor):
         visitor.visit_builtin_type(self.name, self.info,
 self.json_type())

scripts/qapi.py class QAPISchemaArrayType(QAPISchemaType): · line 1199

Quoted 8 lines
scripts/qapi.py +4 -0
@@ -1184,6 +1192,12 @@ class QAPISchemaArrayType(QAPISchemaType):
     def json_type(self):
         return 'array'
 
+    def doc_type(self):
+        elt_doc_type = self.element_type.doc_type()
+        if not elt_doc_type:
+            return None
 

In which case is this expected to happen? place an assert here instead?

Quoted 28 lines
scripts/qapi.py +2 -0
+        return 'array of ' + elt_doc_type
+
     def visit(self, visitor):
         visitor.visit_array_type(self.name, self.info, self.element_type)
scripts/qapi2texi.py +6 -3
index 3dd0146..993b652 100755
@@ -135,8 +135,12 @@ def texi_enum_value(value):
 
 def texi_member(member):
     """Format a table of members item for an object type member"""
-    return '@item @code{%s}%s\n' % (
-        member.name, ' (optional)' if member.optional else '')
+    typ = member.type.doc_type()
+    return '@item @code{%s%s%s}%s\n' % (
+        member.name,
+        ': ' if typ else '',
+        typ if typ else '',
+        ' (optional)' if member.optional else '')
 
 
 def texi_members(doc, what, member_func):
--

2.7.4

Quoted 1 line

--

Marc-André Lureau

#70 lore raw

Re: [Qemu-devel] [PATCH for-2.9 25/47] qapi2texi: Include member type in generated documentation

Quoted 61 lines · Marc-André Lureau

Hi

Quoted 56 lines · Markus Armbruster

The recent merge of docs/qmp-commands.txt and docs/qmp-events.txt into the schema lost type information. Fix this documentation regression.

Example change (qemu-qmp-ref.txt):

-- Struct: InputKeyEvent

Keyboard input event.

Members:

(quoted diff) +2 -2
-     'button'
+     'button: InputButton'
           Which button this event is for.
-     'down'
+     'down: boolean'
           True for key-down and false for key-up events.
 
      Since: 2.0
---
 scripts/qapi.py      | 14 ++++++++++++++
 scripts/qapi2texi.py |  8 ++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
scripts/qapi.py +8 -0
index 9430493..b82a2a6 100644
@@ -1101,6 +1101,11 @@ class QAPISchemaType(QAPISchemaEntity):
         }
         return json2qtype.get(self.json_type())
 
+    def doc_type(self):
+        if self.is_implicit():
+            return None
+        return self.name
+
 
 class QAPISchemaBuiltinType(QAPISchemaType):
     def __init__(self, name, json_type, c_type):
@@ -1125,6 +1130,9 @@ class QAPISchemaBuiltinType(QAPISchemaType):
     def json_type(self):
         return self._json_type_name
 
+    def doc_type(self):
+        return self.json_type()
+
     def visit(self, visitor):
         visitor.visit_builtin_type(self.name, self.info,
 self.json_type())
@@ -1184,6 +1192,12 @@ class QAPISchemaArrayType(QAPISchemaType):
     def json_type(self):
         return 'array'
 
Quoted 7 lines

scripts/qapi.py class QAPISchemaArrayType(QAPISchemaType): · line 1203

Quoted 5 lines
scripts/qapi.py +4 -0
+    def doc_type(self):
+        elt_doc_type = self.element_type.doc_type()
+        if not elt_doc_type:
+            return None
 

In which case is this expected to happen? place an assert here instead?

I think assert should work now, the argument is a bit longwinded, and it won't let us simplify code.

First the argument.

T.doc_type() returns None for a non-array type T when T.is_implicit() and T isn't a built-in type, because:

* QAPISchemaType.doc_type() returns None when self.is_implicit(), but

* QAPISchemaBuiltinType().doc_type() overrides, and never returns None.

T.is_implicit() is true for the following non-array, non-builtin T:

* the implicitly defined enumeration type of a simple union's tag

* the implicitly defined variant type of a simple union

* an implicitly defined base type of a union

* an implicitly defined argument type of a command or event

We can't actually make arrays of these.

Now let's see whether we can use it to simplify code.

There are four calls of .doc_type() besides the one shown above:

* texi_member() calls it for types of

- the (common) members of object types (including command and event arguments) and members of alternate types. None happens for the implicitly defined tag member of simple unions. The easiest way to cope with it is to cope with None for any member.

- the members of variant members of simple unions. It doesn't bother to handle None, because a member type can only be a built-in or explictly defined type, or an array thereof.

* texi_members() calls it and checks for None to help identify undocumented members where we can do better than say "Not documented".

* texi_members() calls it for the base type, except when it's implicitly defined. It doesn't bother to handle None, because it can only be an explictly defined struct type.

* texi_members() calls it for the types of variant members of flat unions. It doesn't bother to handle None, because a member type can only be a built-in or explictly defined type.

Adding the assertion makes no case of None go away.

Quoted 1 line

Thanks!

Reviewed-by on v1 25/47
#71 lore raw

Re: [Qemu-devel] [PATCH for-2.9 25/47] qapi2texi: Include member type in generated documentation

In reply to Markus Armbruster
Quoted 10 lines · Markus Armbruster

The recent merge of docs/qmp-commands.txt and docs/qmp-events.txt into the schema lost type information. Fix this documentation regression.

Example change (qemu-qmp-ref.txt):

-- Struct: InputKeyEvent

Keyboard input event.

Members:

Review

Quoted 8 lines
(quoted diff) +2 -2
-     'button'
+     'button: InputButton'
           Which button this event is for.
-     'down'
+     'down: boolean'
           True for key-down and false for key-up events.
 
      Since: 2.0

Definitely worth having.

Quoted 7 lines
---
 scripts/qapi.py      | 14 ++++++++++++++
 scripts/qapi2texi.py |  8 ++++++--
 2 files changed, 20 insertions(+), 2 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#72 lore raw

PATCH 26/47 qapi2texi: Generate reference to base type members

In reply to Markus Armbruster

The generated documentation doesn't mention object type members inherited from a base type. Fix that.

Example change (qemu-qmp-ref.txt):

-- Struct: VncServerInfo

The network connection information for server

Members:
'auth' (optional)
authentication method used for the plain (non-websocket) VNC server
+ The members of 'VncBasicInfo'

      Since: 2.1
---
 scripts/qapi2texi.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
scripts/qapi2texi.py +8 -4
index 993b652..7083d0c 100755
@@ -143,7 +143,7 @@ def texi_member(member):
         ' (optional)' if member.optional else '')
 
 
-def texi_members(doc, what, member_func):
+def texi_members(doc, what, base, member_func):
     """Format the table of members"""
     items = ''
     for section in doc.args.itervalues():
@@ -152,6 +152,8 @@ def texi_members(doc, what, member_func):
         else:
             desc = 'Not documented'
         items += member_func(section.member) + texi_format(desc) + '\n'
+    if base:
+        items += '@item The members of @code{%s}\n' % base.doc_type()
     if not items:
         return ''
     return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items)
@@ -174,9 +176,9 @@ def texi_sections(doc):
     return body
 
 
-def texi_entity(doc, what, member_func=texi_member):
+def texi_entity(doc, what, base=None, member_func=texi_member):
     return (texi_body(doc)
-            + texi_members(doc, what, member_func)
+            + texi_members(doc, what, base, member_func)
             + texi_sections(doc))
 
 
@@ -205,11 +207,13 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             typ = 'Flat Union'
         else:
             typ = 'Simple Union'
+        if base and base.is_implicit():
+            base = None
         if self.out:
             self.out += '\n'
         self.out += TYPE_FMT(type=typ,
                              name=doc.symbol,
-                             body=texi_entity(doc, 'Members'))
+                             body=texi_entity(doc, 'Members', base))
 
     def visit_alternate_type(self, name, info, variants):
         doc = self.cur_doc
Signature · 1 line
2.7.4
Reviewed-by Reviewed-by on v1 26/47
#73 lore raw

Re: [Qemu-devel] [PATCH for-2.9 26/47] qapi2texi: Generate reference to base type members

Quoted 7 lines · Markus Armbruster

The generated documentation doesn't mention object type members inherited from a base type. Fix that.

Example change (qemu-qmp-ref.txt):

-- Struct: VncServerInfo

Quoted 8 lines

The network connection information for server

Members:
'auth' (optional)
authentication method used for the plain (non-websocket) VNC server
+ The members of 'VncBasicInfo'

Again, will be more useful later in the series when you add hyperlinking.

Quoted 7 lines
      Since: 2.1
---
 scripts/qapi2texi.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 14 lines
scripts/qapi2texi.py +1 -1
index 993b652..7083d0c 100755
@@ -143,7 +143,7 @@ def texi_member(member):
         ' (optional)' if member.optional else '')
 
 
-def texi_members(doc, what, member_func):
+def texi_members(doc, what, base, member_func):
     """Format the table of members"""
     items = ''
     for section in doc.args.itervalues():

scripts/qapi2texi.py def texi_members(doc, what, member_func): · line 156

Quoted 5 lines
scripts/qapi2texi.py +2 -0
@@ -152,6 +152,8 @@ def texi_members(doc, what, member_func):
         else:
             desc = 'Not documented'
         items += member_func(section.member) + texi_format(desc) + '\n'
+    if base:
+        items += '@item The members of @code{%s}\n' % base.doc_type()

Will this still work for implicit bases?

scripts/qapi2texi.py class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): · line 211

Quoted 7 lines
scripts/qapi2texi.py +2 -0
@@ -205,11 +207,13 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             typ = 'Flat Union'
         else:
             typ = 'Simple Union'
+        if base and base.is_implicit():
+            base = None

Hmm - you just ignore those, such as the anonymous base in CpuInfo. On the other hand, CpuInfo documents its base fields explicitly. Are we at risk of double-documenting a base member, both explicitly and via its named base type?

At any rate, this patch is an incremental improvement, so:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#74 lore raw

Re: [Qemu-devel] [PATCH for-2.9 26/47] qapi2texi: Generate reference to base type members

Quoted 52 lines · Eric Blake
Quoted 7 lines · Markus Armbruster

The generated documentation doesn't mention object type members inherited from a base type. Fix that.

Example change (qemu-qmp-ref.txt):

-- Struct: VncServerInfo

Quoted 8 lines

The network connection information for server

Members:
'auth' (optional)
authentication method used for the plain (non-websocket) VNC server
+ The members of 'VncBasicInfo'

Again, will be more useful later in the series when you add hyperlinking.

Quoted 7 lines
      Since: 2.1
---
 scripts/qapi2texi.py | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 14 lines
scripts/qapi2texi.py +1 -1
index 993b652..7083d0c 100755
@@ -143,7 +143,7 @@ def texi_member(member):
         ' (optional)' if member.optional else '')
 
 
-def texi_members(doc, what, member_func):
+def texi_members(doc, what, base, member_func):
     """Format the table of members"""
     items = ''
     for section in doc.args.itervalues():

scripts/qapi2texi.py def texi_members(doc, what, member_func): · line 156

Quoted 5 lines
scripts/qapi2texi.py +2 -0
@@ -152,6 +152,8 @@ def texi_members(doc, what, member_func):
         else:
             desc = 'Not documented'
         items += member_func(section.member) + texi_format(desc) + '\n'
+    if base:
+        items += '@item The members of @code{%s}\n' % base.doc_type()

Will this still work for implicit bases?

Quoted 1 line
Quoted 11 lines

scripts/qapi2texi.py class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): · line 211

Quoted 6 lines
scripts/qapi2texi.py +2 -0
@@ -205,11 +207,13 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             typ = 'Flat Union'
         else:
             typ = 'Simple Union'
+        if base and base.is_implicit():
+            base = None

Hmm - you just ignore those, such as the anonymous base in CpuInfo. On the other hand, CpuInfo documents its base fields explicitly. Are we at risk of double-documenting a base member, both explicitly and via its named base type?

Actually no.

Doc comments should document exactly the members defined locally. This includes members of anonymous bases, but not members of named bases. If you try to document members of named basses, you get your wrist slapped. For example, if I do

    diff --git a/qapi-schema.json b/qapi-schema.json
    index 1d7b1cd..4214e97 100644
    --- a/qapi-schema.json
    +++ b/qapi-schema.json
    @@ -1549,6 +1549,7 @@
     #
     # @auth: authentication method used for
     #        the plain (non-websocket) VNC server
    +# @family: address family
     #
     # Since: 2.1
     ##

I get

qemu/qapi-schema.json:1545: The following documented members are not in the declaration: family

Quoted 2 lines

At any rate, this patch is an incremental improvement, so:

Thanks!

#75 lore raw

Re: [Qemu-devel] [PATCH for-2.9 26/47] qapi2texi: Generate reference to base type members

Quoted 25 lines · Markus Armbruster
Quoted 10 lines · Eric Blake

scripts/qapi2texi.py def texi_members(doc, what, member_func): · line 156

Quoted 6 lines
scripts/qapi2texi.py +2 -0
@@ -152,6 +152,8 @@ def texi_members(doc, what, member_func):
         else:
             desc = 'Not documented'
         items += member_func(section.member) + texi_format(desc) + '\n'
+    if base:
+        items += '@item The members of @code{%s}\n' % base.doc_type()

Will this still work for implicit bases?

Quoted 1 line
Quoted 11 lines

scripts/qapi2texi.py class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor): · line 211

Quoted 6 lines
scripts/qapi2texi.py +2 -0
@@ -205,11 +207,13 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             typ = 'Flat Union'
         else:
             typ = 'Simple Union'
+        if base and base.is_implicit():
+            base = None

Hmm - you just ignore those, such as the anonymous base in CpuInfo. On the other hand, CpuInfo documents its base fields explicitly. Are we at risk of double-documenting a base member, both explicitly and via its named base type?

Quoted 5 lines

Actually no.

Doc comments should document exactly the members defined locally. This includes members of anonymous bases, but not members of named bases. If you try to document members of named basses, you get your wrist slapped.

Cool, we enforce a uniform style. That's what I was missing.

Quoted 2 lines
Quoted 2 lines

At any rate, this patch is an incremental improvement, so:

And you've shown me that we don't even need a followup for my original concern.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#76 lore raw

PATCH 27/47 qapi2texi: Generate documentation for variant members

In reply to Markus Armbruster

A flat union's branch brings in the members of another type. Generate a suitable reference to that type.

Example change (qemu-qmp-ref.txt):

-- Flat Union: QCryptoBlockOpenOptions

The options that are available for all encryption formats when opening an existing volume

Members:
The members of 'QCryptoBlockOptionsBase'
+ The members of 'QCryptoBlockOptionsQCow' when 'format' is "qcow"
+ The members of 'QCryptoBlockOptionsLUKS' when 'format' is "luks"

      Since: 2.6

A simple union's branch adds a member 'data' of some other type. Generate documentation for that member.

Example change (qemu-qmp-ref.txt):

-- Simple Union: SocketAddress

Captures the address of a socket, which could also be a named file descriptor

Members:
'type'
Not documented

+     'data: InetSocketAddress' when 'type' is "inet"
+     'data: UnixSocketAddress' when 'type' is "unix"
+     'data: VsockSocketAddress' when 'type' is "vsock"
+     'data: String' when 'type' is "fd"
      Since: 1.3
---
 scripts/qapi2texi.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
scripts/qapi2texi.py +20 -7
index 7083d0c..ab6b6cd 100755
@@ -133,17 +133,18 @@ def texi_enum_value(value):
     return '@item @code{%s}\n' % value.name
 
 
-def texi_member(member):
+def texi_member(member, suffix=''):
     """Format a table of members item for an object type member"""
     typ = member.type.doc_type()
-    return '@item @code{%s%s%s}%s\n' % (
+    return '@item @code{%s%s%s}%s%s\n' % (
         member.name,
         ': ' if typ else '',
         typ if typ else '',
-        ' (optional)' if member.optional else '')
+        ' (optional)' if member.optional else '',
+        suffix)
 
 
-def texi_members(doc, what, base, member_func):
+def texi_members(doc, what, base, variants, member_func):
     """Format the table of members"""
     items = ''
     for section in doc.args.itervalues():
@@ -154,6 +155,17 @@ def texi_members(doc, what, base, member_func):
         items += member_func(section.member) + texi_format(desc) + '\n'
     if base:
         items += '@item The members of @code{%s}\n' % base.doc_type()
+    if variants:
+        for v in variants.variants:
+            when = ' when @code{%s} is @t{"%s"}' % (
+                variants.tag_member.name, v.name)
+            if v.type.is_implicit():
+                assert not v.type.base and not v.type.variants
+                for m in v.type.local_members:
+                    items += member_func(m, when)
+            else:
+                items += '@item The members of @code{%s}%s\n' % (
+                    v.type.doc_type(), when)
     if not items:
         return ''
     return '\n@b{%s:}\n@table @asis\n%s@end table\n' % (what, items)
@@ -176,9 +188,10 @@ def texi_sections(doc):
     return body
 
 
-def texi_entity(doc, what, base=None, member_func=texi_member):
+def texi_entity(doc, what, base=None, variants=None,
+                member_func=texi_member):
     return (texi_body(doc)
-            + texi_members(doc, what, base, member_func)
+            + texi_members(doc, what, base, variants, member_func)
             + texi_sections(doc))
 
 
@@ -213,7 +226,7 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
             self.out += '\n'
         self.out += TYPE_FMT(type=typ,
                              name=doc.symbol,
-                             body=texi_entity(doc, 'Members', base))
+                             body=texi_entity(doc, 'Members', base, variants))
 
     def visit_alternate_type(self, name, info, variants):
         doc = self.cur_doc
Signature · 1 line
2.7.4
Reviewed-by on v1 27/47
#77 lore raw

Re: [Qemu-devel] [PATCH for-2.9 27/47] qapi2texi: Generate documentation for variant members

Quoted 5 lines · Markus Armbruster

A flat union's branch brings in the members of another type. Generate a suitable reference to that type.

Example change (qemu-qmp-ref.txt):

Quoted 8 lines

-- Flat Union: QCryptoBlockOpenOptions

The options that are available for all encryption formats when opening an existing volume

Members:
The members of 'QCryptoBlockOptionsBase'
+ The members of 'QCryptoBlockOptionsQCow' when 'format' is "qcow"

Relies on the implied knowledge that 'format' is a member of 'QCryptoBlockOptionsBase'. Does that mean references to another type might usefully want to do a list of member names, to avoid having to follow the hyperlink, while still leaving the hyperlink when searching for full details on that member? As in:

Members:
The members of 'QCryptoBlockOptionsBase' ('format') The members of 'QCryptoBlockOptionsQCow' when 'format' is "qcow" ('key-secret')

But it could get noisy (the example here only adds one member; other unions add lots of members), and I'm also okay if you don't like the idea or would rather do it as a followup.

Quoted 17 lines

+ The members of 'QCryptoBlockOptionsLUKS' when 'format' is "luks"

      Since: 2.6

A simple union's branch adds a member 'data' of some other type. Generate documentation for that member.

Example change (qemu-qmp-ref.txt):

-- Simple Union: SocketAddress

Captures the address of a socket, which could also be a named file descriptor

Members:
'type'
Not documented

Review

Quoted 4 lines
(quoted diff) +4 -0
+     'data: InetSocketAddress' when 'type' is "inet"
+     'data: UnixSocketAddress' when 'type' is "unix"
+     'data: VsockSocketAddress' when 'type' is "vsock"
+     'data: String' when 'type' is "fd"

Looks reasonable.

Quoted 8 lines
      Since: 1.3
---
 scripts/qapi2texi.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#78 lore raw

Re: [Qemu-devel] [PATCH for-2.9 27/47] qapi2texi: Generate documentation for variant members

Quoted 11 lines · Eric Blake
Quoted 10 lines · Markus Armbruster

A flat union's branch brings in the members of another type. Generate a suitable reference to that type.

Example change (qemu-qmp-ref.txt):

-- Flat Union: QCryptoBlockOpenOptions

The options that are available for all encryption formats when opening an existing volume

Quoted 8 lines
Quoted 3 lines

Members:
The members of 'QCryptoBlockOptionsBase'
+ The members of 'QCryptoBlockOptionsQCow' when 'format' is "qcow"

Relies on the implied knowledge that 'format' is a member of 'QCryptoBlockOptionsBase'. Does that mean references to another type might usefully want to do a list of member names, to avoid having to follow the hyperlink, while still leaving the hyperlink when searching

Apropos link: 'format' in 'format is "qcow" could be made one.

Quoted 10 lines

for full details on that member? As in:

Members:
The members of 'QCryptoBlockOptionsBase' ('format') The members of 'QCryptoBlockOptionsQCow' when 'format' is "qcow" ('key-secret')

But it could get noisy (the example here only adds one member; other unions add lots of members), and I'm also okay if you don't like the idea or would rather do it as a followup.

I figure more than a few members would be too noisy. Which ones to omit then? I'm open to ideas, but it needs to be done as a follow-up, to give us a chance to fix the QMP documentation regression in time for 2.9.

Quoted 27 lines
Quoted 17 lines

+ The members of 'QCryptoBlockOptionsLUKS' when 'format' is "luks"

      Since: 2.6

A simple union's branch adds a member 'data' of some other type. Generate documentation for that member.

Example change (qemu-qmp-ref.txt):

-- Simple Union: SocketAddress

Captures the address of a socket, which could also be a named file descriptor

Members:
'type'
Not documented

Review

Quoted 4 lines
(quoted diff) +4 -0
+     'data: InetSocketAddress' when 'type' is "inet"
+     'data: UnixSocketAddress' when 'type' is "unix"
+     'data: VsockSocketAddress' when 'type' is "vsock"
+     'data: String' when 'type' is "fd"

Looks reasonable.

Quoted 3 lines
      Since: 1.3
Quoted 7 lines
Quoted 5 lines
---
 scripts/qapi2texi.py | 27 ++++++++++++++++++++-------
 1 file changed, 20 insertions(+), 7 deletions(-)

Thanks!

#79 lore raw

PATCH 28/47 qapi2texi: Generate descriptions for simple union tags

In reply to Markus Armbruster

Simple union tags carry no type information, because their type is implicit. Their description should make up for it, but many have none. Generate one automatically then.

Example change (qemu-qmp-ref.txt):

-- Simple Union: ImageInfoSpecific

A discriminated record of image format specific information structures.

Members:
'type'
- Not documented
+ One of "qcow2", "vmdk", "luks"
'data: ImageInfoSpecificQCow2' when 'type' is "qcow2" 'data: ImageInfoSpecificVmdk' when 'type' is "vmdk" 'data: QCryptoBlockInfoLUKS' when 'type' is "luks"

---
 scripts/qapi2texi.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
scripts/qapi2texi.py +7 -2
index ab6b6cd..282adf4 100755
@@ -148,11 +148,16 @@ def texi_members(doc, what, base, variants, member_func):
     """Format the table of members"""
     items = ''
     for section in doc.args.itervalues():
+        # TODO Drop fallbacks when undocumented members are outlawed
         if section.content:
-            desc = str(section)
+            desc = texi_format(str(section))
+        elif (variants and variants.tag_member == section.member
+              and not section.member.type.doc_type()):
+            values = section.member.type.member_names()
+            desc = 'One of ' + ', '.join(['@t{"%s"}' % v for v in values])
         else:
             desc = 'Not documented'
-        items += member_func(section.member) + texi_format(desc) + '\n'
+        items += member_func(section.member) + desc + '\n'
     if base:
         items += '@item The members of @code{%s}\n' % base.doc_type()
     if variants:
Signature · 1 line
2.7.4
Reviewed-by on v1 28/47
#80 lore raw

Re: [Qemu-devel] [PATCH for-2.9 28/47] qapi2texi: Generate descriptions for simple union tags

Quoted 13 lines · Markus Armbruster

Simple union tags carry no type information, because their type is implicit. Their description should make up for it, but many have none. Generate one automatically then.

Example change (qemu-qmp-ref.txt):

-- Simple Union: ImageInfoSpecific

A discriminated record of image format specific information structures.

Members:
'type'

Review

Quoted 2 lines
(quoted diff) +1 -1
-          Not documented
+          One of "qcow2", "vmdk", "luks"

Yes, that's nicer.

Quoted 9 lines

'data: ImageInfoSpecificQCow2' when 'type' is "qcow2" 'data: ImageInfoSpecificVmdk' when 'type' is "vmdk" 'data: QCryptoBlockInfoLUKS' when 'type' is "luks"

---
 scripts/qapi2texi.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#81 lore raw

PATCH 29/47 qapi2texi: Use category "Object" for all object types

In reply to Markus Armbruster

At the protocol level, the distinction between struct, flat union and simple union is meaningless, they are all JSON objects. Document them that way.

Example change (qemu-qmp-ref.txt):

- -- Simple Union: InputEvent
+ -- Object: InputEvent

Input event union.

This also fixes the completely broken headings for flat and simple unions in qemu-qmp-ref.7 and qemu-ga-ref.7, by sidestepping a bug in texi2pod.pl. For instance, it mistranslates "@deftp {Simple Union} InputEvent" to "B<Union> (Simple)", but translates "@deftp Object InputEvent" to "B<SocketAddress> (Object)".

---
 scripts/qapi2texi.py | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
scripts/qapi2texi.py +1 -7
index 282adf4..8eed11a 100755
@@ -219,17 +219,11 @@ class QAPISchemaGenDocVisitor(qapi.QAPISchemaVisitor):
 
     def visit_object_type(self, name, info, base, members, variants):
         doc = self.cur_doc
-        if not variants:
-            typ = 'Struct'
-        elif variants._tag_name:        # TODO unclean member access
-            typ = 'Flat Union'
-        else:
-            typ = 'Simple Union'
         if base and base.is_implicit():
             base = None
         if self.out:
             self.out += '\n'
-        self.out += TYPE_FMT(type=typ,
+        self.out += TYPE_FMT(type='Object',
                              name=doc.symbol,
                              body=texi_entity(doc, 'Members', base, variants))
 
Signature · 1 line
2.7.4
Reviewed-by on v1 29/47
#82 lore raw

Re: [Qemu-devel] [PATCH for-2.9 29/47] qapi2texi: Use category "Object" for all object types

Quoted 10 lines · Markus Armbruster

At the protocol level, the distinction between struct, flat union and simple union is meaningless, they are all JSON objects. Document them that way.

Example change (qemu-qmp-ref.txt):

- -- Simple Union: InputEvent
+ -- Object: InputEvent

Input event union.

Yay - and even addresses one of my comments earlier in the series about a needless distinction between simple and flat unions.

Quoted 7 lines

This also fixes the completely broken headings for flat and simple unions in qemu-qmp-ref.7 and qemu-ga-ref.7, by sidestepping a bug in texi2pod.pl. For instance, it mistranslates "@deftp {Simple Union} InputEvent" to "B<Union> (Simple)", but translates "@deftp Object InputEvent" to "B<SocketAddress> (Object)".

Quoted 5 lines
---
 scripts/qapi2texi.py | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#83 lore raw

PATCH 30/47 tests/qapi-schema: Improve doc / expression mismatch coverage

In reply to Markus Armbruster

New test doc-bad-expr.json shows we fail to reject a misplaced expression comment.

New test doc-no-symbol.json shows a bad error message.

---
 tests/Makefile.include               | 2 ++
 tests/qapi-schema/doc-bad-expr.err   | 0
 tests/qapi-schema/doc-bad-expr.exit  | 1 +
 tests/qapi-schema/doc-bad-expr.json  | 8 ++++++++
 tests/qapi-schema/doc-bad-expr.out   | 4 ++++
 tests/qapi-schema/doc-no-symbol.err  | 1 +
 tests/qapi-schema/doc-no-symbol.exit | 1 +
 tests/qapi-schema/doc-no-symbol.json | 7 +++++++
 tests/qapi-schema/doc-no-symbol.out  | 0
 9 files changed, 24 insertions(+)
 create mode 100644 tests/qapi-schema/doc-bad-expr.err
 create mode 100644 tests/qapi-schema/doc-bad-expr.exit
 create mode 100644 tests/qapi-schema/doc-bad-expr.json
 create mode 100644 tests/qapi-schema/doc-bad-expr.out
 create mode 100644 tests/qapi-schema/doc-no-symbol.err
 create mode 100644 tests/qapi-schema/doc-no-symbol.exit
 create mode 100644 tests/qapi-schema/doc-no-symbol.json
 create mode 100644 tests/qapi-schema/doc-no-symbol.out
tests/Makefile.include +2 -0
index 7230977..800acbf 100644
@@ -368,6 +368,7 @@ qapi-schema += base-cycle-indirect.json
 qapi-schema += command-int.json
 qapi-schema += comments.json
 qapi-schema += doc-bad-args.json
+qapi-schema += doc-bad-expr.json
 qapi-schema += doc-bad-symbol.json
 qapi-schema += doc-duplicated-arg.json
 qapi-schema += doc-duplicated-return.json
@@ -385,6 +386,7 @@ qapi-schema += doc-missing.json
 qapi-schema += doc-missing-colon.json
 qapi-schema += doc-missing-expr.json
 qapi-schema += doc-missing-space.json
+qapi-schema += doc-no-symbol.json
 qapi-schema += double-data.json
 qapi-schema += double-type.json
 qapi-schema += duplicate-key.json
tests/qapi-schema/doc-bad-expr.err new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/qapi-schema/doc-bad-expr.exit new file +1 -0
new file mode 100644
index 0000000..573541a
@@ -0,0 +1 @@
+0
tests/qapi-schema/doc-bad-expr.json new file +8 -0
new file mode 100644
index 0000000..ec1fbf2
@@ -0,0 +1,8 @@
+# Doc comment separated from defining expression by non-defining expression
+# BUG: not rejected
+
+##
+# @foo:
+##
+{ 'include': 'empty.json' }
+{ 'struct': 'foo', 'data': {} }
tests/qapi-schema/doc-bad-expr.out new file +4 -0
new file mode 100644
index 0000000..236a849
@@ -0,0 +1,4 @@
+enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+    prefix QTYPE
+object foo
+object q_empty
tests/qapi-schema/doc-no-symbol.err new file +1 -0
new file mode 100644
index 0000000..727966c
@@ -0,0 +1 @@
+tests/qapi-schema/doc-no-symbol.json:4: Definition of 'foo' follows documentation for 'None'
tests/qapi-schema/doc-no-symbol.exit new file +1 -0
new file mode 100644
index 0000000..d00491f
@@ -0,0 +1 @@
+1
tests/qapi-schema/doc-no-symbol.json new file +7 -0
new file mode 100644
index 0000000..ee86ca1
@@ -0,0 +1,7 @@
+# Documentation for expression lacks symbol
+# BUG: Error message claims it has symbol 'None'
+
+##
+# foo:
+##
+{ 'command': 'foo', 'data': {'a': 'int'} }
tests/qapi-schema/doc-no-symbol.out new file +0 -0
new file mode 100644
index 0000000..e69de29
Signature · 1 line
2.7.4
Reviewed-by on v1 30/47
#84 lore raw

Re: [Qemu-devel] [PATCH for-2.9 30/47] tests/qapi-schema: Improve doc / expression mismatch coverage

tests/qapi-schema/doc-no-symbol.err line 1

Quoted 11 lines · Markus Armbruster

New test doc-bad-expr.json shows we fail to reject a misplaced expression comment.

New test doc-no-symbol.json shows a bad error message.

---

+++ b/tests/qapi-schema/doc-no-symbol.err

tests/qapi-schema/doc-no-symbol.err new file +1 -0
@@ -0,0 +1 @@
+tests/qapi-schema/doc-no-symbol.json:4: Definition of 'foo' follows documentation for 'None'

Yep, that's python implementation leaking through.

tests/qapi-schema/doc-no-symbol.json line 2

Quoted 4 lines

+++ b/tests/qapi-schema/doc-no-symbol.json

tests/qapi-schema/doc-no-symbol.json new file +2 -0
@@ -0,0 +1,7 @@
+# Documentation for expression lacks symbol
+# BUG: Error message claims it has symbol 'None'
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#85 lore raw

Re: [Qemu-devel] [PATCH for-2.9 30/47] tests/qapi-schema: Improve doc / expression mismatch coverage

In reply to Markus Armbruster
Quoted 10 lines · Markus Armbruster

New test doc-bad-expr.json shows we fail to reject a misplaced expression comment.

New test doc-no-symbol.json shows a bad error message.

---

+++ b/tests/qapi-schema/doc-bad-expr.json

tests/qapi-schema/doc-bad-expr.json line 8

Quoted 8 lines
tests/qapi-schema/doc-bad-expr.json new file +8 -0
@@ -0,0 +1,8 @@
+# Doc comment separated from defining expression by non-defining expression
+# BUG: not rejected
+
+##
+# @foo:
+##
+{ 'include': 'empty.json' }
+{ 'struct': 'foo', 'data': {} }

See my comments on 31/47 for an enhancement to this test that also sticks a { 'pragma': {} } there.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#86 lore raw

PATCH 31/47 qapi: Fix detection of doc / expression mismatch

In reply to Markus Armbruster

This fixes the errors uncovered by the previous commit.

---
 scripts/qapi.py                        | 34 +++++++++++++++++++++-------------
 tests/qapi-schema/doc-bad-expr.err     |  1 +
 tests/qapi-schema/doc-bad-expr.exit    |  2 +-
 tests/qapi-schema/doc-bad-expr.json    |  1 -
 tests/qapi-schema/doc-bad-expr.out     |  4 ----
 tests/qapi-schema/doc-missing-expr.err |  2 +-
 tests/qapi-schema/doc-no-symbol.err    |  2 +-
 tests/qapi-schema/doc-no-symbol.json   |  1 -
 8 files changed, 25 insertions(+), 22 deletions(-)
scripts/qapi.py +21 -13
index b82a2a6..1052274 100644
@@ -248,18 +248,21 @@ class QAPISchemaParser(object):
         self.line_pos = 0
         self.exprs = []
         self.docs = []
+        self.cur_doc = None
         self.accept()
 
         while self.tok is not None:
             info = {'file': fname, 'line': self.line,
                     'parent': self.incl_info}
             if self.tok == '#':
-                doc = self.get_doc(info)
-                self.docs.append(doc)
+                self.reject_expr_doc()
+                self.cur_doc = self.get_doc(info)
+                self.docs.append(self.cur_doc)
                 continue
 
             expr = self.get_expr(False)
             if 'include' in expr:
+                self.reject_expr_doc()
                 if len(expr) != 1:
                     raise QAPISemError(info, "Invalid 'include' directive")
                 include = expr['include']
@@ -276,13 +279,23 @@ class QAPISchemaParser(object):
             else:
                 expr_elem = {'expr': expr,
                              'info': info}
-                if (self.docs
-                        and self.docs[-1].info['file'] == fname
-                        and not self.docs[-1].expr):
-                    self.docs[-1].expr = expr
-                    expr_elem['doc'] = self.docs[-1]
-
+                if self.cur_doc:
+                    if not self.cur_doc.symbol:
+                        raise QAPISemError(
+                            self.cur_doc.info,
+                            "Expression documentation required")
+                    self.cur_doc.expr = expr
+                    expr_elem['doc'] = self.cur_doc
                 self.exprs.append(expr_elem)
+            self.cur_doc = None
+        self.reject_expr_doc()
+
+    def reject_expr_doc(self):
+        if self.cur_doc and self.cur_doc.symbol:
+            raise QAPISemError(
+                self.cur_doc.info,
+                "Documentation for '%s' is not followed by the definition"
+                % self.cur_doc.symbol)
 
     def _include(self, include, info, base_dir, previously_included):
         incl_abs_fname = os.path.join(base_dir, include)
@@ -946,11 +959,6 @@ def check_exprs(exprs):
 
 
 def check_freeform_doc(doc):
-    if doc.symbol:
-        raise QAPISemError(doc.info,
-                           "Documention for '%s' is not followed"
-                           " by the definition" % doc.symbol)
-
     body = str(doc.body)
     if re.search(r'@\S+:', body, re.MULTILINE):
         raise QAPISemError(doc.info,
tests/qapi-schema/doc-bad-expr.err +1 -0
index e69de29..65e9d1f 100644
@@ -0,0 +1 @@
+tests/qapi-schema/doc-bad-expr.json:3: Documentation for 'foo' is not followed by the definition
tests/qapi-schema/doc-bad-expr.exit +1 -1
index 573541a..d00491f 100644
@@ -1 +1 @@
-0
+1
tests/qapi-schema/doc-bad-expr.json +0 -1
index ec1fbf2..0caa0ae 100644
@@ -1,5 +1,4 @@
 # Doc comment separated from defining expression by non-defining expression
-# BUG: not rejected
 
 ##
 # @foo:
tests/qapi-schema/doc-bad-expr.out +0 -4
index 236a849..e69de29 100644
@@ -1,4 +0,0 @@
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
-    prefix QTYPE
-object foo
-object q_empty
tests/qapi-schema/doc-missing-expr.err +1 -1
index c0e687c..c909e26 100644
@@ -1 +1 @@
-tests/qapi-schema/doc-missing-expr.json:3: Documention for 'bar' is not followed by the definition
+tests/qapi-schema/doc-missing-expr.json:3: Documentation for 'bar' is not followed by the definition
tests/qapi-schema/doc-no-symbol.err +1 -1
index 727966c..75f032a 100644
@@ -1 +1 @@
-tests/qapi-schema/doc-no-symbol.json:4: Definition of 'foo' follows documentation for 'None'
+tests/qapi-schema/doc-no-symbol.json:3: Expression documentation required
tests/qapi-schema/doc-no-symbol.json +0 -1
index ee86ca1..98605ba 100644
@@ -1,5 +1,4 @@
 # Documentation for expression lacks symbol
-# BUG: Error message claims it has symbol 'None'
 
 ##
 # foo:
Signature · 1 line
2.7.4
#87 lore raw

Re: [Qemu-devel] [PATCH for-2.9 31/47] qapi: Fix detection of doc / expression mismatch

Quoted 10 lines · Markus Armbruster

This fixes the errors uncovered by the previous commit.

---

expr = self.get_expr(False)
if 'include' in expr:
+ self.reject_expr_doc()

                 if len(expr) != 1:

Do you also need to handle 'pragma' expressions added earlier in the series?

/me goes and experiments:

(quoted diff) +0 -0

w/tests/qapi-schema/doc-bad-expr.json
index 0caa0ae..6c1204d 100644

tests/qapi-schema/doc-bad-expr.json +1 -0
@@ -4,4 +4,5 @@
 # @foo:
 ##
 { 'include': 'empty.json' }
+{ 'pragma': {} }
 { 'struct': 'foo', 'data': {} }

Oops - back to accepting the program.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#88 lore raw

Re: [Qemu-devel] [PATCH for-2.9 31/47] qapi: Fix detection of doc / expression mismatch

Quoted 7 lines · Eric Blake
Quoted 6 lines · Markus Armbruster

This fixes the errors uncovered by the previous commit.

---

Quoted 6 lines
Quoted 4 lines

expr = self.get_expr(False)
if 'include' in expr:
+ self.reject_expr_doc()

                 if len(expr) != 1:

Do you also need to handle 'pragma' expressions added earlier in the series?

Yes.

Quoted 14 lines

/me goes and experiments:

(quoted diff) +0 -0

w/tests/qapi-schema/doc-bad-expr.json
index 0caa0ae..6c1204d 100644

tests/qapi-schema/doc-bad-expr.json +1 -0
@@ -4,4 +4,5 @@
 # @foo:
 ##
 { 'include': 'empty.json' }
+{ 'pragma': {} }
 { 'struct': 'foo', 'data': {} }
Quoted 1 line

Oops - back to accepting the program.

Need to squash in

scripts/qapi.py +1 -0
index 1dc33c9..8d55ff4 100644
@@ -301,6 +301,7 @@ class QAPISchemaParser(object):
                 self._include(include, info, os.path.dirname(abs_fname),
                               previously_included)
             elif "pragma" in expr:
+                self.reject_expr_doc()
                 if len(expr) != 1:
                     raise QAPISemError(info, "Invalid 'pragma' directive")
                 for name, value in expr['pragma'].iteritems():
Reviewed-by
#89 lore raw

Re: [Qemu-devel] [PATCH for-2.9 31/47] qapi: Fix detection of doc / expression mismatch

Quoted 28 lines · Markus Armbruster
Quoted 7 lines · Eric Blake
Quoted 6 lines · Markus Armbruster

This fixes the errors uncovered by the previous commit.

---

Quoted 6 lines
Quoted 4 lines

expr = self.get_expr(False)
if 'include' in expr:
+ self.reject_expr_doc()

                 if len(expr) != 1:

Do you also need to handle 'pragma' expressions added earlier in the series?

Yes.

Need to squash in

scripts/qapi.py +0 -0
index 1dc33c9..8d55ff4 100644

scripts/qapi.py class QAPISchemaParser(object): · line 307

Quoted 7 lines
scripts/qapi.py +1 -0
@@ -301,6 +301,7 @@ class QAPISchemaParser(object):
                 self._include(include, info, os.path.dirname(abs_fname),
                               previously_included)
             elif "pragma" in expr:
+                self.reject_expr_doc()
                 if len(expr) != 1:
                     raise QAPISemError(info, "Invalid 'pragma' directive")
                 for name, value in expr['pragma'].iteritems():

Yep, that looks like it. So with the test updated in 30/47, and this squashed into 31/47, you can add:

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#90 lore raw

PATCH 32/47 qapi: Move detection of doc / expression name mismatch

In reply to Markus Armbruster

Move the check whether the doc matches the expression name from check_definition_doc() to check_exprs(). This changes the error location from the comment to the expression. Makes sense as the message talks about the expresion: "Definition of '%s' follows documentation for '%s'". It's also a step towards getting rid of check_docs().

---
 scripts/qapi.py                      | 28 ++++++++++++++++++----------
 tests/qapi-schema/doc-bad-symbol.err |  2 +-
 2 files changed, 19 insertions(+), 11 deletions(-)
scripts/qapi.py +18 -10
index 1052274..ca8d1f0 100644
@@ -889,40 +889,52 @@ def check_keys(expr_elem, meta, required, optional=[]):
 def check_exprs(exprs):
     global all_names
 
-    # Learn the types and check for valid expression keys
+    # Populate name table with names of built-in types
     for builtin in builtin_types.keys():
         all_names[builtin] = 'built-in'
+
+    # Learn the types and check for valid expression keys
     for expr_elem in exprs:
         expr = expr_elem['expr']
         info = expr_elem['info']
+        doc = expr_elem.get('doc')
 
-        if 'doc' not in expr_elem and doc_required:
+        if not doc and doc_required:
             raise QAPISemError(info,
                                "Expression missing documentation comment")
 
         if 'enum' in expr:
+            name = expr['enum']
             check_keys(expr_elem, 'enum', ['data'], ['prefix'])
-            add_enum(expr['enum'], info, expr['data'])
+            add_enum(name, info, expr['data'])
         elif 'union' in expr:
+            name = expr['union']
             check_keys(expr_elem, 'union', ['data'],
                        ['base', 'discriminator'])
             add_union(expr, info)
         elif 'alternate' in expr:
+            name = expr['alternate']
             check_keys(expr_elem, 'alternate', ['data'])
-            add_name(expr['alternate'], info, 'alternate')
+            add_name(name, info, 'alternate')
         elif 'struct' in expr:
+            name = expr['struct']
             check_keys(expr_elem, 'struct', ['data'], ['base'])
             add_struct(expr, info)
         elif 'command' in expr:
+            name = expr['command']
             check_keys(expr_elem, 'command', [],
                        ['data', 'returns', 'gen', 'success-response', 'boxed'])
-            add_name(expr['command'], info, 'command')
+            add_name(name, info, 'command')
         elif 'event' in expr:
+            name = expr['event']
             check_keys(expr_elem, 'event', [], ['data', 'boxed'])
-            add_name(expr['event'], info, 'event')
+            add_name(name, info, 'event')
         else:
             raise QAPISemError(expr_elem['info'],
                                "Expression is missing metatype")
+        if doc and doc.symbol != name:
+            raise QAPISemError(info, "Definition of '%s' follows documentation"
+                               " for '%s'" % (name, doc.symbol))
 
     # Try again for hidden UnionKind enum
     for expr_elem in exprs:
@@ -972,10 +984,6 @@ def check_definition_doc(doc, expr, info):
             meta = i
             break
 
-    name = expr[meta]
-    if doc.symbol != name:
-        raise QAPISemError(info, "Definition of '%s' follows documentation"
-                           " for '%s'" % (name, doc.symbol))
     if doc.has_section('Returns') and 'command' not in expr:
         raise QAPISemError(info, "'Returns:' is only valid for commands")
 
tests/qapi-schema/doc-bad-symbol.err +1 -1
index ac4e566..8472030 100644
@@ -1 +1 @@
-tests/qapi-schema/doc-bad-symbol.json:3: Definition of 'foo' follows documentation for 'food'
+tests/qapi-schema/doc-bad-symbol.json:6: Definition of 'foo' follows documentation for 'food'
Signature · 1 line
2.7.4
Reviewed-by on v1 32/47
#91 lore raw

Re: [Qemu-devel] [PATCH for-2.9 32/47] qapi: Move detection of doc / expression name mismatch

Quoted 4 lines · Markus Armbruster

Move the check whether the doc matches the expression name from check_definition_doc() to check_exprs(). This changes the error location from the comment to the expression. Makes sense as the message talks about the expresion: "Definition of '%s' follows

s/expresion/expression/

Quoted 9 lines

documentation for '%s'". It's also a step towards getting rid of check_docs().

---
 scripts/qapi.py                      | 28 ++++++++++++++++++----------
 tests/qapi-schema/doc-bad-symbol.err |  2 +-
 2 files changed, 19 insertions(+), 11 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#92 lore raw

Re: [Qemu-devel] [PATCH for-2.9 32/47] qapi: Move detection of doc / expression name mismatch

Quoted 7 lines · Eric Blake
Quoted 4 lines · Markus Armbruster

Move the check whether the doc matches the expression name from check_definition_doc() to check_exprs(). This changes the error location from the comment to the expression. Makes sense as the message talks about the expresion: "Definition of '%s' follows

s/expresion/expression/

Will fix.

Quoted 11 lines
Quoted 9 lines

documentation for '%s'". It's also a step towards getting rid of check_docs().

---
 scripts/qapi.py                      | 28 ++++++++++++++++++----------
 tests/qapi-schema/doc-bad-symbol.err |  2 +-
 2 files changed, 19 insertions(+), 11 deletions(-)

Thanks!

#93 lore raw

PATCH 33/47 qapi: Improve error message on @NAME: in free-form doc

In reply to Markus Armbruster
---
 scripts/qapi.py                           | 17 ++++++-----------
 tests/qapi-schema/doc-invalid-section.err |  2 +-
 2 files changed, 7 insertions(+), 12 deletions(-)
scripts/qapi.py +6 -11
index ca8d1f0..8d34651 100644
@@ -219,6 +219,11 @@ class QAPIDoc(object):
         if (in_arg or not self.section.name
                 or not self.section.name.startswith('Example')):
             line = line.strip()
+        match = re.match(r'(@\S+:)', line)
+        if match:
+            raise QAPIParseError(self.parser,
+                                 "'%s' not allowed in free-form documentation"
+                                 % match.group(1))
         # TODO Drop this once the dust has settled
         if (isinstance(self.section, QAPIDoc.ArgSection)
                 and '#optional' in line):
@@ -970,14 +975,6 @@ def check_exprs(exprs):
     return exprs
 
 
-def check_freeform_doc(doc):
-    body = str(doc.body)
-    if re.search(r'@\S+:', body, re.MULTILINE):
-        raise QAPISemError(doc.info,
-                           "Free-form documentation block must not contain"
-                           " @NAME: sections")
-
-
 def check_definition_doc(doc, expr, info):
     for i in ('enum', 'union', 'alternate', 'struct', 'command', 'event'):
         if i in expr:
@@ -1016,9 +1013,7 @@ def check_docs(docs):
                 raise QAPISemError(doc.info,
                                    "Empty doc section '%s'" % section.name)
 
-        if not doc.expr:
-            check_freeform_doc(doc)
-        else:
+        if doc.expr:
             check_definition_doc(doc, doc.expr, doc.info)
 
     return docs
tests/qapi-schema/doc-invalid-section.err +1 -1
index 85bb67b..bda93b4 100644
@@ -1 +1 @@
-tests/qapi-schema/doc-invalid-section.json:3: Free-form documentation block must not contain @NAME: sections
+tests/qapi-schema/doc-invalid-section.json:5:1: '@note:' not allowed in free-form documentation
Signature · 1 line
2.7.4
Reviewed-by on v1 33/47
#94 lore raw

Re: [Qemu-devel] [PATCH for-2.9 33/47] qapi: Improve error message on @NAME: in free-form doc

Quoted 6 lines · Markus Armbruster
---
 scripts/qapi.py                           | 17 ++++++-----------
 tests/qapi-schema/doc-invalid-section.err |  2 +-
 2 files changed, 7 insertions(+), 12 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#95 lore raw

PATCH 34/47 qapi: Move empty doc section checking to doc parser

In reply to Markus Armbruster

Results in a more precise error location, but the real reason is emptying out check_docs() step by step.

---
 scripts/qapi.py                         | 20 ++++++++++++++------
 tests/qapi-schema/doc-empty-section.err |  2 +-
 2 files changed, 15 insertions(+), 7 deletions(-)
scripts/qapi.py +14 -6
index 8d34651..e53701a 100644
@@ -173,6 +173,9 @@ class QAPIDoc(object):
         else:
             self._append_freeform(line)
 
+    def end_comment(self):
+        self._end_section()
+
     def _append_symbol_line(self, line):
         name = line.split(' ', 1)[0]
 
@@ -200,6 +203,7 @@ class QAPIDoc(object):
             raise QAPIParseError(self.parser,
                                  "'@%s:' can't follow '%s' section"
                                  % (name, self.sections[0].name))
+        self._end_section()
         self.section = QAPIDoc.ArgSection(name)
         self.args[name] = self.section
 
@@ -207,9 +211,18 @@ class QAPIDoc(object):
         if name in ('Returns', 'Since') and self.has_section(name):
             raise QAPIParseError(self.parser,
                                  "Duplicated '%s' section" % name)
+        self._end_section()
         self.section = QAPIDoc.Section(name)
         self.sections.append(self.section)
 
+    def _end_section(self):
+        if self.section:
+            contents = str(self.section)
+            if self.section.name and (not contents or contents.isspace()):
+                raise QAPIParseError(self.parser, "Empty doc section '%s'"
+                                     % self.section.name)
+            self.section = None
+
     def _append_freeform(self, line):
         in_arg = isinstance(self.section, QAPIDoc.ArgSection)
         if (in_arg and self.section.content
@@ -507,6 +520,7 @@ class QAPISchemaParser(object):
                 if self.val != '##':
                     raise QAPIParseError(self, "Junk after '##' at end of "
                                          "documentation comment")
+                doc.end_comment()
                 self.accept()
                 return doc
             else:
@@ -1007,12 +1021,6 @@ def check_definition_doc(doc, expr, info):
 
 def check_docs(docs):
     for doc in docs:
-        for section in doc.args.values() + doc.sections:
-            content = str(section)
-            if not content or content.isspace():
-                raise QAPISemError(doc.info,
-                                   "Empty doc section '%s'" % section.name)
-
         if doc.expr:
             check_definition_doc(doc, doc.expr, doc.info)
 
tests/qapi-schema/doc-empty-section.err +1 -1
index 00ad625..b61e4a7 100644
@@ -1 +1 @@
-tests/qapi-schema/doc-empty-section.json:3: Empty doc section 'Note'
+tests/qapi-schema/doc-empty-section.json:7:1: Empty doc section 'Note'
Signature · 1 line
2.7.4
#96 lore raw

Re: [Qemu-devel] [PATCH for-2.9 34/47] qapi: Move empty doc section checking to doc parser

Quoted 4 lines · Markus Armbruster

Results in a more precise error location, but the real reason is emptying out check_docs() step by step.

Perhaps we should simply drop this error condition. Are empty sections this a mistake users make accidentally?

#97 lore raw

Re: [Qemu-devel] [PATCH for-2.9 34/47] qapi: Move empty doc section checking to doc parser

Quoted 9 lines · Markus Armbruster
Quoted 4 lines · Markus Armbruster

Results in a more precise error location, but the real reason is emptying out check_docs() step by step.

Perhaps we should simply drop this error condition. Are empty sections this a mistake users make accidentally?

Parse error; did you mean "empty sections _like_ this"?

I'm okay with keeping the error; especially if we can't guarantee that the generator copes gracefully with an empty section (different than an omitted section). On the other hand, even if we remove the error, you're probably right that anyone proposing a patch for incorporation that adds an empty section will have to explain themselves, whether or not the parser flagged it, and if the error is cheap to maintain in the parser, then it saves some review cycles.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#98 lore raw

Re: [Qemu-devel] [PATCH for-2.9 34/47] qapi: Move empty doc section checking to doc parser

Quoted 6 lines · Eric Blake
Quoted 5 lines · Markus Armbruster
Quoted 3 lines · Markus Armbruster

Results in a more precise error location, but the real reason is emptying out check_docs() step by step.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Perhaps we should simply drop this error condition. Are empty sections this a mistake users make accidentally?

Parse error; did you mean "empty sections _like_ this"?

Yes.

Quoted 3 lines

I'm okay with keeping the error; especially if we can't guarantee that the generator copes gracefully with an empty section (different than an omitted section).

We'd have to verify it does.

Quoted 5 lines

On the other hand, even if we remove the error,
you're probably right that anyone proposing a patch for incorporation that adds an empty section will have to explain themselves, whether or not the parser flagged it, and if the error is cheap to maintain in the parser, then it saves some review cycles.

The patch adds two methods and changes three existing ones just to catch empty sections. I can't help to ask: why bother?

Reviewed-by on v1 34/47
#99 lore raw

Re: [Qemu-devel] [PATCH for-2.9 34/47] qapi: Move empty doc section checking to doc parser

In reply to Markus Armbruster
Quoted 8 lines · Markus Armbruster

Results in a more precise error location, but the real reason is emptying out check_docs() step by step.

---
 scripts/qapi.py                         | 20 ++++++++++++++------
 tests/qapi-schema/doc-empty-section.err |  2 +-
 2 files changed, 15 insertions(+), 7 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#100 lore raw

PATCH 35/47 tests/qapi-schema: Rename doc-bad-args to doc-bad-command-arg

In reply to Markus Armbruster
---
 tests/Makefile.include                                            | 2 +-
 tests/qapi-schema/doc-bad-args.err                                | 1 -
 tests/qapi-schema/doc-bad-command-arg.err                         | 1 +
 tests/qapi-schema/{doc-bad-args.exit => doc-bad-command-arg.exit} | 0
 tests/qapi-schema/{doc-bad-args.json => doc-bad-command-arg.json} | 0
 tests/qapi-schema/{doc-bad-args.out => doc-bad-command-arg.out}   | 0
 6 files changed, 2 insertions(+), 2 deletions(-)
 delete mode 100644 tests/qapi-schema/doc-bad-args.err
 create mode 100644 tests/qapi-schema/doc-bad-command-arg.err
 rename tests/qapi-schema/{doc-bad-args.exit => doc-bad-command-arg.exit} (100%)
 rename tests/qapi-schema/{doc-bad-args.json => doc-bad-command-arg.json} (100%)
 rename tests/qapi-schema/{doc-bad-args.out => doc-bad-command-arg.out} (100%)
tests/Makefile.include +1 -1
index 800acbf..8ce9d3d 100644
@@ -367,7 +367,7 @@ qapi-schema += base-cycle-direct.json
 qapi-schema += base-cycle-indirect.json
 qapi-schema += command-int.json
 qapi-schema += comments.json
-qapi-schema += doc-bad-args.json
+qapi-schema += doc-bad-command-arg.json
 qapi-schema += doc-bad-expr.json
 qapi-schema += doc-bad-symbol.json
 qapi-schema += doc-duplicated-arg.json
tests/qapi-schema/doc-bad-args.err deleted +0 -1
deleted file mode 100644
index 5d44d9b..0000000
@@ -1 +0,0 @@
-tests/qapi-schema/doc-bad-args.json:3: The following documented members are not in the declaration: b
tests/qapi-schema/doc-bad-command-arg.err new file +1 -0
new file mode 100644
index 0000000..8075b14
@@ -0,0 +1 @@
+tests/qapi-schema/doc-bad-command-arg.json:3: The following documented members are not in the declaration: b
tests/qapi-schema/doc-bad-command-arg.exit renamed from tests/qapi-schema/doc-bad-args.exit +0 -0
similarity index 100%
rename from tests/qapi-schema/doc-bad-args.exit
rename to tests/qapi-schema/doc-bad-command-arg.exit
tests/qapi-schema/doc-bad-command-arg.json renamed from tests/qapi-schema/doc-bad-args.json +0 -0
similarity index 100%
rename from tests/qapi-schema/doc-bad-args.json
rename to tests/qapi-schema/doc-bad-command-arg.json
tests/qapi-schema/doc-bad-command-arg.out renamed from tests/qapi-schema/doc-bad-args.out +0 -0
similarity index 100%
rename from tests/qapi-schema/doc-bad-args.out
rename to tests/qapi-schema/doc-bad-command-arg.out
Signature · 1 line
2.7.4
Reviewed-by on v1 35/47
#101 lore raw

Re: [Qemu-devel] [PATCH for-2.9 35/47] tests/qapi-schema: Rename doc-bad-args to doc-bad-command-arg

Quoted 15 lines · Markus Armbruster
---
 tests/Makefile.include                                            | 2 +-
 tests/qapi-schema/doc-bad-args.err                                | 1 -
 tests/qapi-schema/doc-bad-command-arg.err                         | 1 +
 tests/qapi-schema/{doc-bad-args.exit => doc-bad-command-arg.exit} | 0
 tests/qapi-schema/{doc-bad-args.json => doc-bad-command-arg.json} | 0
 tests/qapi-schema/{doc-bad-args.out => doc-bad-command-arg.out}   | 0
 6 files changed, 2 insertions(+), 2 deletions(-)
 delete mode 100644 tests/qapi-schema/doc-bad-args.err
 create mode 100644 tests/qapi-schema/doc-bad-command-arg.err
 rename tests/qapi-schema/{doc-bad-args.exit => doc-bad-command-arg.exit} (100%)
 rename tests/qapi-schema/{doc-bad-args.json => doc-bad-command-arg.json} (100%)
 rename tests/qapi-schema/{doc-bad-args.out => doc-bad-command-arg.out} (100%)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#102 lore raw

PATCH 36/47 tests/qapi-schema: Improve coverage of bogus member docs

In reply to Markus Armbruster

New test doc-bad-union-member.json shows we can fail to reject documentation for nonexistent members.

---
 tests/Makefile.include                          |  2 ++
 tests/qapi-schema/doc-bad-alternate-member.err  |  1 +
 tests/qapi-schema/doc-bad-alternate-member.exit |  1 +
 tests/qapi-schema/doc-bad-alternate-member.json |  9 +++++++++
 tests/qapi-schema/doc-bad-alternate-member.out  |  0
 tests/qapi-schema/doc-bad-union-member.err      |  0
 tests/qapi-schema/doc-bad-union-member.exit     |  1 +
 tests/qapi-schema/doc-bad-union-member.json     | 19 +++++++++++++++++++
 tests/qapi-schema/doc-bad-union-member.out      | 11 +++++++++++
 9 files changed, 44 insertions(+)
 create mode 100644 tests/qapi-schema/doc-bad-alternate-member.err
 create mode 100644 tests/qapi-schema/doc-bad-alternate-member.exit
 create mode 100644 tests/qapi-schema/doc-bad-alternate-member.json
 create mode 100644 tests/qapi-schema/doc-bad-alternate-member.out
 create mode 100644 tests/qapi-schema/doc-bad-union-member.err
 create mode 100644 tests/qapi-schema/doc-bad-union-member.exit
 create mode 100644 tests/qapi-schema/doc-bad-union-member.json
 create mode 100644 tests/qapi-schema/doc-bad-union-member.out
tests/Makefile.include +2 -0
index 8ce9d3d..5edf3fa 100644
@@ -367,9 +367,11 @@ qapi-schema += base-cycle-direct.json
 qapi-schema += base-cycle-indirect.json
 qapi-schema += command-int.json
 qapi-schema += comments.json
+qapi-schema += doc-bad-alternate-member.json
 qapi-schema += doc-bad-command-arg.json
 qapi-schema += doc-bad-expr.json
 qapi-schema += doc-bad-symbol.json
+qapi-schema += doc-bad-union-member.json
 qapi-schema += doc-duplicated-arg.json
 qapi-schema += doc-duplicated-return.json
 qapi-schema += doc-duplicated-since.json
tests/qapi-schema/doc-bad-alternate-member.err new file +1 -0
new file mode 100644
index 0000000..387f782
@@ -0,0 +1 @@
+tests/qapi-schema/doc-bad-alternate-member.json:3: The following documented members are not in the declaration: aa, bb
tests/qapi-schema/doc-bad-alternate-member.exit new file +1 -0
new file mode 100644
index 0000000..d00491f
@@ -0,0 +1 @@
+1
tests/qapi-schema/doc-bad-alternate-member.json new file +9 -0
new file mode 100644
index 0000000..738635c
@@ -0,0 +1,9 @@
+# Arguments listed in the doc comment must exist in the actual schema
+
+##
+# @AorB:
+# @aa: a
+# @bb: b
+##
+{ 'alternate': 'AorB',
+  'data': { 'a': 'str', 'b': 'int' } }
tests/qapi-schema/doc-bad-alternate-member.out new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/qapi-schema/doc-bad-union-member.err new file +0 -0
new file mode 100644
index 0000000..e69de29
tests/qapi-schema/doc-bad-union-member.exit new file +1 -0
new file mode 100644
index 0000000..573541a
@@ -0,0 +1 @@
+0
tests/qapi-schema/doc-bad-union-member.json new file +19 -0
new file mode 100644
index 0000000..d611435
@@ -0,0 +1,19 @@
+# Arguments listed in the doc comment must exist in the actual schema
+
+##
+# @Frob:
+# @a: a
+# @b: b
+##
+{ 'union': 'Frob',
+  'base': 'Base',
+  'discriminator': 'type',
+  'data': { 'nothing': 'Empty' } }
+
+{ 'struct': 'Base',
+  'data': { 'type': 'T' } }
+
+{ 'struct': 'Empty',
+  'data': { } }
+
+{ 'enum': 'T', 'data': ['nothing'] }
tests/qapi-schema/doc-bad-union-member.out new file +11 -0
new file mode 100644
index 0000000..2576ecd
@@ -0,0 +1,11 @@
+object Base
+    member type: T optional=False
+object Empty
+object Frob
+    base Base
+    tag type
+    case nothing: Empty
+enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
+    prefix QTYPE
+enum T ['nothing']
+object q_empty
Signature · 1 line
2.7.4
Reviewed-by on v1 36/47
#103 lore raw

Re: [Qemu-devel] [PATCH for-2.9 36/47] tests/qapi-schema: Improve coverage of bogus member docs

Quoted 5 lines · Markus Armbruster

New test doc-bad-union-member.json shows we can fail to reject documentation for nonexistent members.

---

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#104 lore raw

PATCH 37/47 qapi: Fix detection of bogus member documentation

In reply to Markus Armbruster

check_definition_doc() checks for member documentation without a matching member. It laboriously second-guesses what members QAPISchema._def_exprs() will create. That's a stupid game.

Move the check into QAPISchema.check(), where the members are known. Delegate the actual checking to new QAPIDoc.check().

---
 scripts/qapi.py                             | 38 ++++++++++-------------------
 tests/qapi-schema/doc-bad-union-member.err  |  1 +
 tests/qapi-schema/doc-bad-union-member.exit |  2 +-
 tests/qapi-schema/doc-bad-union-member.out  | 11 ---------
 4 files changed, 15 insertions(+), 37 deletions(-)
scripts/qapi.py +13 -25
index e53701a..0b0ba59 100644
@@ -249,6 +249,15 @@ class QAPIDoc(object):
             self.args[member.name] = QAPIDoc.ArgSection(member.name)
         self.args[member.name].connect(member)
 
+    def check(self):
+        bogus = [name for name, section in self.args.iteritems()
+                 if not section.member]
+        if bogus:
+            raise QAPISemError(
+                self.info,
+                "The following documented members are not in "
+                "the declaration: %s" % ", ".join(bogus))
+
 
 class QAPISchemaParser(object):
 
@@ -990,34 +999,9 @@ def check_exprs(exprs):
 
 
 def check_definition_doc(doc, expr, info):
-    for i in ('enum', 'union', 'alternate', 'struct', 'command', 'event'):
-        if i in expr:
-            meta = i
-            break
-
     if doc.has_section('Returns') and 'command' not in expr:
         raise QAPISemError(info, "'Returns:' is only valid for commands")
 
-    if meta == 'union':
-        args = expr.get('base', [])
-    else:
-        args = expr.get('data', [])
-    if isinstance(args, str):
-        return
-    if isinstance(args, dict):
-        args = args.keys()
-    assert isinstance(args, list)
-
-    if (meta == 'alternate'
-            or (meta == 'union' and not expr.get('discriminator'))):
-        args.append('type')
-
-    doc_args = set(doc.args.keys())
-    args = set([name.strip('*') for name in args])
-    if not doc_args.issubset(args):
-        raise QAPISemError(info, "The following documented members are not in "
-                           "the declaration: %s" % ', '.join(doc_args - args))
-
 
 def check_docs(docs):
     for doc in docs:
@@ -1263,6 +1247,8 @@ class QAPISchemaObjectType(QAPISchemaType):
             self.variants.check(schema, seen)
             assert self.variants.tag_member in self.members
             self.variants.check_clash(schema, self.info, seen)
+        if self.doc:
+            self.doc.check()
 
     # Check that the members of this type do not cause duplicate JSON members,
     # and update seen to track the members seen so far. Report any errors
@@ -1432,6 +1418,8 @@ class QAPISchemaAlternateType(QAPISchemaType):
             v.check_clash(self.info, seen)
             if self.doc:
                 self.doc.connect_member(v)
+        if self.doc:
+            self.doc.check()
 
     def c_type(self):
         return c_name(self.name) + pointer_suffix
tests/qapi-schema/doc-bad-union-member.err +1 -0
index e69de29..4b016df 100644
@@ -0,0 +1 @@
+tests/qapi-schema/doc-bad-union-member.json:3: The following documented members are not in the declaration: a, b
tests/qapi-schema/doc-bad-union-member.exit +1 -1
index 573541a..d00491f 100644
@@ -1 +1 @@
-0
+1
tests/qapi-schema/doc-bad-union-member.out +0 -11
index 2576ecd..e69de29 100644
@@ -1,11 +0,0 @@
-object Base
-    member type: T optional=False
-object Empty
-object Frob
-    base Base
-    tag type
-    case nothing: Empty
-enum QType ['none', 'qnull', 'qint', 'qstring', 'qdict', 'qlist', 'qfloat', 'qbool']
-    prefix QTYPE
-enum T ['nothing']
-object q_empty
Signature · 1 line
2.7.4
Reviewed-by on v1 37/47
#105 lore raw

Re: [Qemu-devel] [PATCH for-2.9 37/47] qapi: Fix detection of bogus member documentation

Quoted 7 lines · Markus Armbruster

check_definition_doc() checks for member documentation without a matching member. It laboriously second-guesses what members QAPISchema._def_exprs() will create. That's a stupid game.

Move the check into QAPISchema.check(), where the members are known. Delegate the actual checking to new QAPIDoc.check().

Quoted 7 lines
---
 scripts/qapi.py                             | 38 ++++++++++-------------------
 tests/qapi-schema/doc-bad-union-member.err  |  1 +
 tests/qapi-schema/doc-bad-union-member.exit |  2 +-
 tests/qapi-schema/doc-bad-union-member.out  | 11 ---------
 4 files changed, 15 insertions(+), 37 deletions(-)

Nice diffstat.

tests/qapi-schema/doc-bad-union-member.err line 1

Quoted 3 lines

+++ b/tests/qapi-schema/doc-bad-union-member.err

tests/qapi-schema/doc-bad-union-member.err +1 -0
@@ -0,0 +1 @@
+tests/qapi-schema/doc-bad-union-member.json:3: The following documented members are not in the declaration: a, b

Nice that you're able to report all problems within the doc, rather than stopping at the first. (Wish we could do the same about the overall .json file, but that's harder, and out of scope for this series)

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#106 lore raw

Re: [Qemu-devel] [PATCH for-2.9 37/47] qapi: Fix detection of bogus member documentation

Quoted 19 lines · Eric Blake
Quoted 7 lines · Markus Armbruster

check_definition_doc() checks for member documentation without a matching member. It laboriously second-guesses what members QAPISchema._def_exprs() will create. That's a stupid game.

Move the check into QAPISchema.check(), where the members are known. Delegate the actual checking to new QAPIDoc.check().

Quoted 7 lines
---
 scripts/qapi.py                             | 38 ++++++++++-------------------
 tests/qapi-schema/doc-bad-union-member.err  |  1 +
 tests/qapi-schema/doc-bad-union-member.exit |  2 +-
 tests/qapi-schema/doc-bad-union-member.out  | 11 ---------
 4 files changed, 15 insertions(+), 37 deletions(-)

Nice diffstat.

Quoted 7 lines

tests/qapi-schema/doc-bad-union-member.err line 1

Quoted 3 lines

+++ b/tests/qapi-schema/doc-bad-union-member.err

tests/qapi-schema/doc-bad-union-member.err +1 -0
@@ -0,0 +1 @@
+tests/qapi-schema/doc-bad-union-member.json:3: The following documented members are not in the declaration: a, b

Nice that you're able to report all problems within the doc, rather than stopping at the first. (Wish we could do the same about the overall .json file, but that's harder, and out of scope for this series)

Nice to have, but whether it would be worth the error recovery complications is doubtful.

Quoted 1 line

Thanks!

#107 lore raw

PATCH 38/47 qapi: Eliminate check_docs() and drop QAPIDoc.expr

In reply to Markus Armbruster

Move what's left in check_docs() to check_expr(). Delegate the actual checking to new QAPIDoc.check_expr().

QAPIDoc.expr is now unused; drop it.

---
 scripts/qapi.py | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
scripts/qapi.py +10 -17
index 0b0ba59..0da426a 100644
@@ -138,8 +138,6 @@ class QAPIDoc(object):
         self.sections = []
         # the current section
         self.section = self.body
-        # associated expression (to be set by expression parser)
-        self.expr = None
 
     def has_section(self, name):
         """Return True if we have a section with this name."""
@@ -249,6 +247,11 @@ class QAPIDoc(object):
             self.args[member.name] = QAPIDoc.ArgSection(member.name)
         self.args[member.name].connect(member)
 
+    def check_expr(self, expr):
+        if self.has_section('Returns') and 'command' not in expr:
+            raise QAPISemError(self.info,
+                               "'Returns:' is only valid for commands")
+
     def check(self):
         bogus = [name for name, section in self.args.iteritems()
                  if not section.member]
@@ -311,7 +314,6 @@ class QAPISchemaParser(object):
                         raise QAPISemError(
                             self.cur_doc.info,
                             "Expression documentation required")
-                    self.cur_doc.expr = expr
                     expr_elem['doc'] = self.cur_doc
                 self.exprs.append(expr_elem)
             self.cur_doc = None
@@ -979,6 +981,7 @@ def check_exprs(exprs):
     for expr_elem in exprs:
         expr = expr_elem['expr']
         info = expr_elem['info']
+        doc = expr_elem.get('doc')
 
         if 'enum' in expr:
             check_enum(expr, info)
@@ -995,22 +998,12 @@ def check_exprs(exprs):
         else:
             assert False, 'unexpected meta type'
 
+        if doc:
+            doc.check_expr(expr)
+
     return exprs
 
 
-def check_definition_doc(doc, expr, info):
-    if doc.has_section('Returns') and 'command' not in expr:
-        raise QAPISemError(info, "'Returns:' is only valid for commands")
-
-
-def check_docs(docs):
-    for doc in docs:
-        if doc.expr:
-            check_definition_doc(doc, doc.expr, doc.info)
-
-    return docs
-
-
 #
 # Schema compiler frontend
 #
@@ -1506,7 +1499,7 @@ class QAPISchema(object):
         try:
             parser = QAPISchemaParser(open(fname, 'r'))
             self.exprs = check_exprs(parser.exprs)
-            self.docs = check_docs(parser.docs)
+            self.docs = parser.docs
             self._entity_dict = {}
             self._predefining = True
             self._def_predefineds()
Signature · 1 line
2.7.4
Reviewed-by on v1 38/47
#108 lore raw

Re: [Qemu-devel] [PATCH for-2.9 38/47] qapi: Eliminate check_docs() and drop QAPIDoc.expr

Quoted 10 lines · Markus Armbruster

Move what's left in check_docs() to check_expr(). Delegate the actual checking to new QAPIDoc.check_expr().

QAPIDoc.expr is now unused; drop it.

---
 scripts/qapi.py | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)
Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#109 lore raw

PATCH 39/47 qapi: Drop unused variable events

In reply to Markus Armbruster

Missed in commit e98859a

---
 scripts/qapi.py | 3 ---
 1 file changed, 3 deletions(-)
scripts/qapi.py +0 -3
index 0da426a..12b1bda 100644
@@ -49,7 +49,6 @@ name_case_whitelist = []
 enum_types = []
 struct_types = []
 union_types = []
-events = []
 all_names = {}
 
 #
@@ -751,14 +750,12 @@ def check_command(expr, info):
 
 
 def check_event(expr, info):
-    global events
     name = expr['event']
     boxed = expr.get('boxed', False)
 
     meta = ['struct']
     if boxed:
         meta += ['union', 'alternate']
-    events.append(name)
     check_type(info, "'data' for event '%s'" % name,
                expr.get('data'), allow_dict=not boxed, allow_optional=True,
                allow_metas=meta)
Signature · 1 line
2.7.4