From: Markus Armbruster <armbru@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>
Cc: qemu-devel@nongnu.org, qemu-riscv@nongnu.org,
"Anton Johansson" <anjo@rev.ng>,
qemu-s390x@nongnu.org, qemu-ppc@nongnu.org,
"Daniel P . Berrangé" <berrange@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Claudio Fontana" <cfontana@suse.de>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Zhao Liu" <zhao1.liu@intel.com>,
qemu-arm@nongnu.org, "Thomas Huth" <thuth@redhat.com>
Subject: Re: [RFC PATCH-for-9.1 00/21] qapi: Make @query-cpu-definitions command target-agnostic
Date: Tue, 26 Mar 2024 11:18:14 +0100 [thread overview]
Message-ID: <878r25qot5.fsf@pond.sub.org> (raw)
In-Reply-To: <20240315130910.15750-1-philmd@linaro.org> ("Philippe Mathieu-Daudé"'s message of "Fri, 15 Mar 2024 14:08:48 +0100")
Philippe Mathieu-Daudé <philmd@linaro.org> writes:
> Hi Alex, Markus,
>
> Markus mentioned QAPI problems with the heterogeneous emulation
> binary. My understanding is, while QAPI can use host-specific
> conditional (OS, library available, configure option), it
> shouldn't use target-specific ones.
"Shouldn't" is too strong in the current state of things. It can be
awkward, though.
Target-specific macros may be used only in target-specific code,
i.e. code that is compiled per target. To catch uses in
target-independent code, we poison them there; see exec/poison.h.
QAPI-generated .c are not normally compiled per target. To enable use
of target-specific macros in conditionals, we compile .c generated QAPI
submodules named *-target.json per target. This is a bit of a hack.
Since the same conditionals will also appear in the .h generated from
them, these headers can only be used in target-specific code.
Sometimes, these headers "infect" target-independent code: we need to
compile per target just for the headers. Awkward. I can dig out an
example if there's interest.
But what about possible future state of things?
The QAPI schema is compile-time static by design. QAPI conditionals
permit adjusting the schema for build configuration. Target-specific
conditionals adjust it for the build configuration of the
target-specific part. Each QEMU binary contains just one target's
target-specific part.
However, a single QEMU binary will contain several target-specific
parts, one per target it supports. The targets' QAPI schema adjustments
may conflict.
For a single binary, we need to resolve these conflicts.
Special case: QAPI definitions that exist only for some targets.
Example: command query-sev exists only for TARGET_I386. It's actually a
stub when CONFIG_SEV is off.
Obvious solution: make it exist if it needs to exist for any target
compiled into the binary. Requires command stubs for the other targets.
Example: query-sev now exists when the single binary supports x86. It's
a stub when CONFIG_SEV is off. It behaves like a stub when CONFIG_SEV
is on, but the machine isn't x86.
Drawback: introspection with query-qmp-schema becomes less precise.
When the binary supports just one target, introspection can answer
target-specific questions like "does this target support SEV?" With a
single binary, that's no longer possible.
Harmless enough for SEV, but consider query-cpu-model-expansion. The
command may support expansion types "full" and "static". Currently,
s390x supports both, ARM supports only "full", Loongarch only "static",
RISC-V only "full", and x86 supports both.
(I think. The documentation is incomplete:
# Some architectures may not support all expansion types. s390x
# supports "full" and "static". Arm only supports "full".
)
A management application may want to find out which expansion type is
supported. Right now, it can't. But we could improve the schema so it
can find out via introspection: define the expansion types only when
they're actually supported.
With a single binary, that's no longer possible: we have to define an
expansion type when *any* target supports it.
Such loss of introspection power is not a show-stopper, just something
we need to keep in mind.
> This series is an example on how to remove target specific
> bits from the @query-cpu-definitions command.
This is an instance of the special case with an additional twist: each
target defines its own QMP command handler.
> Target specific
> code is registered as CPUClass handlers, then a generic method
> is used, iterating over all targets built in.
>
> The first set of patches were already posted / reviewed last
> year.
>
> The PPC and S390X targets still need work (help welcomed),
> however the code is useful enough to be tested and see if this
> is a good approach.
>
> The only drawback is a change in QAPI introspection, because
> targets not implementing @query-cpu-definitions were returning
> "CommandNotFound".
The change is introspection is actually something else. Before the
series, query-qmp-schema returns a description of command
query-cpu-definitions exactly when the (single) target supports it.
Afterwards, it always returns one (I think).
The CommandNotFound change is a change in behavior when you try to
execute query-cpu-definitions, but the target doesn't support it.
Before, the command doesn't exist, and the QMP core duly replies
CommandNotFound. Afterwards, it does exist, but the target doesn't
implement the call back, so the command fails. I guess it fails with
GenericError. We could make it fail with CommandNotFound if we care.
> My view is this was an incomplete
> implementation, rather than a feature.
Feels fair (but I'm not an expert in this area).
next prev parent reply other threads:[~2024-03-26 10:18 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-15 13:08 [RFC PATCH-for-9.1 00/21] qapi: Make @query-cpu-definitions command target-agnostic Philippe Mathieu-Daudé
2024-03-15 13:08 ` [PATCH-for-9.1 01/21] target/i386: Declare CPU QOM types using DEFINE_TYPES() macro Philippe Mathieu-Daudé
2024-03-15 13:08 ` [PATCH-for-9.1 02/21] target/mips: " Philippe Mathieu-Daudé
2024-03-18 8:13 ` Zhao Liu
2024-03-15 13:08 ` [PATCH-for-9.1 03/21] target/ppc: " Philippe Mathieu-Daudé
2024-03-18 8:15 ` Zhao Liu
2024-03-15 13:08 ` [PATCH-for-9.1 04/21] target/sparc: " Philippe Mathieu-Daudé
2024-03-18 8:16 ` Zhao Liu
2024-03-15 13:08 ` [PATCH-for-9.1 05/21] cpus: Open code OBJECT_DECLARE_TYPE() in OBJECT_DECLARE_CPU_TYPE() Philippe Mathieu-Daudé
2024-03-18 8:31 ` Zhao Liu
2024-03-15 13:08 ` [PATCH-for-9.1 06/21] target/i386: Make X86_CPU common to new I386_CPU / X86_64_CPU types Philippe Mathieu-Daudé
2024-03-18 8:47 ` Zhao Liu
2024-03-26 10:57 ` Markus Armbruster
2024-03-26 12:17 ` Philippe Mathieu-Daudé
2024-03-15 13:08 ` [PATCH-for-9.1 07/21] target/mips: Make MIPS_CPU common to new MIPS32_CPU / MIPS64_CPU types Philippe Mathieu-Daudé
2024-03-19 18:12 ` Philippe Mathieu-Daudé
2024-03-15 13:08 ` [PATCH-for-9.1 08/21] target/sparc: Make SPARC_CPU common to new SPARC32_CPU/SPARC64_CPU types Philippe Mathieu-Daudé
2024-03-15 13:08 ` [PATCH-for-9.1 09/21] qapi: Merge machine-common.json with qapi/machine.json Philippe Mathieu-Daudé
2024-03-26 12:12 ` Markus Armbruster
2024-03-15 13:08 ` [PATCH-for-9.1 10/21] qapi: Make CpuModel* definitions target agnostic Philippe Mathieu-Daudé
2024-03-20 8:49 ` Philippe Mathieu-Daudé
2024-03-26 12:16 ` Markus Armbruster
2024-03-15 13:08 ` [PATCH-for-9.1 11/21] qapi: Make CpuDefinitionInfo " Philippe Mathieu-Daudé
2024-03-15 13:09 ` [PATCH-for-9.1 12/21] system: Introduce QemuArchBit enum Philippe Mathieu-Daudé
2024-03-15 13:09 ` [PATCH-for-9.1 13/21] system: Introduce cpu_typename_by_arch_bit() Philippe Mathieu-Daudé
2024-03-15 13:09 ` [RFC PATCH-for-9.1 14/21] system: Introduce QMP generic_query_cpu_definitions() Philippe Mathieu-Daudé
2024-03-26 12:54 ` Markus Armbruster
2024-03-26 13:28 ` Markus Armbruster
2024-03-29 13:03 ` Philippe Mathieu-Daudé
2024-04-02 9:37 ` Markus Armbruster
2024-03-15 13:09 ` [RFC PATCH-for-9.1 15/21] target/arm: Use " Philippe Mathieu-Daudé
2024-03-15 13:09 ` [RFC PATCH-for-9.1 16/21] target/loongarch: " Philippe Mathieu-Daudé
2024-03-15 13:09 ` [RFC PATCH-for-9.1 17/21] target/riscv: " Philippe Mathieu-Daudé
2024-03-15 13:09 ` [RFC PATCH-for-9.1 18/21] target/i386: " Philippe Mathieu-Daudé
2024-03-15 13:09 ` [PATCH-for-9.1 19/21] target/ppc: Factor ppc_add_alias_definitions() out Philippe Mathieu-Daudé
2024-03-20 5:07 ` Nicholas Piggin
2024-03-15 13:09 ` [RFC PATCH-for-9.1 20/21] target/ppc: Use QMP generic_query_cpu_definitions() Philippe Mathieu-Daudé
2024-03-15 13:09 ` [RFC PATCH-for-9.1 21/21] qapi: Make @query-cpu-definitions target-agnostic Philippe Mathieu-Daudé
2024-03-26 13:32 ` Markus Armbruster
2024-03-26 10:18 ` Markus Armbruster [this message]
2024-03-26 13:37 ` [RFC PATCH-for-9.1 00/21] qapi: Make @query-cpu-definitions command target-agnostic Markus Armbruster
2025-03-11 7:56 ` Philippe Mathieu-Daudé
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=878r25qot5.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=alex.bennee@linaro.org \
--cc=anjo@rev.ng \
--cc=berrange@redhat.com \
--cc=cfontana@suse.de \
--cc=eduardo@habkost.net \
--cc=manos.pitsidianakis@linaro.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=zhao1.liu@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).