e307a817 | 18-Oct-2023 |
Daniel P. Berrangé <berrange@redhat.com> |
qapi: provide a friendly string representation of QAPI classes
If printing a QAPI schema object for debugging we get the classname and a hex value for the instance:
<qapi.schema.QAPISchemaEnumTyp
qapi: provide a friendly string representation of QAPI classes
If printing a QAPI schema object for debugging we get the classname and a hex value for the instance:
<qapi.schema.QAPISchemaEnumType object at 0x7f0ab4c2dad0> <qapi.schema.QAPISchemaObjectType object at 0x7f0ab4c2dd90> <qapi.schema.QAPISchemaArrayType object at 0x7f0ab4c2df90>
With this change we instead get the classname and the human friendly name of the QAPI type instance:
<QAPISchemaEnumType:CpuS390State at 0x7f0ab4c2dad0> <QAPISchemaObjectType:CpuInfoS390 at 0x7f0ab4c2dd90> <QAPISchemaArrayType:CpuInfoFastList at 0x7f0ab4c2df90>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Message-ID: <20231018120500.2028642-1-berrange@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> [Conditional swapped to avoid negation] Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> [Tweaked to mollify pylint] Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
5591b745 | 10-May-2023 |
Paolo Bonzini <pbonzini@redhat.com> |
Python: Drop support for Python 3.6
Python 3.6 was EOL 2021-12-31. Newer versions of upstream libraries have begun dropping support for this version and it is becoming more cumbersome to support. Av
Python: Drop support for Python 3.6
Python 3.6 was EOL 2021-12-31. Newer versions of upstream libraries have begun dropping support for this version and it is becoming more cumbersome to support. Avocado-framework and qemu.qmp each have their own reasons for wanting to drop Python 3.6, but won't until QEMU does.
Versions of Python available in our supported build platforms as of today, with optional versions available in parentheses:
openSUSE Leap 15.4: 3.6.15 (3.9.10, 3.10.2) CentOS Stream 8: 3.6.8 (3.8.13, 3.9.16) CentOS Stream 9: 3.9.13 Fedora 36: 3.10 Fedora 37: 3.11 Debian 11: 3.9.2 Alpine 3.14, 3.15: 3.9.16 Alpine 3.16, 3.17: 3.10.10 Ubuntu 20.04 LTS: 3.8.10 Ubuntu 22.04 LTS: 3.10.4 NetBSD 9.3: 3.9.13* FreeBSD 12.4: 3.9.16 FreeBSD 13.1: 3.9.16 OpenBSD 7.2: 3.9.16
Note: Our VM tests install 3.9 explicitly for FreeBSD and 3.10 for NetBSD; the default for "python" or "python3" in FreeBSD is 3.9.16. NetBSD does not appear to have a default meta-package, but offers several options, the lowest of which is 3.7.15. "python39" appears to be a pre-requisite to one of the other packages we request in tests/vm/netbsd. pip, ensurepip and other Python essentials are currently only available for Python 3.10 for NetBSD.
CentOS and OpenSUSE support parallel installation of multiple Python interpreters, and binaries in /usr/bin will always use Python 3.6. However, the newly introduced support for virtual environments ensures that all build steps that execute QEMU Python code use a single interpreter.
Since it is safe to under our supported platform policy, bump our minimum supported version of Python to 3.7.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20230511035435.734312-24-jsnow@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
eb59cf76 | 28-Apr-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Section parameter @indent is no longer used, drop
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-15-armbru@redhat.com> Reviewed-by: Juan Quintela <qui
qapi: Section parameter @indent is no longer used, drop
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-15-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com>
show more ...
|
08349786 | 28-Apr-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Relax doc string @name: description indentation rules
The QAPI schema doc comment language provides special syntax for command and event arguments, struct and union members, alternate branches
qapi: Relax doc string @name: description indentation rules
The QAPI schema doc comment language provides special syntax for command and event arguments, struct and union members, alternate branches, enumeration values, and features: descriptions starting with "@name:".
By convention, we format them like this:
# @name: Lorem ipsum dolor sit amet, consectetur adipiscing elit, # sed do eiusmod tempor incididunt ut labore et dolore # magna aliqua.
Okay for names as short as "name", but we have much longer ones. Their description gets squeezed against the right margin, like this:
# @dirty-sync-missed-zero-copy: Number of times dirty RAM synchronization could # not avoid copying dirty pages. This is between # 0 and @dirty-sync-count * @multifd-channels. # (since 7.1)
The description text is effectively just 50 characters wide. Easy enough to read, but can be cumbersome to write.
The awkward squeeze against the right margin makes people go beyond it, which produces two undesirables: arguments about style, and descriptions that are unnecessarily hard to read, like this one:
# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU. This is # only present when the postcopy-blocktime migration capability # is enabled. (Since 3.0)
We could instead format it like
# @postcopy-vcpu-blocktime: # list of the postcopy blocktime per vCPU. This is only present # when the postcopy-blocktime migration capability is # enabled. (Since 3.0)
or, since the commit before previous, like
# @postcopy-vcpu-blocktime: # list of the postcopy blocktime per vCPU. This is only present # when the postcopy-blocktime migration capability is # enabled. (Since 3.0)
However, I'd rather have
# @postcopy-vcpu-blocktime: list of the postcopy blocktime per vCPU. # This is only present when the postcopy-blocktime migration # capability is enabled. (Since 3.0)
because this is how rST field and option lists work.
To get this, we need to let the first non-blank line after the "@name:" line determine expected indentation.
This fills up the indentation pitfall mentioned in docs/devel/qapi-code-gen.rst. A related pitfall still exists. Update the text to show it.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-14-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> [Work around lack of walrus operator in Python 3.7 and older]
show more ...
|
3e32dca3 | 28-Apr-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Rewrite parsing of doc comment section symbols and tags
To recognize a line starting with a section symbol and or tag, we first split it at the first space, then examine the part left of the s
qapi: Rewrite parsing of doc comment section symbols and tags
To recognize a line starting with a section symbol and or tag, we first split it at the first space, then examine the part left of the space. We can just as well examine the unsplit line, so do that.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-13-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com> [Work around lack of walrus operator in Python 3.7 and older]
show more ...
|
9b2c6746 | 28-Apr-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix argument description indentation stripping
When an argument's description starts on the line after the "#arg: " line, indentation is stripped only from the description's first line, as dem
qapi: Fix argument description indentation stripping
When an argument's description starts on the line after the "#arg: " line, indentation is stripped only from the description's first line, as demonstrated by the previous commit. Moreover, subsequent lines with less indentation are not rejected.
Make the first line's indentation the expected indentation for the remainder of the description. This fixes indentation stripping, and also requires at least that much indentation.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230428105429.1687850-12-armbru@redhat.com> Reviewed-by: Juan Quintela <quintela@redhat.com>
show more ...
|
1e148b54 | 25-Apr-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Improve specificity of type/member descriptions
Error messages describe object members, enumeration values, features, and variants like ROLE 'NAME', where ROLE is "member", "value", "feature",
qapi: Improve specificity of type/member descriptions
Error messages describe object members, enumeration values, features, and variants like ROLE 'NAME', where ROLE is "member", "value", "feature", or "branch", respectively. When the member is defined in another type, e.g. inherited from a base type, we add "of type 'TYPE'". Example: test case struct-base-clash-deep reports a member of type 'Sub' clashing with a member of its base type 'Base' as
struct-base-clash-deep.json: In struct 'Sub': struct-base-clash-deep.json:10: member 'name' collides with member 'name' of type 'Base'
Members of implicitly defined types need special treatment. We don't want to add "of type 'TYPE'" for them, because their named are made up and mean nothing to the user. Instead, we describe members of an implicitly defined base type as "base member 'NAME'", and command and event parameters as "parameter 'NAME'". Example: test case union-bad-base reports member of a variant's type clashing with a member of its implicitly defined base type as
union-bad-base.json: In union 'TestUnion': union-bad-base.json:8: member 'string' of type 'TestTypeA' collides with base member 'string'
The next commit will permit unions as variant types. "base member 'NAME' would then be ambigious: is it the union's base, or is it the union's variant's base? One of its test cases would report a clash between two such bases as "base member 'type' collides with base member 'type'". Confusing.
Refine the special treatment: add "of TYPE" even for implicitly defined types, but massage TYPE and ROLE so they make sense for the user.
Message-Id: <20230420102619.348173-3-berrange@redhat.com> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
show more ...
|
de3b3f52 | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
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.
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>
show more ...
|
713d921a | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix code generated for optional conditional struct member
The generated member visit neglects to emit #if around a conditional struct member's has_ variable. For instance, tests/qapi-schema/q
qapi: Fix code generated for optional conditional struct member
The generated member visit neglects to emit #if around a conditional struct member's has_ variable. For instance, tests/qapi-schema/qapi-schema-test.json generates
#if defined(TEST_IF_STRUCT) bool visit_type_TestIfStruct_members(Visitor *v, TestIfStruct *obj, Error **errp) { ---> bool has_baz = !!obj->baz;
if (!visit_type_int(v, "foo", &obj->foo, errp)) { return false; } #if defined(TEST_IF_STRUCT_MEMBER) if (!visit_type_int(v, "bar", &obj->bar, errp)) { return false; } #endif /* defined(TEST_IF_STRUCT_MEMBER) */ #if defined(TEST_IF_STRUCT_MEMBER) if (visit_optional(v, "baz", &has_baz)) { if (!visit_type_str(v, "baz", &obj->baz, errp)) { return false; } } #endif /* defined(TEST_IF_STRUCT_MEMBER) */ return true; } [...] #endif /* defined(TEST_IF_STRUCT) */
Won't compile when TEST_IF_STRUCT is defined and TEST_IF_STRUCT_MEMBER isn't.
Fix that the obvious way:
#if defined(TEST_IF_STRUCT_MEMBER) bool has_baz = !!obj->baz; #endif /* defined(TEST_IF_STRUCT_MEMBER) */
Fixes: 44ea9d9be33c (qapi: Start to elide redundant has_FOO in generated C) Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-14-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
e2050ef6 | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Fix to reject 'data': 'mumble' in struct
A struct's 'data' must be a JSON object defining the struct's members. The QAPI code generator incorrectly accepts a JSON string instead, and then cras
qapi: Fix to reject 'data': 'mumble' in struct
A struct's 'data' must be a JSON object defining the struct's members. The QAPI code generator incorrectly accepts a JSON string instead, and then crashes in QAPISchema._make_members() called from ._def_struct_type().
Fix to reject it: factor check_type_implicit() out of check_type_name_or_implicit(), and switch check_struct() to use it instead. Also add a test case.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-9-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [More detailed commit message]
show more ...
|
7c407519 | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Simplify code a bit after previous commits
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-7-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.c
qapi: Simplify code a bit after previous commits
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-7-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message corrected]
show more ...
|
2a0c975f | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Improve error message for unexpected array types
We reject array types in certain places with "cannot be an array". Deleting this check improves the error message to "should be a type name" or
qapi: Improve error message for unexpected array types
We reject array types in certain places with "cannot be an array". Deleting this check improves the error message to "should be a type name" or "should be an object or type name", depending on context, so do that.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-6-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
show more ...
|
06cc46ee | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Split up check_type()
check_type() can check type names, arrays, and implicit struct types. Callers pass flags to select from this menu. This makes the function somewhat hard to read. Moreov
qapi: Split up check_type()
check_type() can check type names, arrays, and implicit struct types. Callers pass flags to select from this menu. This makes the function somewhat hard to read. Moreover, a few minor bugs are hiding in there, as we'll see shortly.
Split it into check_type_name(), check_type_name_or_array(), and check_type_name_or_implicit(). Each of them is a copy of the original specialized to a certain set of flags.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-5-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> [Commit message corrected]
show more ...
|
607045ba | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi: Clean up after removal of simple unions
Commit 4e99f4b12c0 (qapi: Drop simple unions) missed a bit of code dealing with simple union branches. Drop it.
Signed-off-by: Markus Armbruster <armb
qapi: Clean up after removal of simple unions
Commit 4e99f4b12c0 (qapi: Drop simple unions) missed a bit of code dealing with simple union branches. Drop it.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-4-armbru@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com>
show more ...
|
ecee568e | 16-Mar-2023 |
Markus Armbruster <armbru@redhat.com> |
qapi/schema: Use super()
Commit 2cae67bcb5e (qapi: Use super() now we have Python 3) converted the code to super(). Shortly after, commit f965e8fea6a (qapi: New special feature flag "deprecated") n
qapi/schema: Use super()
Commit 2cae67bcb5e (qapi: Use super() now we have Python 3) converted the code to super(). Shortly after, commit f965e8fea6a (qapi: New special feature flag "deprecated") neglected to use super(). Convert it now.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-Id: <20230316071325.492471-3-armbru@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
show more ...
|