qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
	qemu-devel@nongnu.org, alex.bennee@linaro.org,
	stefanha@redhat.com, peter.maydell@linaro.org,
	richard.henderson@linaro.org, pbonzini@redhat.com,
	jsnow@redhat.com, philmd@linaro.org, thuth@redhat.com,
	"Michael Roth" <michael.roth@amd.com>
Subject: Re: [PATCH 09/13] qapi: transform target specific 'if' in runtime checks
Date: Wed, 14 May 2025 09:13:16 +0200	[thread overview]
Message-ID: <87cycbacmr.fsf@pond.sub.org> (raw)
In-Reply-To: <e33c5751-6db2-4ca7-9a6e-b992a399e696@linaro.org> (Pierrick Bouvier's message of "Tue, 13 May 2025 15:52:39 -0700")

Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:

> On 5/13/25 12:08 AM, Markus Armbruster wrote:
>> Pierrick Bouvier <pierrick.bouvier@linaro.org> writes:
>> 
>>> On 5/9/25 11:57 PM, Markus Armbruster wrote:
>>>>> The build system would need generate an input document for the
>>>>> QAPI visitor that defines whether each constant is set to true
>>>>> or false, based on suitable CONFIG/TARGET conditions from meson.
>>>>
>>>> I think the conditions that are evaluated at build time in handwritten C
>>>> code (with #if) should also be evaluated at build time in generated C
>>>> code.
>>>>
>>>> Certain conditions are evaluated at build time in target-specific code,
>>>> and at runtime in target-independent code.  Again, I think handwritten
>>>> and generated code should work the same way.
>>>>
>>>> Thus, to eliminate target-specific QAPI-generated code, we either
>>>> evaluate them at runtime, or simply eliminate them.  Elsewhere, we've
>>>> come to the conclusion (I think) that the latter should do at least for
>>>> now, likely forever, so we should try that first.
>>>>
>>>
>>> I'm not sure if you mean you'd prefer to eradicate #if completely.
>> 
>> I do not!
>> 
>>> We have to keep in mind that some config host #if have to stay there, or
>>> they expose things that the rest of QEMU code is not supposed to see
>>> (hidden under those same CONFIG_ ifdef also).
>> 
>> Letting people configure their QEMU build is useful and must stay.
>> 
>> We provide this via conditional compilation, of complete source files
>> (done in meson), as well as within source files (#if in C and 'if' in
>> QAPI).
>> 
>>> So we would need both if and runtime_if.
>> 
>> I don't understand the need for runtime_if.  Can you give an example?
>>
>
> That is the point of this whole series, which explores introducing a 
> 'runtime' if in the schema, to keep it as it is today, while removing 
> target specific compile time defines.

Ah, I lost the wider context, sorry!

We identified three ways to deal with target-specific conditionals in a
single binary, and 'runtime_if' is one of them:

(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.

Both (2) and (3) keep the QAPI schema work as it does now.  None of us
likes (3) due to bloat and complexity.

The other two look both workable to me.  (2) keeps the QAPI schema work
exactly as it does now.  (1) is simpler, but the external interface
changes somewhat.  Its users seem to be okay with it.

So let's go with (1).

> It is another approach that one Daniel followed on his series.
>
> I invite you to give a quick read to this series, especially the related 
> commit introducing 'runtime_if' 
> (20250507231442.879619-2-pierrick.bouvier@linaro.org).

I can't afford a thorough review now, but I'll have a look, and I will
hold onto your series just in case.

> As well, I would appreciate if you could state clearly where we are 
> going with all this (or at least, where you *don't* want this to go), so 
> we can avoid spending time in the wrong direction.

The discussion was spread over multiple threads, which makes it hard to
follow.  I hope the conclusion is clear now.  If not, please ask for
further clarification.

> I am ok to pursue Daniel's approach, or continue the approach in the 
> current series, no strong opinion in my side, I am just trying to move 
> QAPI generated code out of the way for the single binary goal.

Understood!



  reply	other threads:[~2025-05-14  7:14 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-07 23:14 [PATCH 00/13] single-binary: make QAPI generated files common Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 01/13] qapi: introduce 'runtime_if' for QAPI json Pierrick Bouvier
2025-05-08  6:53   ` Philippe Mathieu-Daudé
2025-05-08 20:22     ` Pierrick Bouvier
2025-05-15  4:39   ` Markus Armbruster
2025-05-15 15:42     ` Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 02/13] qapi/introspect: generate schema as a QObject directly Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 03/13] qobject/qlit: allow to hide dict or list entries Pierrick Bouvier
2025-05-08 14:21   ` Daniel P. Berrangé
2025-05-08 20:25     ` Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 04/13] qapi/introspect: hide fields in schema Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 05/13] qapi/commands: register commands conditionally Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 06/13] qapi/visit: hide fields in JSON marshalling Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 07/13] qapi: add access to qemu/target-info.h Pierrick Bouvier
2025-05-08  6:57   ` Philippe Mathieu-Daudé
2025-05-07 23:14 ` [PATCH 08/13] qemu/target-info: implement missing helpers Pierrick Bouvier
2025-05-08  6:40   ` Philippe Mathieu-Daudé
2025-05-08 20:30     ` Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 09/13] qapi: transform target specific 'if' in runtime checks Pierrick Bouvier
2025-05-08  6:44   ` Philippe Mathieu-Daudé
2025-05-08 14:40   ` Daniel P. Berrangé
2025-05-08 20:48     ` Pierrick Bouvier
2025-05-10  6:57     ` Markus Armbruster
2025-05-13  0:36       ` Pierrick Bouvier
2025-05-13  7:08         ` Markus Armbruster
2025-05-13 22:52           ` Pierrick Bouvier
2025-05-14  7:13             ` Markus Armbruster [this message]
2025-05-14 16:54               ` Pierrick Bouvier
2025-05-14 14:09   ` Markus Armbruster
2025-05-14 16:50     ` Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 10/13] qapi: add weak stubs for target specific commands Pierrick Bouvier
2025-05-08  6:57   ` Philippe Mathieu-Daudé
2025-05-08 20:33     ` Pierrick Bouvier
2025-05-07 23:14 ` [PATCH 11/13] qapi: make all generated files common Pierrick Bouvier
2025-05-08  6:57   ` Philippe Mathieu-Daudé
2025-05-07 23:14 ` [PATCH 13/13] [ANNEX] build/qapi: after series Pierrick Bouvier
2025-05-07 23:33 ` [PATCH 00/13] single-binary: make QAPI generated files common 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=87cycbacmr.fsf@pond.sub.org \
    --to=armbru@redhat.com \
    --cc=alex.bennee@linaro.org \
    --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=pierrick.bouvier@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).