[PATCH v4 0/8] qapi: Add support for aliases

Kevin Wolf posted 8 patches 2 years, 7 months ago
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20210917161320.201086-1-kwolf@redhat.com
Maintainers: Michael Roth <michael.roth@amd.com>, Markus Armbruster <armbru@redhat.com>, Peter Maydell <peter.maydell@linaro.org>
docs/devel/qapi-code-gen.rst                  | 109 ++++-
docs/sphinx/qapidoc.py                        |   2 +-
include/qapi/visitor-impl.h                   |  12 +
include/qapi/visitor.h                        |  59 ++-
qapi/qapi-visit-core.c                        |  22 +
qapi/qobject-input-visitor.c                  | 452 ++++++++++++++++--
tests/unit/test-qmp-cmds.c                    |  10 +
tests/unit/test-qobject-input-visitor.c       | 271 +++++++++++
scripts/qapi/expr.py                          |  54 ++-
scripts/qapi/schema.py                        | 117 ++++-
scripts/qapi/types.py                         |   4 +-
scripts/qapi/visit.py                         |  34 +-
tests/qapi-schema/test-qapi.py                |   7 +-
tests/qapi-schema/alias-bad-type.err          |   2 +
tests/qapi-schema/alias-bad-type.json         |   3 +
tests/qapi-schema/alias-bad-type.out          |   0
tests/qapi-schema/alias-missing-source.err    |   2 +
tests/qapi-schema/alias-missing-source.json   |   3 +
tests/qapi-schema/alias-missing-source.out    |   0
tests/qapi-schema/alias-name-bad-type.err     |   2 +
tests/qapi-schema/alias-name-bad-type.json    |   3 +
tests/qapi-schema/alias-name-bad-type.out     |   0
tests/qapi-schema/alias-name-conflict.err     |   2 +
tests/qapi-schema/alias-name-conflict.json    |   4 +
tests/qapi-schema/alias-name-conflict.out     |   0
tests/qapi-schema/alias-recursive.err         |   2 +
tests/qapi-schema/alias-recursive.json        |   4 +
tests/qapi-schema/alias-recursive.out         |   0
tests/qapi-schema/alias-source-bad-type.err   |   2 +
tests/qapi-schema/alias-source-bad-type.json  |   3 +
tests/qapi-schema/alias-source-bad-type.out   |   0
.../alias-source-elem-bad-type.err            |   2 +
.../alias-source-elem-bad-type.json           |   3 +
.../alias-source-elem-bad-type.out            |   0
tests/qapi-schema/alias-source-empty.err      |   2 +
tests/qapi-schema/alias-source-empty.json     |   3 +
tests/qapi-schema/alias-source-empty.out      |   0
.../alias-source-inexistent-variants.err      |   2 +
.../alias-source-inexistent-variants.json     |  12 +
.../alias-source-inexistent-variants.out      |   0
tests/qapi-schema/alias-source-inexistent.err |   2 +
.../qapi-schema/alias-source-inexistent.json  |   3 +
tests/qapi-schema/alias-source-inexistent.out |   0
.../alias-source-non-object-path.err          |   2 +
.../alias-source-non-object-path.json         |   3 +
.../alias-source-non-object-path.out          |   0
.../alias-source-non-object-wildcard.err      |   2 +
.../alias-source-non-object-wildcard.json     |   3 +
.../alias-source-non-object-wildcard.out      |   0
...lias-source-optional-wildcard-indirect.err |   2 +
...ias-source-optional-wildcard-indirect.json |   6 +
...lias-source-optional-wildcard-indirect.out |   0
.../alias-source-optional-wildcard.err        |   2 +
.../alias-source-optional-wildcard.json       |   5 +
.../alias-source-optional-wildcard.out        |   0
tests/qapi-schema/alias-unknown-key.err       |   3 +
tests/qapi-schema/alias-unknown-key.json      |   3 +
tests/qapi-schema/alias-unknown-key.out       |   0
tests/qapi-schema/aliases-bad-type.err        |   2 +
tests/qapi-schema/aliases-bad-type.json       |   3 +
tests/qapi-schema/aliases-bad-type.out        |   0
tests/qapi-schema/meson.build                 |  16 +
tests/qapi-schema/qapi-schema-test.json       |  35 ++
tests/qapi-schema/qapi-schema-test.out        |  44 ++
tests/qapi-schema/unknown-expr-key.err        |   2 +-
65 files changed, 1290 insertions(+), 57 deletions(-)
create mode 100644 tests/qapi-schema/alias-bad-type.err
create mode 100644 tests/qapi-schema/alias-bad-type.json
create mode 100644 tests/qapi-schema/alias-bad-type.out
create mode 100644 tests/qapi-schema/alias-missing-source.err
create mode 100644 tests/qapi-schema/alias-missing-source.json
create mode 100644 tests/qapi-schema/alias-missing-source.out
create mode 100644 tests/qapi-schema/alias-name-bad-type.err
create mode 100644 tests/qapi-schema/alias-name-bad-type.json
create mode 100644 tests/qapi-schema/alias-name-bad-type.out
create mode 100644 tests/qapi-schema/alias-name-conflict.err
create mode 100644 tests/qapi-schema/alias-name-conflict.json
create mode 100644 tests/qapi-schema/alias-name-conflict.out
create mode 100644 tests/qapi-schema/alias-recursive.err
create mode 100644 tests/qapi-schema/alias-recursive.json
create mode 100644 tests/qapi-schema/alias-recursive.out
create mode 100644 tests/qapi-schema/alias-source-bad-type.err
create mode 100644 tests/qapi-schema/alias-source-bad-type.json
create mode 100644 tests/qapi-schema/alias-source-bad-type.out
create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.err
create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.json
create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.out
create mode 100644 tests/qapi-schema/alias-source-empty.err
create mode 100644 tests/qapi-schema/alias-source-empty.json
create mode 100644 tests/qapi-schema/alias-source-empty.out
create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.err
create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.json
create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.out
create mode 100644 tests/qapi-schema/alias-source-inexistent.err
create mode 100644 tests/qapi-schema/alias-source-inexistent.json
create mode 100644 tests/qapi-schema/alias-source-inexistent.out
create mode 100644 tests/qapi-schema/alias-source-non-object-path.err
create mode 100644 tests/qapi-schema/alias-source-non-object-path.json
create mode 100644 tests/qapi-schema/alias-source-non-object-path.out
create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.err
create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.json
create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.out
create mode 100644 tests/qapi-schema/alias-source-optional-wildcard-indirect.err
create mode 100644 tests/qapi-schema/alias-source-optional-wildcard-indirect.json
create mode 100644 tests/qapi-schema/alias-source-optional-wildcard-indirect.out
create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.err
create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.json
create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.out
create mode 100644 tests/qapi-schema/alias-unknown-key.err
create mode 100644 tests/qapi-schema/alias-unknown-key.json
create mode 100644 tests/qapi-schema/alias-unknown-key.out
create mode 100644 tests/qapi-schema/aliases-bad-type.err
create mode 100644 tests/qapi-schema/aliases-bad-type.json
create mode 100644 tests/qapi-schema/aliases-bad-type.out
[PATCH v4 0/8] qapi: Add support for aliases
Posted by Kevin Wolf 2 years, 7 months ago
This series introduces alias definitions for QAPI object types (structs
and unions).

