583f4d6f | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: fix typing for QAPISchemaVariants.tag_member
There are two related changes here:
(1) We need to perform type narrowing for resolving the type of tag_member during check(), and
(2)
qapi/schema: fix typing for QAPISchemaVariants.tag_member
There are two related changes here:
(1) We need to perform type narrowing for resolving the type of tag_member during check(), and
(2) tag_member is a delayed initialization field, but we can hide it behind a property that raises an Exception if it's called too early. This simplifies the typing in quite a few places and avoids needing to assert that the "tag_member is not None" at a dozen callsites, which can be confusing and suggest the wrong thing to a drive-by contributor.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-18-armbru@redhat.com>
show more ...
|
9beda22d | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: Don't initialize "members" with `None`
Declare, but don't initialize the "members" field with type List[QAPISchemaObjectTypeMember].
This simplifies the typing from what would otherwis
qapi/schema: Don't initialize "members" with `None`
Declare, but don't initialize the "members" field with type List[QAPISchemaObjectTypeMember].
This simplifies the typing from what would otherwise be Optional[List[T]] to merely List[T]. This removes the need to add assertions to several callsites that this value is not None - which it never will be after the delayed initialization in check() anyway.
The type declaration without initialization trick will cause accidental uses of this field prior to full initialization to raise an AttributeError.
(Note that it is valid to have an empty members list, see the internal q_empty object as an example. For this reason, we cannot use the empty list as a replacement test for full initialization and instead rely on the _checked/_check_complete fields.)
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-17-armbru@redhat.com>
show more ...
|
875f6242 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: add _check_complete flag
Instead of using the None value for the members field, use a dedicated flag to detect recursive misconfigurations.
This is intended to assist with subsequent p
qapi/schema: add _check_complete flag
Instead of using the None value for the members field, use a dedicated flag to detect recursive misconfigurations.
This is intended to assist with subsequent patches that seek to remove the "None" value from the members field (which can never hold that value after the final call to check()) in order to simplify the static typing of that field; avoiding the need of assertions littered at many callsites to eliminate the possibility of the None value.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-16-armbru@redhat.com>
show more ...
|
8b9e7fd3 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: assert info is present when necessary
QAPISchemaInfo arguments can often be None because built-in definitions don't have such information. The type hint can only be Optional[QAPISchema
qapi/schema: assert info is present when necessary
QAPISchemaInfo arguments can often be None because built-in definitions don't have such information. The type hint can only be Optional[QAPISchemaInfo] then. But, mypy gets upset about all the places where we exploit that it can't actually be None there. Add assertions that will help mypy over the hump, to enable adding type hints in a forthcoming commit.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-15-armbru@redhat.com>
show more ...
|
8c91329f | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type
Adjust the expression at the callsite to work around mypy's weak type introspection that believes this expression can resolve to QAP
qapi/schema: fix QAPISchemaArrayType.check's call to resolve_type
Adjust the expression at the callsite to work around mypy's weak type introspection that believes this expression can resolve to QAPISourceInfo; it cannot.
(Fundamentally: self.info only resolves to false in a boolean expression when it is None; therefore this expression may only ever produce Optional[str]. mypy does not know that 'info', when it is a QAPISourceInfo object, cannot ever be false.)
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-14-armbru@redhat.com>
show more ...
|
7191400a | 15-Mar-2024 |
Markus Armbruster <armbru@redhat.com> |
qapi: Assert built-in types exist
QAPISchema.lookup_type('FOO') returns a QAPISchemaType when type 'FOO' exists, else None. It won't return None for built-in types like 'int'.
Since mypy can't see
qapi: Assert built-in types exist
QAPISchema.lookup_type('FOO') returns a QAPISchemaType when type 'FOO' exists, else None. It won't return None for built-in types like 'int'.
Since mypy can't see that, it'll complain that we assign the Optional[QAPISchemaType] returned by .lookup_type() to QAPISchemaType variables.
Add assertions to help it over the hump.
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-13-armbru@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com>
show more ...
|
802a3e3f | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: assert resolve_type has 'info' and 'what' args on error
resolve_type() is generally used to resolve configuration-provided type names into type objects, and generally requires valid 'in
qapi/schema: assert resolve_type has 'info' and 'what' args on error
resolve_type() is generally used to resolve configuration-provided type names into type objects, and generally requires valid 'info' and 'what' parameters.
In some cases, such as with QAPISchemaArrayType.check(), resolve_type may be used to resolve built-in types and as such will not have an 'info' argument, but also must not fail in this scenario.
Use an assertion to sate mypy that we will indeed have 'info' and 'what' parameters for the error pathway in resolve_type.
Note: there are only three callsites to resolve_type at present where "info" is perceived by mypy to be possibly None:
1) QAPISchemaArrayType.check() 2) QAPISchemaObjectTypeMember.check() 3) QAPISchemaEvent.check()
Of those three, only the first actually ever passes None; the other two are limited by their base class initializers which accept info=None, but neither subclass actually use a None value in practice, currently.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-12-armbru@redhat.com>
show more ...
|
10755a95 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: add type narrowing to lookup_type()
This function is a bit hard to type as-is; mypy needs some assertions to assist with the type narrowing.
Signed-off-by: John Snow <jsnow@redhat.com>
qapi/schema: add type narrowing to lookup_type()
This function is a bit hard to type as-is; mypy needs some assertions to assist with the type narrowing.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-11-armbru@redhat.com>
show more ...
|
9bda6c7d | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: adjust type narrowing for mypy's benefit
We already take care to perform some type narrowing for arg_type and ret_type, but not in a way where mypy can utilize the result once we add ty
qapi/schema: adjust type narrowing for mypy's benefit
We already take care to perform some type narrowing for arg_type and ret_type, but not in a way where mypy can utilize the result once we add type hints, e.g.:
qapi/schema.py:833: error: Incompatible types in assignment (expression has type "QAPISchemaType", variable has type "Optional[QAPISchemaObjectType]") [assignment]
qapi/schema.py:893: error: Incompatible types in assignment (expression has type "QAPISchemaType", variable has type "Optional[QAPISchemaObjectType]") [assignment]
A simple change to use a temporary variable helps the medicine go down.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-10-armbru@redhat.com>
show more ...
|
d150be3d | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: make c_type() and json_type() abstract methods
These methods should always return a str, it's only the default abstract implementation that doesn't. They can be marked "abstract", which
qapi/schema: make c_type() and json_type() abstract methods
These methods should always return a str, it's only the default abstract implementation that doesn't. They can be marked "abstract", which requires subclasses to override the method with the proper return type.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-9-armbru@redhat.com>
show more ...
|
578cd932 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: declare type for QAPISchemaArrayType.element_type
A QAPISchemaArrayType's element type gets resolved only during .check(). We have QAPISchemaArrayType.__init__() initialize self.element
qapi/schema: declare type for QAPISchemaArrayType.element_type
A QAPISchemaArrayType's element type gets resolved only during .check(). We have QAPISchemaArrayType.__init__() initialize self.element_type = None, and .check() assign the actual type. Using .element_type before .check() is wrong, and hopefully crashes due to the value being None. Works.
However, it makes for awkward typing. With .element_type: Optional[QAPISchemaType], mypy is of course unable to see that it's None before .check(), and a QAPISchemaType after. To help it over the hump, we'd have to assert self.element_type is not None before all the (valid) uses. The assertion catches invalid uses, but only at run time; mypy can't flag them.
Instead, declare .element_type in .__init__() as QAPISchemaType *without* initializing it. Using .element_type before .check() now certainly crashes, which is an improvement. Mypy still can't flag invalid uses, but that's okay.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-8-armbru@redhat.com>
show more ...
|
ec103961 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: declare type for QAPISchemaObjectTypeMember.type
A QAPISchemaObjectTypeMember's type gets resolved only during .check(). We have QAPISchemaObjectTypeMember.__init__() initialize self.ty
qapi/schema: declare type for QAPISchemaObjectTypeMember.type
A QAPISchemaObjectTypeMember's type gets resolved only during .check(). We have QAPISchemaObjectTypeMember.__init__() initialize self.type = None, and .check() assign the actual type. Using .type before .check() is wrong, and hopefully crashes due to the value being None. Works.
However, it makes for awkward typing. With .type: Optional[QAPISchemaType], mypy is of course unable to see that it's None before .check(), and a QAPISchemaType after. To help it over the hump, we'd have to assert self.type is not None before all the (valid) uses. The assertion catches invalid uses, but only at run time; mypy can't flag them.
Instead, declare .type in .__init__() as QAPISchemaType *without* initializing it. Using .type before .check() now certainly crashes, which is an improvement. Mypy still can't flag invalid uses, but that's okay.
Addresses typing errors such as these:
qapi/schema.py:657: error: "None" has no attribute "alternate_qtype" [attr-defined] qapi/schema.py:662: error: "None" has no attribute "describe" [attr-defined]
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-7-armbru@redhat.com>
show more ...
|
2418d1c4 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi: create QAPISchemaDefinition
Include entities don't have names, but we generally expect "entities" to have names. Reclassify all entities with names as *definitions*, leaving the nameless inclu
qapi: create QAPISchemaDefinition
Include entities don't have names, but we generally expect "entities" to have names. Reclassify all entities with names as *definitions*, leaving the nameless include entities as QAPISchemaEntity instances.
This is primarily to help simplify typing around expectations of what callers expect for properties of an "entity".
Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-6-armbru@redhat.com>
show more ...
|
ce7fde06 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/schema: add pylint suppressions
With this patch, pylint is happy with the file, so enable it in the configuration.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <a
qapi/schema: add pylint suppressions
With this patch, pylint is happy with the file, so enable it in the configuration.
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-5-armbru@redhat.com>
show more ...
|
cebc1881 | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi: sort pylint suppressions
Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Marku
qapi: sort pylint suppressions
Suggested-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-4-armbru@redhat.com>
show more ...
|
2daf52df | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/parser: shush up pylint
Shhh!
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <2
qapi/parser: shush up pylint
Shhh!
Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-3-armbru@redhat.com>
show more ...
|
4f8f199f | 15-Mar-2024 |
John Snow <jsnow@redhat.com> |
qapi/parser: fix typo - self.returns.info => self.errors.info
Small copy-pasto. The correct info field to use in this conditional block is self.errors.info.
Fixes: 3a025d3d1ffa Signed-off-by: John
qapi/parser: fix typo - self.returns.info => self.errors.info
Small copy-pasto. The correct info field to use in this conditional block is self.errors.info.
Fixes: 3a025d3d1ffa Signed-off-by: John Snow <jsnow@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240315152301.3621858-2-armbru@redhat.com>
show more ...
|
ef929281 | 12-Mar-2024 |
Philippe Mathieu-Daudé <philmd@linaro.org> |
qapi: Inline and remove QERR_INVALID_PARAMETER_TYPE definition
Address the comment added in commit 4629ed1e98 ("qerror: Finally unused, clean up"), from 2015:
/* * These macros will go away, p
qapi: Inline and remove QERR_INVALID_PARAMETER_TYPE definition
Address the comment added in commit 4629ed1e98 ("qerror: Finally unused, clean up"), from 2015:
/* * These macros will go away, please don't use * in new code, and do not add new ones! */
Manual changes (escaping the format in qapi/visit.py).
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240312141343.3168265-8-armbru@redhat.com> Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
show more ...
|
b40b8eb6 | 21-Feb-2024 |
Michael Roth <michael.roth@amd.com> |
scripts/update-linux-headers: Add bits.h to file imports
Signed-off-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> |
66210a1a | 18-Feb-2024 |
Michael Roth <michael.roth@amd.com> |
scripts/update-linux-headers: Add setup_data.h to import list
Data structures like struct setup_data have been moved to a separate setup_data.h header which bootparam.h relies on. Add setup_data.h t
scripts/update-linux-headers: Add setup_data.h to import list
Data structures like struct setup_data have been moved to a separate setup_data.h header which bootparam.h relies on. Add setup_data.h to the cp_portable() list and sync it along with the other header files.
Note that currently struct setup_data is stripped away as part of generating bootparam.h, but that handling is no currently needed for setup_data.h since it doesn't pull in many external headers/dependencies. However, QEMU currently redefines struct setup_data in hw/i386/x86.c, so that will need to be removed as part of any header update that pulls in the new setup_data.h to avoid build bisect breakage.
Because <asm/setup_data.h> is the first architecture specific #include in include/standard-headers/, add a new sed substitution to rewrite asm/ include to the standard-headers/asm-* subdirectory for the current architecture.
And while at it, remove asm-generic/kvm_para.h from the list of allowed includes: it does not have a matching substitution, and therefore it would not be possible to use it on non-Linux systems where there is no /usr/include/asm-generic/ directory.
Signed-off-by: Michael Roth <michael.roth@amd.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
081340d1 | 08-Jan-2024 |
Daniel P. Berrangé <berrange@redhat.com> |
tracetool: remove redundant --target-type / --target-name args
The --target-type and --target-name args are used to construct the default probe prefix if '--probe-prefix' is not given. The meson.bui
tracetool: remove redundant --target-type / --target-name args
The --target-type and --target-name args are used to construct the default probe prefix if '--probe-prefix' is not given. The meson.build will always pass '--probe-prefix', so the other args are effectively redundant.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: John Snow <jsnow@redhat.com> Message-id: 20240108171356.1037059-2-berrange@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
show more ...
|
89126b6d | 09-Mar-2024 |
Peter Maydell <peter.maydell@linaro.org> |
Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2024-03-09
# -----BEGIN PGP SIGNATURE----- # # iQFDBAABCAAtFiEEe3O61ovnosKJMUsicBtPaxppPlkFAmXshtI
Merge tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu into staging
trivial patches for 2024-03-09
# -----BEGIN PGP SIGNATURE----- # # iQFDBAABCAAtFiEEe3O61ovnosKJMUsicBtPaxppPlkFAmXshtIPHG1qdEB0bHMu # bXNrLnJ1AAoJEHAbT2saaT5ZMFUIAKTd1rYzRs6x4wXitaWbYIIs2d6UB/HLbzz2 # BVHZwoYqsW3TuNFJp4njHhexZ76nFlT8xMuOKB5tAm4KOmqOdxS/mfThuSGsWGP7 # CAk35ENOMQbii/jp6tqawop+H0rVMSJjBrkU4vLRAtQ7g1ISnX6tJi3wiyS+FtHq # 9eIfgJgM77tvq6RLPZTUrUBevMWQfjMcvXmMnYqL4Z1dnibIb5/R3RKAnEc4CUoS # hMw94wBcq+ZOQNPnY7d+WioKq7JcSWX7UW5NuHo+C+G83nq1/5vE8Oe2kNwzFyDL # 9sIqL8bz6v8iiqcVMIBykSAZhYH9QEuVRJso18UE5w0B8k4CQcM= # =dIAF # -----END PGP SIGNATURE----- # gpg: Signature made Sat 09 Mar 2024 15:57:06 GMT # gpg: using RSA key 7B73BAD68BE7A2C289314B22701B4F6B1A693E59 # gpg: issuer "mjt@tls.msk.ru" # gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>" [full] # gpg: aka "Michael Tokarev <mjt@corpit.ru>" [full] # gpg: aka "Michael Tokarev <mjt@debian.org>" [full] # Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5 # Subkey fingerprint: 7B73 BAD6 8BE7 A2C2 8931 4B22 701B 4F6B 1A69 3E59
* tag 'pull-trivial-patches' of https://gitlab.com/mjt0k/qemu: docs/acpi/bits: add some clarity and details while also improving formating hw/mem/cxl_type3: Fix problem with g_steal_pointer() hw/pci-bridge/cxl_upstream: Fix problem with g_steal_pointer() hw/cxl/cxl-cdat: Fix type of buf in ct3_load_cdat() qerror: QERR_DEVICE_IN_USE is no longer used, drop blockdev: Fix block_resize error reporting for op blockers char: Slightly better error reporting when chardev is in use make-release: switch to .xz format by default hw/scsi/lsi53c895a: Fix typo in comment hw/vfio/pci.c: Make some structure static replay: Improve error messages about configuration conflicts
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
show more ...
|
9bc9e951 | 04-Mar-2024 |
Michael Tokarev <mjt@tls.msk.ru> |
make-release: switch to .xz format by default
For a long time, we provide two compression formats in the download area, .bz2 and .xz. There's absolutely no reason to provide two in parallel, .xz co
make-release: switch to .xz format by default
For a long time, we provide two compression formats in the download area, .bz2 and .xz. There's absolutely no reason to provide two in parallel, .xz compresses better, and all the links we use points to .xz. Downstream distributions mostly use .xz too.
For the release maintenance providing two formats is definitely extra burden too.
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
show more ...
|
2f3e5e4c | 04-Mar-2024 |
Paolo Bonzini <pbonzini@redhat.com> |
run-coverity-scan: add --check-upload-only option
Add an option to check if upload is permitted without actually attempting a build. This can be useful to add a third outcome beyond success and fai
run-coverity-scan: add --check-upload-only option
Add an option to check if upload is permitted without actually attempting a build. This can be useful to add a third outcome beyond success and failure---namely, a CI job can self-cancel if the uploading quota has been reached.
There is a small change here in that a failure to do the upload check changes the exit code from 1 to 99. 99 was chosen because it is what Autotools and Meson use to represent a problem in the setup (as opposed to a failure in the test).
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
show more ...
|
e1f684ea | 27-Feb-2024 |
Markus Armbruster <armbru@redhat.com> |
qapi: Reject "Returns" section when command doesn't return anything
Signed-off-by: Markus Armbruster <armbru@redhat.com> Message-ID: <20240227113921.236097-14-armbru@redhat.com> |