| 636c96cd | 11-Jul-2025 |
John Snow <jsnow@redhat.com> |
qapi: Fix undocumented return values by generating something
Generated command documentation lacks information on return value in several cases, e.g. query-tpm.
The obvious fix would be to require
qapi: Fix undocumented return values by generating something
Generated command documentation lacks information on return value in several cases, e.g. query-tpm.
The obvious fix would be to require a Returns: section when a command returns something.
However, note that many existing Returns: sections are pretty useless: the description is basically the return type, which then gets rendered like "Return: <Type> – <basically the return type>". This suggests that a description is often not really necessary, and requiring one isn't useful.
Instead, generate the obvious minimal thing when Returns: is absent: "Return: <Type>".
This auto-generated Return documentation is placed is as follows:
1. If we have arguments, return goes right after them. 2. Else if we have errors, return goes right before them. 3. Else if we have features, return goes right before them. 4. Else return goes right after the intro
To facilitate this algorithm, a "TODO:" hack line is used to separate the intro from the remainder of the documentation block in cases where there are no other sections to separate the intro from e.g. examples and additional detail meant to appear below the key sections of interest.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250711051045.51110-3-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [_insert_near_kind() code replaced by something simpler, commit message amended to explain why we're doing this] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 62c4dc4b | 18-Jun-2025 |
John Snow <jsnow@redhat.com> |
qapi: lift restriction on using '=' in doc blocks
We reject lines starting with '=' in definition documentation. This made sense when such lines were headings in free-form documentation, but not in
qapi: lift restriction on using '=' in doc blocks
We reject lines starting with '=' in definition documentation. This made sense when such lines were headings in free-form documentation, but not in definition documentation.
Before the previous commit, lines starting with '=' were headings in free-form documentation, and rejected in definition documentation, where such headings could not work.
The previous commit dropped the headings feature from free-form documentation, because we can simply use plain rST headings. Rejecting them in definition documentation no longer makes sense, so drop that, too.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250618165353.1980365-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Amend commit message to explain why] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 678868ee | 04-Jun-2025 |
John Snow <jsnow@redhat.com> |
qapi: delete un-needed python static analysis configs
Since the previous commit, python/setup.cfg applies to scripts/qapi/ as well. Configuration files in scripts/qapi/ override python/setup.cfg.
qapi: delete un-needed python static analysis configs
Since the previous commit, python/setup.cfg applies to scripts/qapi/ as well. Configuration files in scripts/qapi/ override python/setup.cfg.
scripts/qapi/.flake8 and scripts/qapi/.isort.cfg actually match python/setup.cfg exactly, and can go.
The differences between scripts/qapi/mypy.ini and python/setup.cfg are harmless: namespace_packages being set to True is a requirement for the PEP420 nested package structure of QEMU but not for scripts/qapi, but has no effect on type checking the QAPI code. warn_unused_ignores is used in python/ to be able to target a wide variety of mypy versions; some of which that have added new ignore categories that are not present in older versions.
Ultimately, scripts/qapi/mypy.ini can be removed without any real change in behavior to how mypy enforces type safety there.
The pylint config is being left in place because the settings differ enough from the python/ directory settings that we need a chit-chat on how to merge them O:-)
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 20250604200354.459501-7-jsnow@redhat.com
show more ...
|
| 65aa0a17 | 04-Jun-2025 |
John Snow <jsnow@redhat.com> |
python: add qapi static analysis tests
Update the python tests to also check QAPI and the QAPI Sphinx extensions. The docs/sphinx/qapidoc_legacy.py file is not included in these checks, as it is des
python: add qapi static analysis tests
Update the python tests to also check QAPI and the QAPI Sphinx extensions. The docs/sphinx/qapidoc_legacy.py file is not included in these checks, as it is destined for removal soon. mypy is also not called on the QAPI Sphinx extensions, owing to difficulties supporting Sphinx 3.x - 8.x while maintaining static type checking support. mypy *is* called on all of the QAPI tools themselves, though.
flake8, isort and mypy use the tool configuration from the existing python directory (in setup.cfg). pylint continues to use the special configuration located in scripts/qapi/ - that configuration is more permissive. If we wish to unify the two configurations, that's a separate series and a discussion for a later date.
The list of pylint ignores is also updated, owing again to the wide window of pylint version support: newer versions require pragmas to occasionally silence the "too many positional arguments" warning, but older versions do not have such a warning category and will instead yelp about an unrecognized option. Silence that warning, too.
As a result of this patch, one would be able to run any of the following tests locally from the qemu.git/python directory and have it cover the QAPI tooling as well. All of the following options run the python tests, static analysis tests, and linter checks; but with different combinations of dependencies and interpreters.
- "make check-minreqs" Run tests specifically under our oldest supported Python and our oldest supported dependencies. This is the test that runs on GitLab as "check-python-minreqs". This helps ensure we do not regress support on older platforms accidentally.
- "make check-tox" Runs the tests under the newest supported dependencies, but under each supported version of Python in turn. At time of writing, this is Python 3.8 to 3.13 inclusive. This test helps catch bleeding-edge problems before they become problems for developer workstations. This is the GitLab test "check-python-tox" and is an optionally run, may-fail test due to the unpredictable nature of new dependencies being released into the ecosystem that may cause regressions.
- "make check-dev" Runs the tests under the newest supported dependencies using whatever version of Python the user happens to have installed. This is a quick convenience check that does not map to any particular GitLab test.
(Note! check-dev may be busted on Fedora 41 and bleeding edge versions of setuptools. That's unrelated to this patch and I'll address it separately and soon. Thank you for your patience, --mgmt)
Finally, finally, finally: this means that QAPI tooling will be linted and type-checked from the GitLab pipelines.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-id: 20250604200354.459501-5-jsnow@redhat.com [Edited license choice per review --js] Signed-off-by: John Snow <jsnow@redhat.com>
show more ...
|
| 93db9c84 | 11-Mar-2025 |
Markus Armbruster <armbru@redhat.com> |
scripts/qapi/backend: Clean up create_backend()'s failure mode
create_backend()'s caller catches QAPIError, and returns non-zero exit code on catch. The caller's caller passes the exit code to sys.
scripts/qapi/backend: Clean up create_backend()'s failure mode
create_backend()'s caller catches QAPIError, and returns non-zero exit code on catch. The caller's caller passes the exit code to sys.exit().
create_backend() doesn't care: it reports errors to stderr and sys.exit()s.
Change it to raise QAPIError instead.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20250311065352.992307-1-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
show more ...
|
| 4d7d30b4 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
qapi/parser: add undocumented stub members to all_sections
Parser and doc generator cooperate on generating stub documentation for undocumented members. The parser makes up an ArgSection with an em
qapi/parser: add undocumented stub members to all_sections
Parser and doc generator cooperate on generating stub documentation for undocumented members. The parser makes up an ArgSection with an empty description, and the doc generator makes up a description.
Right now, the made-up ArgSections go into doc.args. However, the new doc generator uses .all_sections, not .args. So put them into .all_sections, too.
Insert them right after existing 'member' sections. If there are none, insert directly after the leading section.
Doesn't affect the old generator, because that one doesn't use .all_sections.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-60-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Commit message rewritten] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 36e4182f | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
qapi/source: allow multi-line QAPISourceInfo advancing
This is for the sake of the new rST generator (the "transmogrifier") so we can advance multiple lines on occasion while keeping the generated<-
qapi/source: allow multi-line QAPISourceInfo advancing
This is for the sake of the new rST generator (the "transmogrifier") so we can advance multiple lines on occasion while keeping the generated<-->source mappings accurate.
next_line now simply takes an optional n parameter which chooses the number of lines to advance.
The next patch will use this when converting section syntax in free-form documentation to more traditional rST section header syntax, which does not always line up 1:1 for line counts.
For example:
``` ## # = Section <-- Info is pointing here, "L1" # # Lorem Ipsum ## ```
would be transformed to rST as:
``` ======= <-- L1 Section <-- L1 ======= <-- L1 <-- L2 Lorem Ipsum <-- L3 ```
After consuming the single "Section" line from the source, we want to advance the source pointer to the next non-empty line which requires jumping by more than one line.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20250311034303.75779-42-jsnow@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| d7ca9a3a | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
qapi/schema: add __repr__ to QAPIDoc.Section
Makes debugging far more pleasant when you can just print(section) and get something reasonable to display.
Signed-off-by: John Snow <jsnow@redhat.com>
qapi/schema: add __repr__ to QAPIDoc.Section
Makes debugging far more pleasant when you can just print(section) and get something reasonable to display.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-35-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 323c6689 | 10-Mar-2025 |
John Snow <jsnow@redhat.com> |
qapi: clean up encoding of section kinds
We have several kinds of sections, and to tell them apart, we use Section attribute @tag and also the section object's Python type:
type
qapi: clean up encoding of section kinds
We have several kinds of sections, and to tell them apart, we use Section attribute @tag and also the section object's Python type:
type @tag untagged Section None @foo: ArgSection 'foo' Returns: Section 'Returns' Errors: Section 'Errors' Since: Section 'Since' TODO: Section 'TODO'
Note:
* @foo can be a member or a feature description, depending on context.
* tag == 'Since' can be a Since: section or a member or feature description. If it's a Section, it's the former, and if it's an ArgSection, it's the latter.
Clean this up as follows. Move the member or feature name to new ArgSection attribute @name, and replace @tag by enum @kind like this:
type kind name untagged Section PLAIN @foo: ArgSection MEMBER 'foo' if member or argument ArgSection FEATURE 'foo' if feature Returns: Section RETURNS Errors: Section ERRORS Since: Section SINCE TODO: Section TODO
The qapi-schema tests are updated to account for the new section names; "TODO" becomes "Todo" and `None` becomes "Plain" there.
Signed-off-by: John Snow <jsnow@redhat.com> Message-ID: <20250311034303.75779-34-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| e6985cc4 | 27-Feb-2025 |
Markus Armbruster <armbru@redhat.com> |
qapi/introspect: Use @dataclass to simplify
A TODO comment in class Annotated reminds us to simplify it once we can use @dataclass, new in Python 3.7. We have that now, so do it.
There's a similar
qapi/introspect: Use @dataclass to simplify
A TODO comment in class Annotated reminds us to simplify it once we can use @dataclass, new in Python 3.7. We have that now, so do it.
There's a similar comment in scripts/qapi/source.py, but I can't figure out how to use @dataclass there. Left for another day.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20250227080757.3978333-4-armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
show more ...
|
| dde27992 | 24-Feb-2025 |
Daniel P. Berrangé <berrange@redhat.com> |
qapi: pluggable backend code generators
The 'qapi.backend.QAPIBackend' class defines an API contract for code generators. The current generator is put into a new class 'qapi.backend.QAPICBackend' an
qapi: pluggable backend code generators
The 'qapi.backend.QAPIBackend' class defines an API contract for code generators. The current generator is put into a new class 'qapi.backend.QAPICBackend' and made to be the default impl.
A custom generator can be requested using the '-k' arg which takes a fully qualified python class name
qapi-gen.py -B the.python.module.QAPIMyBackend
This allows out of tree code to use the QAPI generator infrastructure to create new language bindings for QAPI schemas. This has the caveat that the QAPI generator APIs are not guaranteed stable, so consumers of this feature may have to update their code to be compatible with future QEMU releases.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20250224182030.2089959-1-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Error checking and messages tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 2ebb09f3 | 05-Feb-2025 |
Daniel P. Berrangé <berrange@redhat.com> |
qapi: expose all schema features to code
This replaces use of the constants from the QapiSpecialFeatures enum, with constants from the auto-generate QapiFeatures enum in qapi-features.h
The 'deprec
qapi: expose all schema features to code
This replaces use of the constants from the QapiSpecialFeatures enum, with constants from the auto-generate QapiFeatures enum in qapi-features.h
The 'deprecated' and 'unstable' features still have a little bit of special handling, being force defined to be the 1st + 2nd features in the enum, regardless of whether they're used in the schema. This retains compatibility with common code that references the features via the QapiSpecialFeatures constants.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20250205123550.2754387-5-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Imports tidied up with isort] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| ba27dccc | 05-Feb-2025 |
Daniel P. Berrangé <berrange@redhat.com> |
qapi: rename 'special_features' to 'features'
This updates the QAPI code generation to refer to 'features' instead of 'special_features', in preparation for generalizing their exposure.
Signed-off-
qapi: rename 'special_features' to 'features'
This updates the QAPI code generation to refer to 'features' instead of 'special_features', in preparation for generalizing their exposure.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20250205123550.2754387-4-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Imports tidied up with isort] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| d8a22e69 | 05-Feb-2025 |
Daniel P. Berrangé <berrange@redhat.com> |
qapi: cope with feature names containing a '-'
When we shortly expose all feature names to code, it will be valid to include a '-', which must be translated to a '_' for the enum constants.
Signed-
qapi: cope with feature names containing a '-'
When we shortly expose all feature names to code, it will be valid to include a '-', which must be translated to a '_' for the enum constants.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20250205123550.2754387-2-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
| 153b0989 | 18-Nov-2024 |
Daniel P. Berrangé <berrange@redhat.com> |
qapi: Move and rename qapi/qmp/dispatch.h to qapi/qmp-registry.h
The general expectation is that header files should follow the same file/path naming scheme as the corresponding source file. There a
qapi: Move and rename qapi/qmp/dispatch.h to qapi/qmp-registry.h
The general expectation is that header files should follow the same file/path naming scheme as the corresponding source file. There are various historical exceptions to this practice in QEMU, with one of the most notable being the include/qapi/qmp/ directory.
include/qapi/qmp/dispatch.h corresponds mostly to qapi/qmp-registry.c. Move and rename it to include/qapi/qmp-registry.h.
Now just qerror.h is left in include/qapi/qmp/. Since it's deprecated & (slowly) getting eliminated anyway, it isn't worth moving.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20241118151235.2665921-3-armbru@redhat.com>
show more ...
|