This allows using the same QAPI type and visitor even when the syntax
has some variations between different external interfaces such as QMP
and the command line.

It also provides a new tool for evolving the schema while maintaining
backwards compatibility (possibly during a deprecation period).

The first user is intended to be a QAPIfied -chardev command line
option, for which I'll send a separate series. A git tag is available
that contains both this series and the chardev changes that make use of
it:

    https://repo.or.cz/qemu/kevin.git qapi-alias-chardev-v4

v4:
- Make sure to keep a defined order of aliases in StackObject.aliases
- Added patch 4 to allow for better error messages when wildcard aliases
  provide a second value for a member, which may or may not be consumed
  elsewhere.
- Resolve chained aliases only once instead of just checking that they
  can be resolved while looking for matching aliases, and actually
  resolving them at the end. This is not only a code simplification, but
  actually necessary for correct error messages on conflicts.
- Separate schema.py cleanup patch by Markus ('qapi: Revert an
  accidental change from list to view object')
- Fixed alias name checks in the QAPI generator
- Changed check_path() to avoid modifying its 'path' parameter
- Some more test cases
- Coding style fixes
- Documentation improvements

v3:
- Mention the new functions in the big comment in visitor.h. However,
  since the comment is about users of the visitor rather than the
  generated code, it seems like to wrong place to go into details.
- Updated commit message for patch 3 ('Simplify full_name_nth() ...')
- Patch 4 ('qapi: Apply aliases in qobject-input-visitor'):
    - Multiple matching wildcard aliases are considered conflicting now
    - Improved comments for several functions
    - Renamed bool *implicit_object into *is_alias_prefix, which
      describes better what it is rather than what it is used for
    - Simplified alias_present() into input_present()
    - Fixed potential use of wrong StackObject in error message
- Patch 5 ('qapi: Add support for aliases'):
    - Made QAPISchemaAlias a QAPISchemaMember
    - Check validity of alias source paths (must exist in at least one
      variant, no optional objects in the path of a wildcard alias, no
      alias loops)
- Many new tests cases, both positive and negative, including unit tests
  of the generated visit functions
- Coding style changes
- Rebased documentation (.txt -> .rst conversion in master)

v2:
- Renamed 'alias' to 'name' in all data structures describing aliases
- Tons of new or changed comments and other documentation
- Be more explicit that empty 'source' is invalid and assert it
- Fixed full_name_so() for lists (added a parameter to tell the function
  whether the name of a list member or the list itself is meant)
- Changed some QAPI generator error messages
- Assert the type of parameters in QAPISchemaAlias.__init__()

Kevin Wolf (7):
  qapi: Add interfaces for alias support to Visitor
  qapi: Remember alias definitions in qobject-input-visitor
  qapi: Simplify full_name_nth() in qobject-input-visitor
  qapi: Store Error in StackObject.h for qobject-input-visitor
  qapi: Apply aliases in qobject-input-visitor
  qapi: Add support for aliases
  tests/qapi-schema: Test cases for aliases

Markus Armbruster (1):
  qapi: Revert an accidental change from list to view object

 docs/devel/qapi-code-gen.rst                  | 109 ++++-
 docs/sphinx/qapidoc.py                        |   2 +-
 include/qapi/visitor-impl.h                   |  12 +
 include/qapi/visitor.h                        |  59 ++-
 qapi/qapi-visit-core.c                        |  22 +
 qapi/qobject-input-visitor.c                  | 452 ++++++++++++++++--
 tests/unit/test-qmp-cmds.c                    |  10 +
 tests/unit/test-qobject-input-visitor.c       | 271 +++++++++++
 scripts/qapi/expr.py                          |  54 ++-
 scripts/qapi/schema.py                        | 117 ++++-
 scripts/qapi/types.py                         |   4 +-
 scripts/qapi/visit.py                         |  34 +-
 tests/qapi-schema/test-qapi.py                |   7 +-
 tests/qapi-schema/alias-bad-type.err          |   2 +
 tests/qapi-schema/alias-bad-type.json         |   3 +
 tests/qapi-schema/alias-bad-type.out          |   0
 tests/qapi-schema/alias-missing-source.err    |   2 +
 tests/qapi-schema/alias-missing-source.json   |   3 +
 tests/qapi-schema/alias-missing-source.out    |   0
 tests/qapi-schema/alias-name-bad-type.err     |   2 +
 tests/qapi-schema/alias-name-bad-type.json    |   3 +
 tests/qapi-schema/alias-name-bad-type.out     |   0
 tests/qapi-schema/alias-name-conflict.err     |   2 +
 tests/qapi-schema/alias-name-conflict.json    |   4 +
 tests/qapi-schema/alias-name-conflict.out     |   0
 tests/qapi-schema/alias-recursive.err         |   2 +
 tests/qapi-schema/alias-recursive.json        |   4 +
 tests/qapi-schema/alias-recursive.out         |   0
 tests/qapi-schema/alias-source-bad-type.err   |   2 +
 tests/qapi-schema/alias-source-bad-type.json  |   3 +
 tests/qapi-schema/alias-source-bad-type.out   |   0
 .../alias-source-elem-bad-type.err            |   2 +
 .../alias-source-elem-bad-type.json           |   3 +
 .../alias-source-elem-bad-type.out            |   0
 tests/qapi-schema/alias-source-empty.err      |   2 +
 tests/qapi-schema/alias-source-empty.json     |   3 +
 tests/qapi-schema/alias-source-empty.out      |   0
 .../alias-source-inexistent-variants.err      |   2 +
 .../alias-source-inexistent-variants.json     |  12 +
 .../alias-source-inexistent-variants.out      |   0
 tests/qapi-schema/alias-source-inexistent.err |   2 +
 .../qapi-schema/alias-source-inexistent.json  |   3 +
 tests/qapi-schema/alias-source-inexistent.out |   0
 .../alias-source-non-object-path.err          |   2 +
 .../alias-source-non-object-path.json         |   3 +
 .../alias-source-non-object-path.out          |   0
 .../alias-source-non-object-wildcard.err      |   2 +
 .../alias-source-non-object-wildcard.json     |   3 +
 .../alias-source-non-object-wildcard.out      |   0
 ...lias-source-optional-wildcard-indirect.err |   2 +
 ...ias-source-optional-wildcard-indirect.json |   6 +
 ...lias-source-optional-wildcard-indirect.out |   0
 .../alias-source-optional-wildcard.err        |   2 +
 .../alias-source-optional-wildcard.json       |   5 +
 .../alias-source-optional-wildcard.out        |   0
 tests/qapi-schema/alias-unknown-key.err       |   3 +
 tests/qapi-schema/alias-unknown-key.json      |   3 +
 tests/qapi-schema/alias-unknown-key.out       |   0
 tests/qapi-schema/aliases-bad-type.err        |   2 +
 tests/qapi-schema/aliases-bad-type.json       |   3 +
 tests/qapi-schema/aliases-bad-type.out        |   0
 tests/qapi-schema/meson.build                 |  16 +
 tests/qapi-schema/qapi-schema-test.json       |  35 ++
 tests/qapi-schema/qapi-schema-test.out        |  44 ++
 tests/qapi-schema/unknown-expr-key.err        |   2 +-
 65 files changed, 1290 insertions(+), 57 deletions(-)
 create mode 100644 tests/qapi-schema/alias-bad-type.err
 create mode 100644 tests/qapi-schema/alias-bad-type.json
 create mode 100644 tests/qapi-schema/alias-bad-type.out
 create mode 100644 tests/qapi-schema/alias-missing-source.err
 create mode 100644 tests/qapi-schema/alias-missing-source.json
 create mode 100644 tests/qapi-schema/alias-missing-source.out
 create mode 100644 tests/qapi-schema/alias-name-bad-type.err
 create mode 100644 tests/qapi-schema/alias-name-bad-type.json
 create mode 100644 tests/qapi-schema/alias-name-bad-type.out
 create mode 100644 tests/qapi-schema/alias-name-conflict.err
 create mode 100644 tests/qapi-schema/alias-name-conflict.json
 create mode 100644 tests/qapi-schema/alias-name-conflict.out
 create mode 100644 tests/qapi-schema/alias-recursive.err
 create mode 100644 tests/qapi-schema/alias-recursive.json
 create mode 100644 tests/qapi-schema/alias-recursive.out
 create mode 100644 tests/qapi-schema/alias-source-bad-type.err
 create mode 100644 tests/qapi-schema/alias-source-bad-type.json
 create mode 100644 tests/qapi-schema/alias-source-bad-type.out
 create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.err
 create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.json
 create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.out
 create mode 100644 tests/qapi-schema/alias-source-empty.err
 create mode 100644 tests/qapi-schema/alias-source-empty.json
 create mode 100644 tests/qapi-schema/alias-source-empty.out
 create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.err
 create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.json
 create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.out
 create mode 100644 tests/qapi-schema/alias-source-inexistent.err
 create mode 100644 tests/qapi-schema/alias-source-inexistent.json
 create mode 100644 tests/qapi-schema/alias-source-inexistent.out
 create mode 100644 tests/qapi-schema/alias-source-non-object-path.err
 create mode 100644 tests/qapi-schema/alias-source-non-object-path.json
 create mode 100644 tests/qapi-schema/alias-source-non-object-path.out
 create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.err
 create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.json
 create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.out
 create mode 100644 tests/qapi-schema/alias-source-optional-wildcard-indirect.err
 create mode 100644 tests/qapi-schema/alias-source-optional-wildcard-indirect.json
 create mode 100644 tests/qapi-schema/alias-source-optional-wildcard-indirect.out
 create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.err
 create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.json
 create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.out
 create mode 100644 tests/qapi-schema/alias-unknown-key.err
 create mode 100644 tests/qapi-schema/alias-unknown-key.json
 create mode 100644 tests/qapi-schema/alias-unknown-key.out
 create mode 100644 tests/qapi-schema/aliases-bad-type.err
 create mode 100644 tests/qapi-schema/aliases-bad-type.json
 create mode 100644 tests/qapi-schema/aliases-bad-type.out

-- 
2.31.1


Re: [PATCH v4 0/8] qapi: Add support for aliases
Posted by Kevin Wolf 2 years, 6 months ago
Am 17.09.2021 um 18:13 hat Kevin Wolf geschrieben:
> This series introduces alias definitions for QAPI object types (structs
> and unions).
> 
> This allows using the same QAPI type and visitor even when the syntax
> has some variations between different external interfaces such as QMP
> and the command line.
> 
> It also provides a new tool for evolving the schema while maintaining
> backwards compatibility (possibly during a deprecation period).
> 
> The first user is intended to be a QAPIfied -chardev command line
> option, for which I'll send a separate series. A git tag is available
> that contains both this series and the chardev changes that make use of
> it:
> 
>     https://repo.or.cz/qemu/kevin.git qapi-alias-chardev-v4
> 
> v4:
> - Make sure to keep a defined order of aliases in StackObject.aliases
> - Added patch 4 to allow for better error messages when wildcard aliases
>   provide a second value for a member, which may or may not be consumed
>   elsewhere.
> - Resolve chained aliases only once instead of just checking that they
>   can be resolved while looking for matching aliases, and actually
>   resolving them at the end. This is not only a code simplification, but
>   actually necessary for correct error messages on conflicts.
> - Separate schema.py cleanup patch by Markus ('qapi: Revert an
>   accidental change from list to view object')
> - Fixed alias name checks in the QAPI generator
> - Changed check_path() to avoid modifying its 'path' parameter
> - Some more test cases
> - Coding style fixes
> - Documentation improvements

ping


Re: [PATCH v4 0/8] qapi: Add support for aliases
Posted by John Snow 2 years, 6 months ago
On Fri, Sep 17, 2021 at 12:13 PM Kevin Wolf <kwolf@redhat.com> wrote:

> This series introduces alias definitions for QAPI object types (structs
> and unions).
>
> This allows using the same QAPI type and visitor even when the syntax
> has some variations between different external interfaces such as QMP
> and the command line.
>
>
I'm absurdly late to the party here, and I'm afraid my involvement may only
stall your progress even further, but ... can you fill me in on the
slightly-less-higher-level details here?

I'm curious as to the nature of "has some variations" and how the aliases
help alleviate them. Do you accomplish that compatibility by using
different names for different fields of the struct?

so e.g. x.foo can be used as an alias for x.bar, but both map ultimately
onto 'x.foo'? Or does this series provide for some more fundamental
mechanical changes to map one type onto another?


> It also provides a new tool for evolving the schema while maintaining
> backwards compatibility (possibly during a deprecation period).
>
> The first user is intended to be a QAPIfied -chardev command line
> option, for which I'll send a separate series. A git tag is available
> that contains both this series and the chardev changes that make use of
> it:
>
>     https://repo.or.cz/qemu/kevin.git qapi-alias-chardev-v4
>
>
v4:
> - Make sure to keep a defined order of aliases in StackObject.aliases
> - Added patch 4 to allow for better error messages when wildcard aliases
>   provide a second value for a member, which may or may not be consumed
>   elsewhere.
> - Resolve chained aliases only once instead of just checking that they
>   can be resolved while looking for matching aliases, and actually
>   resolving them at the end. This is not only a code simplification, but
>   actually necessary for correct error messages on conflicts.
> - Separate schema.py cleanup patch by Markus ('qapi: Revert an
>   accidental change from list to view object')
> - Fixed alias name checks in the QAPI generator
> - Changed check_path() to avoid modifying its 'path' parameter
> - Some more test cases
> - Coding style fixes
> - Documentation improvements
>
> v3:
> - Mention the new functions in the big comment in visitor.h. However,
>   since the comment is about users of the visitor rather than the
>   generated code, it seems like to wrong place to go into details.
> - Updated commit message for patch 3 ('Simplify full_name_nth() ...')
> - Patch 4 ('qapi: Apply aliases in qobject-input-visitor'):
>     - Multiple matching wildcard aliases are considered conflicting now
>     - Improved comments for several functions
>     - Renamed bool *implicit_object into *is_alias_prefix, which
>       describes better what it is rather than what it is used for
>     - Simplified alias_present() into input_present()
>     - Fixed potential use of wrong StackObject in error message
> - Patch 5 ('qapi: Add support for aliases'):
>     - Made QAPISchemaAlias a QAPISchemaMember
>     - Check validity of alias source paths (must exist in at least one
>       variant, no optional objects in the path of a wildcard alias, no
>       alias loops)
> - Many new tests cases, both positive and negative, including unit tests
>   of the generated visit functions
> - Coding style changes
> - Rebased documentation (.txt -> .rst conversion in master)
>
> v2:
> - Renamed 'alias' to 'name' in all data structures describing aliases
> - Tons of new or changed comments and other documentation
> - Be more explicit that empty 'source' is invalid and assert it
> - Fixed full_name_so() for lists (added a parameter to tell the function
>   whether the name of a list member or the list itself is meant)
> - Changed some QAPI generator error messages
> - Assert the type of parameters in QAPISchemaAlias.__init__()
>
> Kevin Wolf (7):
>   qapi: Add interfaces for alias support to Visitor
>   qapi: Remember alias definitions in qobject-input-visitor
>   qapi: Simplify full_name_nth() in qobject-input-visitor
>   qapi: Store Error in StackObject.h for qobject-input-visitor
>   qapi: Apply aliases in qobject-input-visitor
>   qapi: Add support for aliases
>   tests/qapi-schema: Test cases for aliases
>
> Markus Armbruster (1):
>   qapi: Revert an accidental change from list to view object
>
>  docs/devel/qapi-code-gen.rst                  | 109 ++++-
>  docs/sphinx/qapidoc.py                        |   2 +-
>  include/qapi/visitor-impl.h                   |  12 +
>  include/qapi/visitor.h                        |  59 ++-
>  qapi/qapi-visit-core.c                        |  22 +
>  qapi/qobject-input-visitor.c                  | 452 ++++++++++++++++--
>  tests/unit/test-qmp-cmds.c                    |  10 +
>  tests/unit/test-qobject-input-visitor.c       | 271 +++++++++++
>  scripts/qapi/expr.py                          |  54 ++-
>  scripts/qapi/schema.py                        | 117 ++++-
>  scripts/qapi/types.py                         |   4 +-
>  scripts/qapi/visit.py                         |  34 +-
>  tests/qapi-schema/test-qapi.py                |   7 +-
>  tests/qapi-schema/alias-bad-type.err          |   2 +
>  tests/qapi-schema/alias-bad-type.json         |   3 +
>  tests/qapi-schema/alias-bad-type.out          |   0
>  tests/qapi-schema/alias-missing-source.err    |   2 +
>  tests/qapi-schema/alias-missing-source.json   |   3 +
>  tests/qapi-schema/alias-missing-source.out    |   0
>  tests/qapi-schema/alias-name-bad-type.err     |   2 +
>  tests/qapi-schema/alias-name-bad-type.json    |   3 +
>  tests/qapi-schema/alias-name-bad-type.out     |   0
>  tests/qapi-schema/alias-name-conflict.err     |   2 +
>  tests/qapi-schema/alias-name-conflict.json    |   4 +
>  tests/qapi-schema/alias-name-conflict.out     |   0
>  tests/qapi-schema/alias-recursive.err         |   2 +
>  tests/qapi-schema/alias-recursive.json        |   4 +
>  tests/qapi-schema/alias-recursive.out         |   0
>  tests/qapi-schema/alias-source-bad-type.err   |   2 +
>  tests/qapi-schema/alias-source-bad-type.json  |   3 +
>  tests/qapi-schema/alias-source-bad-type.out   |   0
>  .../alias-source-elem-bad-type.err            |   2 +
>  .../alias-source-elem-bad-type.json           |   3 +
>  .../alias-source-elem-bad-type.out            |   0
>  tests/qapi-schema/alias-source-empty.err      |   2 +
>  tests/qapi-schema/alias-source-empty.json     |   3 +
>  tests/qapi-schema/alias-source-empty.out      |   0
>  .../alias-source-inexistent-variants.err      |   2 +
>  .../alias-source-inexistent-variants.json     |  12 +
>  .../alias-source-inexistent-variants.out      |   0
>  tests/qapi-schema/alias-source-inexistent.err |   2 +
>  .../qapi-schema/alias-source-inexistent.json  |   3 +
>  tests/qapi-schema/alias-source-inexistent.out |   0
>  .../alias-source-non-object-path.err          |   2 +
>  .../alias-source-non-object-path.json         |   3 +
>  .../alias-source-non-object-path.out          |   0
>  .../alias-source-non-object-wildcard.err      |   2 +
>  .../alias-source-non-object-wildcard.json     |   3 +
>  .../alias-source-non-object-wildcard.out      |   0
>  ...lias-source-optional-wildcard-indirect.err |   2 +
>  ...ias-source-optional-wildcard-indirect.json |   6 +
>  ...lias-source-optional-wildcard-indirect.out |   0
>  .../alias-source-optional-wildcard.err        |   2 +
>  .../alias-source-optional-wildcard.json       |   5 +
>  .../alias-source-optional-wildcard.out        |   0
>  tests/qapi-schema/alias-unknown-key.err       |   3 +
>  tests/qapi-schema/alias-unknown-key.json      |   3 +
>  tests/qapi-schema/alias-unknown-key.out       |   0
>  tests/qapi-schema/aliases-bad-type.err        |   2 +
>  tests/qapi-schema/aliases-bad-type.json       |   3 +
>  tests/qapi-schema/aliases-bad-type.out        |   0
>  tests/qapi-schema/meson.build                 |  16 +
>  tests/qapi-schema/qapi-schema-test.json       |  35 ++
>  tests/qapi-schema/qapi-schema-test.out        |  44 ++
>  tests/qapi-schema/unknown-expr-key.err        |   2 +-
>  65 files changed, 1290 insertions(+), 57 deletions(-)
>  create mode 100644 tests/qapi-schema/alias-bad-type.err
>  create mode 100644 tests/qapi-schema/alias-bad-type.json
>  create mode 100644 tests/qapi-schema/alias-bad-type.out
>  create mode 100644 tests/qapi-schema/alias-missing-source.err
>  create mode 100644 tests/qapi-schema/alias-missing-source.json
>  create mode 100644 tests/qapi-schema/alias-missing-source.out
>  create mode 100644 tests/qapi-schema/alias-name-bad-type.err
>  create mode 100644 tests/qapi-schema/alias-name-bad-type.json
>  create mode 100644 tests/qapi-schema/alias-name-bad-type.out
>  create mode 100644 tests/qapi-schema/alias-name-conflict.err
>  create mode 100644 tests/qapi-schema/alias-name-conflict.json
>  create mode 100644 tests/qapi-schema/alias-name-conflict.out
>  create mode 100644 tests/qapi-schema/alias-recursive.err
>  create mode 100644 tests/qapi-schema/alias-recursive.json
>  create mode 100644 tests/qapi-schema/alias-recursive.out
>  create mode 100644 tests/qapi-schema/alias-source-bad-type.err
>  create mode 100644 tests/qapi-schema/alias-source-bad-type.json
>  create mode 100644 tests/qapi-schema/alias-source-bad-type.out
>  create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.err
>  create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.json
>  create mode 100644 tests/qapi-schema/alias-source-elem-bad-type.out
>  create mode 100644 tests/qapi-schema/alias-source-empty.err
>  create mode 100644 tests/qapi-schema/alias-source-empty.json
>  create mode 100644 tests/qapi-schema/alias-source-empty.out
>  create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.err
>  create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.json
>  create mode 100644 tests/qapi-schema/alias-source-inexistent-variants.out
>  create mode 100644 tests/qapi-schema/alias-source-inexistent.err
>  create mode 100644 tests/qapi-schema/alias-source-inexistent.json
>  create mode 100644 tests/qapi-schema/alias-source-inexistent.out
>  create mode 100644 tests/qapi-schema/alias-source-non-object-path.err
>  create mode 100644 tests/qapi-schema/alias-source-non-object-path.json
>  create mode 100644 tests/qapi-schema/alias-source-non-object-path.out
>  create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.err
>  create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.json
>  create mode 100644 tests/qapi-schema/alias-source-non-object-wildcard.out
>  create mode 100644
> tests/qapi-schema/alias-source-optional-wildcard-indirect.err
>  create mode 100644
> tests/qapi-schema/alias-source-optional-wildcard-indirect.json
>  create mode 100644
> tests/qapi-schema/alias-source-optional-wildcard-indirect.out
>  create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.err
>  create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.json
>  create mode 100644 tests/qapi-schema/alias-source-optional-wildcard.out
>  create mode 100644 tests/qapi-schema/alias-unknown-key.err
>  create mode 100644 tests/qapi-schema/alias-unknown-key.json
>  create mode 100644 tests/qapi-schema/alias-unknown-key.out
>  create mode 100644 tests/qapi-schema/aliases-bad-type.err
>  create mode 100644 tests/qapi-schema/aliases-bad-type.json
>  create mode 100644 tests/qapi-schema/aliases-bad-type.out
>
> --
> 2.31.1
>
>
Re: [PATCH v4 0/8] qapi: Add support for aliases
Posted by Kevin Wolf 2 years, 6 months ago
Am 26.10.2021 um 23:23 hat John Snow geschrieben:
> On Fri, Sep 17, 2021 at 12:13 PM Kevin Wolf <kwolf@redhat.com> wrote:
> 
> > This series introduces alias definitions for QAPI object types (structs
> > and unions).
> >
> > This allows using the same QAPI type and visitor even when the syntax
> > has some variations between different external interfaces such as QMP
> > and the command line.
> >
> >
> I'm absurdly late to the party here, and I'm afraid my involvement may only
> stall your progress even further, but ...

I'm not sure if it's worth investing much of your time in this. After a
year of discussing implementation details, Markus decided that he
doesn't like the whole approach, so the series is probably dead in this
shape. Maybe parts of it (possibly even large parts) can be saved and
used in a modified approach, depending on how radically different the
new approach is.

Markus promised that he'll think of alternative approaches to solve the
problem. I'm waiting for that before I waste more time implementing
something else that is also dead from the start.

> can you fill me in on the slightly-less-higher-level details here?
> 
> I'm curious as to the nature of "has some variations" and how the aliases
> help alleviate them. Do you accomplish that compatibility by using
> different names for different fields of the struct?

> so e.g. x.foo can be used as an alias for x.bar, but both map ultimately
> onto 'x.foo'? Or does this series provide for some more fundamental
> mechanical changes to map one type onto another?

I would recommend reading the changes to docs/devel/qapi-code-gen.rst in
patch 7, which explain the implemented mechanism.

For -chardev, most of "some varations" are different names for the same
member of a struct, or nesting in QMP that you don't want to have on the
command line. I went through all cases in one of the last messages in
the v3 thread, but I think these are the two important categories of
cases.

The C types stay the same as they have always been, aliases just provide
an alternative way to specify the same thing in the input.

> > It also provides a new tool for evolving the schema while maintaining
> > backwards compatibility (possibly during a deprecation period).
> >
> > The first user is intended to be a QAPIfied -chardev command line
> > option, for which I'll send a separate series. A git tag is available
> > that contains both this series and the chardev changes that make use of
> > it:
> >
> >     https://repo.or.cz/qemu/kevin.git qapi-alias-chardev-v4

You may also want to have a look at this, and specifically
qapi/char.json, to see how I used aliases in practice.

Kevin


Re: [PATCH v4 0/8] qapi: Add support for aliases
Posted by John Snow 2 years, 6 months ago
On Wed, Oct 27, 2021 at 6:31 AM Kevin Wolf <kwolf@redhat.com> wrote:

> Am 26.10.2021 um 23:23 hat John Snow geschrieben:
> > On Fri, Sep 17, 2021 at 12:13 PM Kevin Wolf <kwolf@redhat.com> wrote:
> >
> > > This series introduces alias definitions for QAPI object types (structs
> > > and unions).
> > >
> > > This allows using the same QAPI type and visitor even when the syntax
> > > has some variations between different external interfaces such as QMP
> > > and the command line.
> > >
> > >
> > I'm absurdly late to the party here, and I'm afraid my involvement may
> only
> > stall your progress even further, but ...
>
> I'm not sure if it's worth investing much of your time in this. After a
>

ACK, understood. Still, I had this on my review pile for a while and I want
to know what problem we're trying to solve, and why Markus wasn't
enthralled by it.


> year of discussing implementation details, Markus decided that he
> doesn't like the whole approach, so the series is probably dead in this
> shape. Maybe parts of it (possibly even large parts) can be saved and
> used in a modified approach, depending on how radically different the
> new approach is.
>
> Markus promised that he'll think of alternative approaches to solve the
> problem. I'm waiting for that before I waste more time implementing
> something else that is also dead from the start.
>
> > can you fill me in on the slightly-less-higher-level details here?
> >
> > I'm curious as to the nature of "has some variations" and how the aliases
> > help alleviate them. Do you accomplish that compatibility by using
> > different names for different fields of the struct?
>
> > so e.g. x.foo can be used as an alias for x.bar, but both map ultimately
> > onto 'x.foo'? Or does this series provide for some more fundamental
> > mechanical changes to map one type onto another?
>
> I would recommend reading the changes to docs/devel/qapi-code-gen.rst in
> patch 7, which explain the implemented mechanism.
>
> For -chardev, most of "some varations" are different names for the same
> member of a struct, or nesting in QMP that you don't want to have on the
> command line. I went through all cases in one of the last messages in
> the v3 thread, but I think these are the two important categories of
> cases.
>
> The C types stay the same as they have always been, aliases just provide
> an alternative way to specify the same thing in the input.
>
>
Thanks very much for the pointers!


> > > It also provides a new tool for evolving the schema while maintaining
> > > backwards compatibility (possibly during a deprecation period).
> > >
> > > The first user is intended to be a QAPIfied -chardev command line
> > > option, for which I'll send a separate series. A git tag is available
> > > that contains both this series and the chardev changes that make use of
> > > it:
> > >
> > >     https://repo.or.cz/qemu/kevin.git qapi-alias-chardev-v4
>
> You may also want to have a look at this, and specifically
> qapi/char.json, to see how I used aliases in practice.
>
> Kevin
>
>