[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v9 09/17] qapi: Implement boxed types for comman
From: |
Markus Armbruster |
Subject: |
Re: [Qemu-devel] [PATCH v9 09/17] qapi: Implement boxed types for commands/events |
Date: |
Thu, 14 Jul 2016 16:26:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> writes:
> Turn on the ability to pass command and event arguments in
> a single boxed parameter, which must name a non-empty type
> (although the type can be a struct with all optional members).
> For structs, it makes it possible to pass a single qapi type
> instead of a breakout of all struct members (useful if the
> arguments are already in a struct or if the number of members
> is large); for other complex types, it is now possible to use
> a union or alternate as the data for a command or event.
>
> The empty type may be technically feasible if needed down the
> road, but it's easier to forbid it now and relax things to allow
> it later, than it is to allow it now and have to special case
> how the generated 'q_empty' type is handled (see commit 7ce106a9
> for reasons why nothing is generated for the empty type). An
> alternate type is never considered empty, but now that a boxed
> type can be either an object or an alternate, we have to provide
> a trivial QAPISchemaAlternateType.is_empty(). The new call to
> arg_type.is_empty() during QAPISchemaCommand.check() requires
> that we first check the type in question; but there is no chance
> of introducing a cycle since objects do not refer back to commands.
>
> We still have a split in syntax checking between ad-hoc parsing
> up front (merely validates that 'boxed' has a sane value) and
> during .check() methods (if 'boxed' is set, then 'data' must name
> a non-empty user-defined type).
>
> Generated code is unchanged, as long as no client uses the
> new feature.
>
> Signed-off-by: Eric Blake <address@hidden>
>
> ---
> v9: s/box/boxed/, formatting tweak, commit message improvements,
> restore assertions rather than relying on implicit checking
> v8: forbid empty type, allow alternates, improve docs
> v7: rebase to latest
> v6: retitle, rebase, and merge v5 40/46 and 41/46 into one patch
> ---
> scripts/qapi.py | 63
> ++++++++++++++++++++++++++-------
> scripts/qapi-commands.py | 3 +-
> scripts/qapi-event.py | 5 ++-
> tests/test-qmp-commands.c | 8 +++++
> docs/qapi-code-gen.txt | 27 ++++++++++++--
> tests/Makefile.include | 5 +++
> tests/qapi-schema/args-bad-box.err | 1 +
> tests/qapi-schema/args-bad-box.exit | 1 +
> tests/qapi-schema/args-bad-box.json | 2 ++
> tests/qapi-schema/args-bad-box.out | 0
> tests/qapi-schema/args-box-anon.err | 1 +
> tests/qapi-schema/args-box-anon.exit | 1 +
> tests/qapi-schema/args-box-anon.json | 2 ++
> tests/qapi-schema/args-box-anon.out | 0
> tests/qapi-schema/args-box-empty.err | 1 +
> tests/qapi-schema/args-box-empty.exit | 1 +
> tests/qapi-schema/args-box-empty.json | 3 ++
> tests/qapi-schema/args-box-empty.out | 0
> tests/qapi-schema/args-box-string.err | 1 +
> tests/qapi-schema/args-box-string.exit | 1 +
> tests/qapi-schema/args-box-string.json | 2 ++
> tests/qapi-schema/args-box-string.out | 0
> tests/qapi-schema/args-union.err | 2 +-
> tests/qapi-schema/args-union.json | 3 +-
> tests/qapi-schema/event-box-empty.err | 1 +
> tests/qapi-schema/event-box-empty.exit | 1 +
> tests/qapi-schema/event-box-empty.json | 2 ++
> tests/qapi-schema/event-box-empty.out | 0
> tests/qapi-schema/qapi-schema-test.json | 4 +++
> tests/qapi-schema/qapi-schema-test.out | 8 +++++
> 30 files changed, 129 insertions(+), 20 deletions(-)
> create mode 100644 tests/qapi-schema/args-bad-box.err
> create mode 100644 tests/qapi-schema/args-bad-box.exit
> create mode 100644 tests/qapi-schema/args-bad-box.json
> create mode 100644 tests/qapi-schema/args-bad-box.out
> create mode 100644 tests/qapi-schema/args-box-anon.err
> create mode 100644 tests/qapi-schema/args-box-anon.exit
> create mode 100644 tests/qapi-schema/args-box-anon.json
> create mode 100644 tests/qapi-schema/args-box-anon.out
> create mode 100644 tests/qapi-schema/args-box-empty.err
> create mode 100644 tests/qapi-schema/args-box-empty.exit
> create mode 100644 tests/qapi-schema/args-box-empty.json
> create mode 100644 tests/qapi-schema/args-box-empty.out
> create mode 100644 tests/qapi-schema/args-box-string.err
> create mode 100644 tests/qapi-schema/args-box-string.exit
> create mode 100644 tests/qapi-schema/args-box-string.json
> create mode 100644 tests/qapi-schema/args-box-string.out
> create mode 100644 tests/qapi-schema/event-box-empty.err
> create mode 100644 tests/qapi-schema/event-box-empty.exit
> create mode 100644 tests/qapi-schema/event-box-empty.json
> create mode 100644 tests/qapi-schema/event-box-empty.out
I'm inclined to change box to boxed in the test file names on commit.
What do you think?
[...]
> diff --git a/tests/qapi-schema/args-union.json
> b/tests/qapi-schema/args-union.json
> index 7bdcbb7..c0ce091 100644
> --- a/tests/qapi-schema/args-union.json
> +++ b/tests/qapi-schema/args-union.json
> @@ -1,4 +1,3 @@
> -# we do not allow union arguments
> -# TODO should we support this?
> +# use of union arguments requires 'box':true
You missed a box here. Can touch up on commit.
> { 'union': 'Uni', 'data': { 'case1': 'int', 'case2': 'str' } }
> { 'command': 'oops', 'data': 'Uni' }
[...]
- [Qemu-devel] [PATCH v9 03/17] qapi: Special case c_name() for empty type, (continued)
- [Qemu-devel] [PATCH v9 03/17] qapi: Special case c_name() for empty type, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 02/17] qapi: Require all branches of flat union enum to be covered, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 05/17] qapi: Add type.is_empty() helper, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 07/17] qapi-event: Simplify visit of non-implicit data, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 04/17] qapi: Hide tag_name data member of variants, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 06/17] qapi: Drop useless gen_err_check(), Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 08/17] qapi: Plumb in 'boxed' to qapi generator lower levels, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 01/17] net: use Netdev instead of NetClientOptions in client init, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 09/17] qapi: Implement boxed types for commands/events, Eric Blake, 2016/07/13
- Re: [Qemu-devel] [PATCH v9 09/17] qapi: Implement boxed types for commands/events,
Markus Armbruster <=
- [Qemu-devel] [PATCH v9 13/17] net: Use correct type for bool flag, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 11/17] block: Simplify drive-mirror, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 15/17] option: make parse_option_bool/number non-static, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 10/17] block: Simplify block_set_io_throttle, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 14/17] net: Complete qapi-fication of netdev_add, Eric Blake, 2016/07/13
- [Qemu-devel] [PATCH v9 16/17] qapi: Tweak QmpInputVisitor to optionally do string conversion, Eric Blake, 2016/07/13