From: Markus Armbruster <armbru@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: qemu-devel@nongnu.org, "Philippe Mathieu-Daudé" <f4bug@amsat.org>,
"Thomas Huth" <thuth@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Daniel P. Berrange" <berrange@redhat.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Cédric Le Goater" <clg@kaod.org>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Mark Burton" <mburton@qti.qualcomm.com>,
"Luc Michel" <luc@lmichel.fr>,
"Bernhard Beschow" <shentey@gmail.com>,
"Bin Meng" <bin.meng@windriver.com>,
"Alistair Francis" <Alistair.Francis@wdc.com>
Subject: Re: Can we unpoison CONFIG_FOO macros?
Date: Thu, 09 Feb 2023 11:43:55 +0100 [thread overview]
Message-ID: <874jrv6rv8.fsf@pond.sub.org> (raw)
In-Reply-To: <CAFEAcA8T1OA_WfbXATJDO+1kiL2_yfOtKg4PWdKfZQsDtcA_rA@mail.gmail.com> (Peter Maydell's message of "Tue, 7 Feb 2023 15:50:41 +0000")
Peter Maydell <peter.maydell@linaro.org> writes:
> On Tue, 7 Feb 2023 at 15:41, Markus Armbruster <armbru@redhat.com> wrote:
>> We have a boatload of CONFIG_FOO macros that may only be used in
>> target-dependent code. We use generated config-poison.h to enforce.
>>
>> This is a bit annoying in the QAPI schema. Let me demonstrate with an
>> example: QMP commands query-rocker, query-rocker-ports, and so forth.
>> These commands are useful only with "rocker" devices. They are
>> compile-time optional. hw/net/Kconfig:
>>
>> config ROCKER
>> bool
>> default y if PCI_DEVICES
>> depends on PCI && MSI_NONBROKEN
>>
>> The rocker device and QMP code is actually target-independent:
>> hw/net/meson.build puts it into softmmu_ss.
>>
>> Disabling the "rocker" device type ideally disables the rocker QMP
>> commands, too. Should be easy enough: 'if': 'CONFIG_FOO' in the QAPI
>> schema.
>>
>> Except that makes the entire code QAPI generates for rocker.json
>> device-dependent: it now contains #if defined(CONFIG_ROCKER), and
>> CONFIG_ROCKER is poisoned. The rocker code implementing monitor
>> commands also becomes device-dependent, because it includes generated
>> headers. We compile all that per target for no sane reason at all.
>> That's why we don't actually disable the commands.
>>
>> Not disabling them creates another problem: we have the commands always,
>> but their implementation depends on CONFIG_ROCKER. So we provide stubs
>> that always fail for use when CONFIG_ROCKER is off. Drawbacks: we
>> generate, compile and link useless code, and QAPI/QMP introspection is
>> less useful than it could be.
>
> If you want the introspection to be useful, then you need to
> make the appearance of the commands depend on what machine
> type and devices are created on the command line. There are
> lots of machine types where the rocker commands are irrelevant
> because they don't apply to that machine even though it happens
> that PCI_DEVICES got built into that QEMU executable.
>
> I think the underlying question is "what does it mean to be
> only building in a QMP command when a Kconfig value is set?".
> It doesn't mean "this command only appears when it's useful",
> so anybody introspecting with QMP has to handle the "command
> exists but doesn't do anything helpful" case anyway. My guess
> is that the check you're trying to do at compile time ought
> to be done at runtime somehow instead (which is a general
> theme for 'single system emulation executable' work).
For better or worse, QAPI/QMP introspection is compile-time static.
It's oblivious of run-time configuration and state.
You point out that the question "is rocker built into this binary" isn't
particularly interesting. You're right.
Still, it's a kind of question static introspection *should* be able to
answer. Due to the way our compile time configuration machinery works,
QAPI/QMP introspection can't actually answer it, and that irks me.
For the same reason, we can't fully disable things like rocker: the
generated QAPI code remains along with command stubs. Irks me, too.
Neither is a serious problem for us as far as I can tell. As I wrote:
> This isn't terrible. It still annoys me. I wonder whether Philippe's
> work on having a single qemu-system binary could improve things here.
next prev parent reply other threads:[~2023-02-09 10:44 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 15:39 Can we unpoison CONFIG_FOO macros? Markus Armbruster
2023-02-07 15:50 ` Peter Maydell
2023-02-09 10:43 ` Markus Armbruster [this message]
2023-02-07 20:54 ` Thomas Huth
2023-02-09 10:57 ` Markus Armbruster
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=874jrv6rv8.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=Alistair.Francis@wdc.com \
--cc=berrange@redhat.com \
--cc=bin.meng@windriver.com \
--cc=clg@kaod.org \
--cc=eduardo@habkost.net \
--cc=f4bug@amsat.org \
--cc=luc@lmichel.fr \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mburton@qti.qualcomm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=shentey@gmail.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 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.