#
407bc4bf |
| 18-Nov-2024 |
Daniel P. Berrangé <berrange@redhat.com> |
qapi: Move include/qapi/qmp/ to include/qobject/
The general expectation is that header files should follow the same file/path naming scheme as the corresponding source file. There are various histo
qapi: Move include/qapi/qmp/ to include/qobject/
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. Most of the headers there correspond to source files in qobject/.
This patch corrects most of that inconsistency by creating include/qobject/ and moving the headers for qobject/ there.
This also fixes MAINTAINERS for include/qapi/qmp/dispatch.h: scripts/get_maintainer.pl now reports "QAPI" instead of "No maintainers found".
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com> Acked-by: Halil Pasic <pasic@linux.ibm.com> #s390x Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20241118151235.2665921-2-armbru@redhat.com> [Rebased]
show more ...
|
#
3ff2a5a3 |
| 15-Mar-2024 |
Markus Armbruster <armbru@redhat.com> |
qapi: Rename QAPISchemaObjectType.variants to .branches
A previous commit narrowed the type of QAPISchemaObjectType.variants from QAPISchemaVariants to QAPISchemaBranches. Rename it to .branches.
qapi: Rename QAPISchemaObjectType.variants to .branches
A previous commit narrowed the type of QAPISchemaObjectType.variants from QAPISchemaVariants to QAPISchemaBranches. Rename it to .branches.
Same for .__init__() parameter @variants.
Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
44ea9d9b |
| 04-Nov-2022 |
Markus Armbruster <armbru@redhat.com> |
qapi: Start to elide redundant has_FOO in generated C
In QAPI, absent optional members are distinct from any present value. We thus represent an optional schema member FOO as two C members: a FOO wi
qapi: Start to elide redundant has_FOO in generated C
In QAPI, absent optional members are distinct from any present value. We thus represent an optional schema member FOO as two C members: a FOO with the member's type, and a bool has_FOO. Likewise for function arguments.
However, has_FOO is actually redundant for a pointer-valued FOO, which can be null only when has_FOO is false, i.e. has_FOO == !!FOO. Except for arrays, where we a null FOO can also be a present empty array.
The redundant has_FOO are a nuisance to work with. Improve the generator to elide them. Uses of has_FOO need to be replaced as follows.
Tests of has_FOO become the equivalent comparison of FOO with null. For brevity, this is commonly done by implicit conversion to bool.
Assignments to has_FOO get dropped.
Likewise for arguments to has_FOO parameters.
Beware: code may violate the invariant has_FOO == !!FOO before the transformation, and get away with it. The above transformation can then break things. Two cases:
* Absent: if code ignores FOO entirely when !has_FOO (except for freeing it if necessary), even non-null / uninitialized FOO works. Such code is known to exist.
* Present: if code ignores FOO entirely when has_FOO, even null FOO works. Such code should not exist.
In both cases, replacing tests of has_FOO by FOO reverts their sense. We have to fix the value of FOO then.
To facilitate review of the necessary updates to handwritten code, add means to opt out of this change, and opt out for all QAPI schema modules where the change requires updates to handwritten code. The next few commits will remove these opt-outs in reviewable chunks, then drop the means to opt out.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20221104160712.3005652-5-armbru@redhat.com>
show more ...
|
#
7df18461 |
| 04-Nov-2022 |
Markus Armbruster <armbru@redhat.com> |
qapi: Tidy up whitespace in generated code
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20221104160712.3005652-3-armbru@red
qapi: Tidy up whitespace in generated code
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Message-Id: <20221104160712.3005652-3-armbru@redhat.com>
show more ...
|
#
57df0dff |
| 28-Oct-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Extend -compat to set policy for unstable interfaces
New option parameters unstable-input and unstable-output set policy for unstable interfaces just like deprecated-input and deprecated-outpu
qapi: Extend -compat to set policy for unstable interfaces
New option parameters unstable-input and unstable-output set policy for unstable interfaces just like deprecated-input and deprecated-output set policy for deprecated interfaces (see commit 6dd75472d5 "qemu-options: New -compat to set policy for deprecated interfaces"). This is intended for testing users of the management interfaces. It is experimental.
For now, this covers only syntactic aspects of QMP, i.e. stuff tagged with feature 'unstable'. We may want to extend it to cover semantic aspects, or the command line.
Note that there is no good way for management application to detect presence of these new option parameters: they are not visible output of query-qmp-schema or query-command-line-options. Tolerable, because it's meant for testing. If running with -compat fails, skip the test.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Acked-by: John Snow <jsnow@redhat.com> Message-Id: <20211028102520.747396-10-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Doc comments fixed up]
show more ...
|
#
f17539c8 |
| 04-Aug-2021 |
Marc-André Lureau <marcandre.lureau@redhat.com> |
qapi: wrap Sequence[str] in an object
Mechanical change, except for a new assertion in QAPISchemaEntity.ifcond().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <2021080
qapi: wrap Sequence[str] in an object
Mechanical change, except for a new assertion in QAPISchemaEntity.ifcond().
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-Id: <20210804083105.97531-3-marcandre.lureau@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Rebased with obvious conflicts, commit message adjusted] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
a291a38f |
| 18-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Implement deprecated-output=hide for QMP event data
This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP event data: suppress deprecat
qapi: Implement deprecated-output=hide for QMP event data
This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP event data: suppress deprecated members.
No QMP event data is deprecated right now.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210318155519.1224118-6-armbru@redhat.com>
show more ...
|
#
278fc2f7 |
| 18-Mar-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi: Implement deprecated-output=hide for QMP events
This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP events: suppress deprecated ones.
qapi: Implement deprecated-output=hide for QMP events
This policy suppresses deprecated bits in output, and thus permits "testing the future". Implement it for QMP events: suppress deprecated ones.
No QMP event is deprecated right now.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20210318155519.1224118-5-armbru@redhat.com>
show more ...
|
#
2184bca7 |
| 16-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi: Replace List[str] with Sequence[str] for ifcond
It does happen to be a list (as of now), but we can describe it in more general terms with no loss in accuracy to allow tuples and other constru
qapi: Replace List[str] with Sequence[str] for ifcond
It does happen to be a list (as of now), but we can describe it in more general terms with no loss in accuracy to allow tuples and other constructs.
In the future, we can write "ifcond: Sequence[str] = ()" as a default parameter, which we could not do safely with a Mutable type like a List.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210216021809.134886-2-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Commit message tweaked] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
4a82e468 |
| 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi: type 'info' as Optional[QAPISourceInfo]
For everything typed so far, type this parameter as Optional[QAPISourceInfo].
In the most generic case, QAPISchemaEntity's info field may be None to re
qapi: type 'info' as Optional[QAPISourceInfo]
For everything typed so far, type this parameter as Optional[QAPISourceInfo].
In the most generic case, QAPISchemaEntity's info field may be None to represent types that come from built-in definitions. Although some Entity types may not currently have any built-in definitions, it is not easily possible to constrain the type except on an ad-hoc basis using assertions.
It's easier and simpler, then, to just say it's always an Optional type.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-16-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
4ab0ff6d |
| 01-Feb-2021 |
Markus Armbruster <armbru@redhat.com> |
qapi/gen: Combine ._add_[user|system]_module
With callers to _add_system_module now explicitly using the './' prefix to indicate a system module, there is no longer any reason to have separate inter
qapi/gen: Combine ._add_[user|system]_module
With callers to _add_system_module now explicitly using the './' prefix to indicate a system module, there is no longer any reason to have separate interfaces for adding system vs user modules; use a unified interface that differentiates based on the name.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-10-jsnow@redhat.com>
show more ...
|
#
12893a8e |
| 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi: use explicitly internal module names
QAPISchemaModularCVisitor._add_system_module() prefixes './' to its name argument to make it a module name. Pass the module name instead. This will allow
qapi: use explicitly internal module names
QAPISchemaModularCVisitor._add_system_module() prefixes './' to its name argument to make it a module name. Pass the module name instead. This will allow us to coalesce the methods to add modules later on.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-8-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Commit message reworded] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
3cc01c54 |
| 01-Feb-2021 |
John Snow <jsnow@redhat.com> |
qapi/events: fix visit_event typing
Actually, the arg_type can indeed be Optional.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-3-jsnow@redhat.com> Reviewed-by: M
qapi/events: fix visit_event typing
Actually, the arg_type can indeed be Optional.
Signed-off-by: John Snow <jsnow@redhat.com> Message-Id: <20210201193747.2169670-3-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
1a503761 |
| 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/events.py: Move comments into docstrings
Clarify them while we're here.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa
qapi/events.py: Move comments into docstrings
Clarify them while we're here.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-21-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
d1b21b39 |
| 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/events.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Note: __init__ does not need its return type annotated, as it is special.
qapi/events.py: add type hint annotations
Annotations do not change runtime behavior. This commit *only* adds annotations.
Note: __init__ does not need its return type annotated, as it is special. https://mypy.readthedocs.io/en/stable/class_basics.html#annotating-init-methods
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-20-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
e6a34cd7 |
| 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi/common.py: move build_params into gen.py
Including it in common.py creates a circular import dependency; schema relies on common, but common.build_params requires a type annotation from schema.
qapi/common.py: move build_params into gen.py
Including it in common.py creates a circular import dependency; schema relies on common, but common.build_params requires a type annotation from schema. To type this properly, it needs to be moved outside the cycle.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Message-Id: <20201009161558.107041-18-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
5af8263d |
| 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi: Remove wildcard includes
Wildcard includes become hard to manage when refactoring and dealing with circular dependencies with strictly typed mypy.
flake8 also flags each one as a warning, as
qapi: Remove wildcard includes
Wildcard includes become hard to manage when refactoring and dealing with circular dependencies with strictly typed mypy.
flake8 also flags each one as a warning, as it is not smart enough to know which names exist in the imported file.
Remove them and include things explicitly by name instead.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201009161558.107041-7-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
7137a960 |
| 09-Oct-2020 |
John Snow <jsnow@redhat.com> |
qapi: Prefer explicit relative imports
All of the QAPI include statements are changed to be package-aware, as explicit relative imports.
A quirk of Python packages is that the name of the package e
qapi: Prefer explicit relative imports
All of the QAPI include statements are changed to be package-aware, as explicit relative imports.
A quirk of Python packages is that the name of the package exists only *outside* of the package. This means that to a module inside of the qapi folder, there is inherently no such thing as the "qapi" package. The reason these imports work is because the "qapi" package exists in the context of the caller -- the execution shim, where sys.path includes a directory that has a 'qapi' folder in it.
When we write "from qapi import sibling", we are NOT referencing the folder 'qapi', but rather "any package named qapi in sys.path". If you should so happen to have a 'qapi' package in your path, it will use *that* package.
When we write "from .sibling import foo", we always reference explicitly our sibling module; guaranteeing consistency in *where* we are importing these modules from.
This can be useful when working with virtual environments and packages in development mode. In development mode, a package is installed as a series of symlinks that forwards to your same source files. The problem arises because code quality checkers will follow "import qapi.x" to the "installed" version instead of the sibling file and -- even though they are the same file -- they have different module paths, and this causes cyclic import problems, false positive type mismatch errors, and more.
It can also be useful when dealing with hierarchical packages, e.g. if we allow qemu.core.qmp, qemu.qapi.parser, etc.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Cleber Rosa <crosa@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Message-Id: <20201009161558.107041-6-jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
#
013b4efc |
| 17-Mar-2020 |
Markus Armbruster <armbru@redhat.com> |
qapi: Add feature flags to remaining definitions
In v4.1.0, we added feature flags just to struct types (commit 6a8c0b5102^..f3ed93d545), to satisfy an immediate need (commit c9d4070991 "file-posix:
qapi: Add feature flags to remaining definitions
In v4.1.0, we added feature flags just to struct types (commit 6a8c0b5102^..f3ed93d545), to satisfy an immediate need (commit c9d4070991 "file-posix: Add dynamic-auto-read-only QAPI feature"). In v4.2.0, we added them to commands (commit 23394b4c39 "qapi: Add feature flags to commands") to satisfy another immediate need (commit d76744e65e "qapi: Allow introspecting fix for savevm's cooperation with blockdev").
Add them to the remaining definitions: enumeration types, union types, alternate types, and events.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20200317115459.31821-13-armbru@redhat.com>
show more ...
|
#
2cae67bc |
| 04-Mar-2020 |
Markus Armbruster <armbru@redhat.com> |
qapi: Use super() now we have Python 3
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20200304155932.20452-4-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
|
#
3bef3aae |
| 20-Nov-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Simplify QAPISchemaModularCVisitor
Since the previous commit, QAPISchemaVisitor.visit_module() is called just once. Simplify QAPISchemaModularCVisitor accordingly.
Signed-off-by: Markus Armb
qapi: Simplify QAPISchemaModularCVisitor
Since the previous commit, QAPISchemaVisitor.visit_module() is called just once. Simplify QAPISchemaModularCVisitor accordingly.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20191120182551.23795-7-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
#
e6c42b96 |
| 18-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Split up scripts/qapi/common.py
The QAPI code generator clocks in at some 3100 SLOC in 8 source files. Almost 60% of the code is in qapi/common.py. Split it into more focused modules:
* Move
qapi: Split up scripts/qapi/common.py
The QAPI code generator clocks in at some 3100 SLOC in 8 source files. Almost 60% of the code is in qapi/common.py. Split it into more focused modules:
* Move QAPISchemaPragma and QAPISourceInfo to qapi/source.py.
* Move QAPIError and its sub-classes to qapi/error.py.
* Move QAPISchemaParser and QAPIDoc to parser.py. Use the opportunity to put QAPISchemaParser first.
* Move check_expr() & friends to qapi/expr.py. Use the opportunity to put the code into a more sensible order.
* Move QAPISchema & friends to qapi/schema.py
* Move QAPIGen and its sub-classes, ifcontext, QAPISchemaModularCVisitor, and QAPISchemaModularCVisitor to qapi/gen.py
* Delete camel_case(), it's unused since commit e98859a9b9 "qapi: Clean up after recent conversions to QAPISchemaVisitor"
A number of helper functions remain in qapi/common.py. I considered moving the code generator helpers to qapi/gen.py, but decided not to. Perhaps we should rewrite them as methods of QAPIGen some day.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-7-armbru@redhat.com> [Add "# -*- coding: utf-8 -*-" lines]
show more ...
|
#
61bfb2e1 |
| 18-Oct-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Move gen_enum(), gen_enum_lookup() back to qapi/types.py
The next commit will split up qapi/common.py. gen_enum() needs QAPISchemaEnumMember, and that's in the way. Move it to qapi/types.py
qapi: Move gen_enum(), gen_enum_lookup() back to qapi/types.py
The next commit will split up qapi/common.py. gen_enum() needs QAPISchemaEnumMember, and that's in the way. Move it to qapi/types.py along with its buddy gen_enum_lookup().
Permit me a short a digression on history: how did gen_enum() end up in qapi/common.py? Commit 21cd70dfc1 "qapi script: add event support" duplicated qapi-types.py's gen_enum() and gen_enum_lookup() in qapi-event.py. Simply importing them would have been cleaner, but wasn't possible as qapi-types.py was a program, not a module. Commit efd2eaa6c2 "qapi: De-duplicate enum code generation" de-duplicated by moving them to qapi.py, which was a module.
Since then, program qapi-types.py has morphed into module types.py. It's where gen_enum() and gen_enum_lookup() started, and where they belong.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20191018074345.24034-6-armbru@redhat.com>
show more ...
|
#
e6f9678d |
| 27-Sep-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Plumb info to the QAPISchemaMember
Future commits will need info in the .check() methods of QAPISchemaMember and its descendants. Get it there.
Signed-off-by: Markus Armbruster <armbru@redha
qapi: Plumb info to the QAPISchemaMember
Future commits will need info in the .check() methods of QAPISchemaMember and its descendants. Get it there.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190927134639.4284-15-armbru@redhat.com>
show more ...
|
#
398969fe |
| 13-Sep-2019 |
Markus Armbruster <armbru@redhat.com> |
qapi: Adjust frontend errors to say enum value, not member
For consistency with docs/devel/qapi-code-gen.txt.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@re
qapi: Adjust frontend errors to say enum value, not member
For consistency with docs/devel/qapi-code-gen.txt.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Message-Id: <20190913201349.24332-12-armbru@redhat.com>
show more ...
|