]> git.proxmox.com Git - mirror_qemu.git/commit - tests/qapi-schema/args-if-implicit.err
qapi: Require boxed for conditional command and event arguments
authorMarkus Armbruster <armbru@redhat.com>
Thu, 16 Mar 2023 07:13:25 +0000 (08:13 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Mon, 24 Apr 2023 13:21:39 +0000 (15:21 +0200)
commitde3b3f529d453dfaa1f8b437c1a1f0766d8108e4
treec6b9dab2c6dceed6fa6012e969374a619e9a1778
parent713d921aed52a802c62f02dadd59da5a9f9466b1
qapi: Require boxed for conditional command and event arguments

The C code generator fails to honor 'if' conditions of command and
event arguments.

For instance, tests/qapi-schema/qapi-schema-test.json has

    { 'event': 'TEST_IF_EVENT',
      'data': { 'foo': 'TestIfStruct',
'bar': { 'type': ['str'], 'if': 'TEST_IF_EVT_ARG' } },
      'if': { 'all': ['TEST_IF_EVT', 'TEST_IF_STRUCT'] } }

Generated tests/test-qapi-events.h fails to honor the TEST_IF_EVT_ARG
condition:

    #if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)
    void qapi_event_send_test_if_event(TestIfStruct *foo, strList *bar);
    #endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */

Only uses so far are in tests/.

We could fix the generator to emit something like

    #if defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT)
    void qapi_event_send_test_if_event(TestIfStruct *foo
    #if defined(TEST_IF_EVT_ARG)
                    , strList *bar
    #endif
                    );
    #endif /* defined(TEST_IF_EVT) && defined(TEST_IF_STRUCT) */

Ugly.  Calls become similarly ugly.  Not worth fixing.

Conditional arguments work fine with 'boxed': true, simply because
complex types with conditional members work fine.  Not worth breaking.

Reject conditional arguments unless boxed.

Move the tests cases covering unboxed conditional arguments out of
tests/qapi-schema/qapi-schema-test.json.  Cover boxed conditional
arguments there instead.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20230316071325.492471-15-armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
16 files changed:
docs/devel/qapi-code-gen.rst
scripts/qapi/commands.py
scripts/qapi/gen.py
scripts/qapi/schema.py
tests/qapi-schema/args-if-implicit.err [new file with mode: 0644]
tests/qapi-schema/args-if-implicit.json [new file with mode: 0644]
tests/qapi-schema/args-if-implicit.out [new file with mode: 0644]
tests/qapi-schema/args-if-unboxed.err [new file with mode: 0644]
tests/qapi-schema/args-if-unboxed.json [new file with mode: 0644]
tests/qapi-schema/args-if-unboxed.out [new file with mode: 0644]
tests/qapi-schema/event-args-if-unboxed.err [new file with mode: 0644]
tests/qapi-schema/event-args-if-unboxed.json [new file with mode: 0644]
tests/qapi-schema/event-args-if-unboxed.out [new file with mode: 0644]
tests/qapi-schema/meson.build
tests/qapi-schema/qapi-schema-test.json
tests/qapi-schema/qapi-schema-test.out