From: Pierrick Bouvier <pierrick.bouvier@linaro.org>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, stefanha@redhat.com,
"Michael Roth" <michael.roth@amd.com>,
pbonzini@redhat.com, berrange@redhat.com,
peter.maydell@linaro.org, thuth@redhat.com, jsnow@redhat.com,
philmd@linaro.org, "Alex Bennée" <alex.bennee@linaro.org>,
"Markus Armbruster" <armbru@redhat.com>,
"Pierrick Bouvier" <pierrick.bouvier@linaro.org>
Subject: [RFC PATCH 0/3] single-binary: make QAPI generated files common
Date: Thu, 24 Apr 2025 11:33:47 -0700 [thread overview]
Message-ID: <20250424183350.1798746-1-pierrick.bouvier@linaro.org> (raw)
Note: This RFC was posted to trigger a discussion around this topic, and it's
not expected to merge it as it is.
Context
=======
Linaro is working towards heterogeneous emulation, mixing several architectures
in a single QEMU process. The first prerequisite is to be able to build such a
binary, which we commonly name "single-binary" in our various series.
An (incomplete) list of series is available here:
https://patchew.org/search?q=project%3AQEMU+single-binary
We don't expect to change existing command line interface or any observable
behaviour, it should be identical to existing binaries. If anyone notices a
difference, it will be a bug.
The first objective we target is to combine qemu-system-arm and
qemu-system-aarch64 in a single binary, showing that we can build and link such
a thing. While being useless from a feature point of view, it allows us to make
good progress towards the goal, and unify two "distinct" architectures, and gain
experience on problems met.
Our current approach is to remove compilation units duplication to be able to
link all object files together. One of the concerned subsystem is QAPI.
QAPI
====
QAPI generated files contain conditional clauses to define various structures,
enums, and commands only for specific targets. This forces files to be
compiled for every target. What we try to do here is to build them only once
instead.
In the past, we identied that the best approach to solve this is to expose code
for all targets (thus removing all #if clauses), and stub missing
symbols for concerned targets.
This series build QAPI generated code once, by removing all TARGET_{arch} and
CONFIG_KVM clauses. What it does *not* at the moment is:
- prevent target specific commands to be visible for all targets
(see TODO comment on patch 2 explaining how to address this)
- nothing was done to hide all this from generated documentation
From what I understood, the only thing that matters is to limit qmp commands
visible. Exposing enums, structure, or events is not a problem, since they
won't be used/triggered for non concerned targets. Please correct me if this is
wrong, and if there are unexpected consequences for libvirt or other consumers.
Impact on code size
===================
There is a strong focus on keeping QEMU fast and small. Concerning performance,
there is no impact, as the only thing that would change is to conditionally
check current target to register some commands.
Concerning code size, you can find the impact on various qemu-system binaries
with optimized and stripped build.
upstream:
12588 ./build/qemu-system-s390x
83992 ./build/qemu-system-x86_64
31884 ./build/qemu-system-aarch64
upstream + this series:
12644 ./build/qemu-system-s390x (+56kB, +0.004%)
84076 ./build/qemu-system-x86_64 (+84kB, +0.001%)
31944 ./build/qemu-system-aarch64 (+60kB, +0.001%)
Feedback
========
The goal of this series is to be spark a conversation around following topics:
- Would you be open to such an approach? (expose all code, and restrict commands
registered at runtime only for specific targets)
- Are there unexpected consequences for libvirt or other consumers to expose
more definitions than what we have now?
- Would you recommend another approach instead? I experimented with having per
target generated files, but we still need to expose quite a lot in headers, so
my opinion is that it's much more complicated for zero benefit. As well, the
code size impact is more than negligible, so the simpler, the better.
Feel free to add anyone I could have missed in CC.
Regards,
Pierrick
Pierrick Bouvier (3):
qapi: add weak stubs for target specific commands
qapi: always expose TARGET_* or CONFIG_KVM code
qapi: make all generated files common
qapi/commands-weak-stubs.c | 38 ++++++++++++++++++++++++++++++++++++++
qapi/meson.build | 5 ++++-
scripts/qapi/commands.py | 4 ++++
scripts/qapi/common.py | 4 +++-
4 files changed, 49 insertions(+), 2 deletions(-)
create mode 100644 qapi/commands-weak-stubs.c
--
2.39.5
next reply other threads:[~2025-04-24 18:35 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-24 18:33 Pierrick Bouvier [this message]
2025-04-24 18:33 ` [RFC PATCH 1/3] qapi: add weak stubs for target specific commands Pierrick Bouvier
2025-04-24 18:52 ` Pierrick Bouvier
2025-04-24 18:33 ` [RFC PATCH 2/3] qapi: always expose TARGET_* or CONFIG_KVM code Pierrick Bouvier
2025-04-24 18:33 ` [RFC PATCH 3/3] qapi: make all generated files common Pierrick Bouvier
2025-04-24 20:31 ` Philippe Mathieu-Daudé
2025-04-24 21:08 ` Richard Henderson
2025-04-24 20:43 ` [RFC PATCH 0/3] single-binary: make QAPI " Philippe Mathieu-Daudé
2025-04-24 21:15 ` Richard Henderson
2025-04-24 22:22 ` Pierrick Bouvier
2025-04-24 20:44 ` Philippe Mathieu-Daudé
2025-04-25 7:35 ` Daniel P. Berrangé
2025-04-25 20:39 ` Pierrick Bouvier
2025-04-28 8:37 ` Daniel P. Berrangé
2025-04-28 15:54 ` Pierrick Bouvier
2025-04-25 22:16 ` Philippe Mathieu-Daudé
2025-04-26 4:53 ` Markus Armbruster
2025-04-25 15:38 ` Markus Armbruster
2025-04-25 21:07 ` Pierrick Bouvier
2025-04-25 21:13 ` Pierrick Bouvier
2025-04-26 6:21 ` Markus Armbruster
2025-04-28 16:05 ` Pierrick Bouvier
2025-04-29 7:43 ` Markus Armbruster
2025-04-29 8:37 ` Daniel P. Berrangé
2025-04-29 19:26 ` Pierrick Bouvier
2025-05-07 11:21 ` Markus Armbruster
2025-04-29 19:15 ` Pierrick Bouvier
2025-05-07 7:55 ` Markus Armbruster
2025-05-07 11:32 ` Daniel P. Berrangé
2025-05-07 19:00 ` Pierrick Bouvier
2025-05-07 18:54 ` Pierrick Bouvier
2025-04-28 10:25 ` Peter Krempa
2025-04-28 16:18 ` Pierrick Bouvier
2025-04-28 8:55 ` Peter Krempa
2025-04-28 11:07 ` Markus Armbruster
2025-04-28 12:48 ` Philippe Mathieu-Daudé
2025-04-28 16:35 ` Pierrick Bouvier
2025-04-29 8:23 ` Markus Armbruster
2025-04-29 9:20 ` Thomas Huth
2025-04-29 9:32 ` Daniel P. Berrangé
2025-04-29 9:39 ` Philippe Mathieu-Daudé
2025-04-29 19:48 ` Pierrick Bouvier
2025-04-30 5:40 ` Thomas Huth
2025-04-30 6:18 ` Pierrick Bouvier
2025-04-29 9:35 ` Philippe Mathieu-Daudé
2025-04-29 9:47 ` Daniel P. Berrangé
2025-04-29 19:57 ` Pierrick Bouvier
2025-04-29 20:11 ` Pierrick Bouvier
2025-04-29 12:04 ` BALATON Zoltan
2025-04-28 18:14 ` Stefan Hajnoczi
2025-04-28 19:25 ` Pierrick Bouvier
2025-04-28 19:54 ` Stefan Hajnoczi
2025-04-28 21:35 ` Pierrick Bouvier
2025-05-07 23:19 ` Pierrick Bouvier
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=20250424183350.1798746-1-pierrick.bouvier@linaro.org \
--to=pierrick.bouvier@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=armbru@redhat.com \
--cc=berrange@redhat.com \
--cc=jsnow@redhat.com \
--cc=michael.roth@amd.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=stefanha@redhat.com \
--cc=thuth@redhat.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).