From: Markus Armbruster <armbru@redhat.com>
To: Zhao Liu <zhao1.liu@intel.com>
Cc: "Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Mark Burton" <mburton@qti.qualcomm.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Alessandro Di Federico" <ale@rev.ng>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Anton Johansson" <anjo@rev.ng>, "Brian Cain" <bcain@quicinc.com>,
"Daniel P. Berrange" <berrange@redhat.com>,
"Chao Peng" <chao.p.peng@linux.intel.com>,
"Neo Jia" <cjia@nvidia.com>, "Cédric Le Goater" <clg@kaod.org>,
"Wedgwood, Chris" <cw@f00f.org>,
dhedde@kalrayinc.com, "Eric Blake" <eblake@redhat.com>,
eblot@rivosinc.com,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Elena Ufimtseva" <elena.ufimtseva@oracle.com>,
"Auger Eric" <eric.auger@redhat.com>,
"Felipe Franciosi" <felipe@nutanix.com>,
iggy@theiggy.com, "Warner Losh" <imp@bsdimp.com>,
"Jan Kiszka" <jan.kiszka@web.de>,
"Jason Gunthorpe" <jgg@nvidia.com>,
"Jidong Xiao" <jidong.xiao@gmail.com>,
"Jim Shu" <jim.shu@sifive.com>,
"Joao Martins" <joao.m.martins@oracle.com>,
"Konrad Rzeszutek Wilk" <konrad.wilk@oracle.com>,
"Luc Michel" <luc@lmichel.fr>,
"Manos Pitsidianakis" <manos.pitsidianakis@linaro.org>,
"Max Chou" <max.chou@sifive.com>,
"Meirav Dean" <mdean@redhat.com>,
mimu@linux.vnet.ibm.com, "Ho, Nelson" <nelson.ho@windriver.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"QEMU Developers" <qemu-devel@nongnu.org>,
"Roberto Campesato" <rbc@meta.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Shameerali Kolothum Thodi"
<shameerali.kolothum.thodi@huawei.com>,
"Bernhard Beschow" <shentey@gmail.com>,
"Stefan Hajnoczi" <stefanha@gmail.com>,
"Thomas Huth" <thuth@redhat.com>,
"Wei Wang" <wei.w.wang@intel.com>,
z.huo@139.com, "LIU Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Wu, Zhiyong" <zwu.kernel@gmail.com>
Subject: Re: KVM/QEMU Community call 29/04/2025 agenda items?
Date: Thu, 08 May 2025 14:32:26 +0200 [thread overview]
Message-ID: <87plgjcmg5.fsf@pond.sub.org> (raw)
In-Reply-To: <aBxvmV7F+lI6YDGn@intel.com> (Zhao Liu's message of "Thu, 8 May 2025 16:47:21 +0800")
Zhao Liu <zhao1.liu@intel.com> writes:
> On Wed, May 07, 2025 at 05:11:39PM +0200, Markus Armbruster wrote:
>> Date: Wed, 07 May 2025 17:11:39 +0200
>> From: Markus Armbruster <armbru@redhat.com>
>> Subject: Re: KVM/QEMU Community call 29/04/2025 agenda items?
>>
>> Philippe Mathieu-Daudé <philmd@linaro.org> writes:
>>
>> > On 30/4/25 12:41, Markus Armbruster wrote:
>>
>> [...]
>>
>> >> Pierrick's stated goal is to have no noticable differences between the
>> >> single binary and the qemu-system-<target> it covers.
>> >>
>> >> We have two external interfaces to worry about: QMP and the command
>> >> line. Let's ignore the latter for now.
>> >>
>> >> Target-specific differences in *syntax* come from QAPI schema
>> >> conditionals with target-specific conditions. Example:
>> >>
>> >> { 'command': 'query-cpu-definitions', 'returns': ['CpuDefinitionInfo'],
>> >> 'if': { 'any': [ 'TARGET_PPC',
>> >> 'TARGET_ARM',
>> >> 'TARGET_I386',
>> >> 'TARGET_S390X',
>> >> 'TARGET_MIPS',
>> >> 'TARGET_LOONGARCH64',
>> >> 'TARGET_RISCV' ] } }
>> >>
>> >> This command is only defined for some targets.
>> >>
>> >> The value of query-qmp-schema reflects this: it has
>> >> query-cpu-definitions exactly when the condition is satisfied. The
>> >> condition is evaluated at compile-time, because that's how QAPI schema
>> >> 'if' works.
>> >>
>> >> Say we drop the condition and instead add an equivalent run-time
>> >> condition to command registration. This preserves behavior of command
>> >> execution. But query-qmp-schema now has query-cpu-definitions *always*.
>> >> This is a noticable difference. It may break management applications
>> >> that use query-qmp-schema to probe for the command.
>> >>
>> >> Moreover, conditionals aren't limited to commands. Example:
>> >>
>> >> { 'struct': 'CpuModelExpansionInfo',
>> >> 'data': { 'model': 'CpuModelInfo',
>> >> 'deprecated-props' : { 'type': ['str'],
>> >> ---> 'if': 'TARGET_S390X' } },
>> >> 'if': { 'any': [ 'TARGET_S390X',
>> >> 'TARGET_I386',
>> >> 'TARGET_ARM',
>> >> 'TARGET_LOONGARCH64',
>> >> 'TARGET_RISCV' ] } }
>> >>
>> >> Here we have a conditional member.
>>
>> [...]
>>
>> > IMHO conditionals should only depend on host / static configuration
>> > features, not features modifiable from the command line.
>>
>> This is how the QAPI schema works now.
>>
>> > (I'm always
>> > confused by KVM features published in the schema, but then you start
>> > your binary with -accel=tcg and still can run KVM specific commands
>> > via QMP, returning errors).
>>
>> Not exactly a ringing endorsement for keeping the QAPI schema work the
>> way it does now, isn't it? ;)
>>
>> The problem at hand is QAPI-generated files in a single binary.
>>
>> Pierrick posted "[RFC PATCH 0/3] single-binary: make QAPI generated
>> files common". The patches are flawed, but that's alright for RFC.
>>
>> In review, I pointed out three possible solutions, and discussed their
>> pros and cons:
>>
>> (1) Drop target-specific conditionals.
>>
>> (2) Replace them by run-time checks.
>>
>> (3) Have target-specific QAPI-generated code for multiple targets
>> coexist in the single binary.
>
> Thank you Markus for your nice summary! I also apologize to you and
> Philippe if I didn't understand correctly (I tried to look at
> Pierrick's and Philippe's work, but still worry about I may have wrong
> understanding :-) )
>
>> Both (1) and (3) keep the QAPI schema work as it does now.
>>
>> Pierrick's patches are an incomplete attempt at (2).
>
> I see.
>
>> Daniel made a case for (1). You and I actually discussed (1) before,
>> and I encouraged you to explore it.
>
> And I notice Philippe has 2 patches:
>
> (1) For QAPI, this is to drop target-specific cond:
>
> https://lore.kernel.org/qemu-devel/20250429100419.20427-1-philmd@linaro.org/
>
> I feel it's a smart way to make it optional.
>
> (2) Not for QAPI, but this is try to add runtime check:
>
> https://lore.kernel.org/qemu-devel/20250502214551.80401-5-philmd@linaro.org/
>
> I am thinking about how kvm-pmu-filter could be aligned with these
> current efforts in mail list.
>
> I can drop all the target conditions for KvmPmuEventFormat:
>
> { 'enum': 'KvmPmuEventFormat',
> 'data': ['raw', 'x86-select-umask', 'x86-masked-entry'] }
This is what you need to do if we pick solution (1).
> This is what you listed before and it is similar to the way in (1). But
> only (1) is not enough because I can't make these formats as optional
> (pls educate me if I'm wrong :-) ).
>
> Therefore, I think I need run-time check like Philippe did in (2), in
> my kvm-pmu.c file. Do you think so?
In general, not just for your KVM PMU filter work: dropping
target-specific conditionals makes the formerly conditional things exist
for targets where they didn't exist before. This commonly breaks the
build for these targets. To fix a target's build, we can either
implement things for the target, or make attempts to use them fail
cleanly.
> An additional question - about CONFIG_KVM - is that I see that it's all
> currently focused on solving target-specific problems, and I understand
> that it's not yet kvm-specific's turn.
>
> But kvm-pmu-filter does (or, may :-) ) need CONFIG_KVM. My initial
> thought is, is it possible to remove the CONFIG_KVM condition for
> kvm-pmu-filter in QAPI and use the same runtime check? But this would
> require accel-info as Philippe's work on target-info in [2]).
I'm afraid I don't understand your question.
>> We can certainly discuss this some more, but I'd prefer to review a
>> working solution instead.
>
> With so many options on the table, I'm a bit confused about the fate of
> kvm-pmu-filter. Should this case wait for the most appropriate option to
> come along, or could it move forward based on the status quo, and then
> consider the refactoring later with the final optimal option?
Up to you.
We'll hopefully reach consensus fairly soon. You might want to wait a
few days for that.
next prev parent reply other threads:[~2025-05-08 12:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-28 11:05 KVM/QEMU Community call 29/04/2025 agenda items? Alex Bennée
2025-04-28 12:57 ` Philippe Mathieu-Daudé
2025-04-29 10:09 ` Philippe Mathieu-Daudé
2025-04-29 14:24 ` Paolo Bonzini
2025-04-30 10:41 ` Markus Armbruster
2025-04-30 11:16 ` Daniel P. Berrangé
2025-05-07 8:24 ` Zhao Liu
2025-05-07 14:34 ` Philippe Mathieu-Daudé
2025-04-30 14:36 ` Philippe Mathieu-Daudé
2025-05-07 15:11 ` Markus Armbruster
2025-05-08 8:47 ` Zhao Liu
2025-05-08 12:32 ` Markus Armbruster [this message]
2025-05-08 14:09 ` Daniel P. Berrangé
2025-04-29 15:20 ` Alex Bennée
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=87plgjcmg5.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=ale@rev.ng \
--cc=alex.bennee@linaro.org \
--cc=alistair.francis@wdc.com \
--cc=anjo@rev.ng \
--cc=bcain@quicinc.com \
--cc=berrange@redhat.com \
--cc=chao.p.peng@linux.intel.com \
--cc=cjia@nvidia.com \
--cc=clg@kaod.org \
--cc=cw@f00f.org \
--cc=dhedde@kalrayinc.com \
--cc=eblake@redhat.com \
--cc=eblot@rivosinc.com \
--cc=edgar.iglesias@gmail.com \
--cc=eduardo@habkost.net \
--cc=elena.ufimtseva@oracle.com \
--cc=eric.auger@redhat.com \
--cc=felipe@nutanix.com \
--cc=iggy@theiggy.com \
--cc=imp@bsdimp.com \
--cc=jan.kiszka@web.de \
--cc=jgg@nvidia.com \
--cc=jidong.xiao@gmail.com \
--cc=jim.shu@sifive.com \
--cc=joao.m.martins@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=luc@lmichel.fr \
--cc=manos.pitsidianakis@linaro.org \
--cc=max.chou@sifive.com \
--cc=mburton@qti.qualcomm.com \
--cc=mdean@redhat.com \
--cc=mimu@linux.vnet.ibm.com \
--cc=nelson.ho@windriver.com \
--cc=paul.walmsley@sifive.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=rbc@meta.com \
--cc=richard.henderson@linaro.org \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=shentey@gmail.com \
--cc=stefanha@gmail.com \
--cc=thuth@redhat.com \
--cc=wei.w.wang@intel.com \
--cc=z.huo@139.com \
--cc=zhao1.liu@intel.com \
--cc=zhiwei_liu@linux.alibaba.com \
--cc=zwu.kernel@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.