From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Yonggang Luo <luoyonggang@gmail.com>
Cc: "BALATON Zoltan" <balaton@eik.bme.hu>,
"Pierrick Bouvier" <pierrick.bouvier@oss.qualcomm.com>,
qemu-devel@nongnu.org, "Anthony PERARD" <anthony@xenproject.org>,
"Felipe Balbi" <balbi@kernel.org>,
"Aleksandar Rikalo" <arikalo@gmail.com>,
"Philippe Mathieu-Daude" <philmd@mailo.com>,
"Antony Pavlov" <antonynpavlov@gmail.com>,
"Daniel Henrique Barboza" <daniel.barboza@oss.qualcomm.com>,
"Stefano Stabellini" <sstabellini@kernel.org>,
"Subbaraya Sundeep" <sundeep.lkml@gmail.com>,
"Hervé Poussineau" <hpoussin@reactos.org>,
"Max Filippov" <jcmvbkbc@gmail.com>,
"Niek Linnenbank" <nieklinnenbank@gmail.com>,
xen-devel@lists.xenproject.org, qemu-riscv@nongnu.org,
"Jean-Christophe Dubois" <jcd@tribudubois.net>,
qemu-ppc@nongnu.org, "Alexandre Iooss" <erdnaxe@crans.org>,
"Weiwei Li" <liwei1518@gmail.com>,
"Zhao Liu" <zhao1.liu@intel.com>,
"Jiaxun Yang" <jiaxun.yang@flygoat.com>,
"Strahinja Jankovic" <strahinja.p.jankovic@gmail.com>,
"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
"Thomas Huth" <th.huth+qemu@posteo.eu>,
"Clément Chigot" <chigot@adacore.com>,
"Mark Cave-Ayland" <mark.cave-ayland@ilande.co.uk>,
"Yoshinori Sato" <yoshinori.sato@nifty.com>,
"Frederic Konrad" <konrad.frederic@yahoo.fr>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Chao Liu" <chao.liu@processmission.com>,
"Sai Pavan Boddu" <sai.pavan.boddu@amd.com>,
"Alistair Francis" <alistair@alistair23.me>,
"Huacai Chen" <chenhuacai@kernel.org>,
"Aurelien Jarno" <aurelien@aurel32.net>,
"Gaurav Sharma" <gaurav.sharma_7@nxp.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
"Richard Henderson" <richard.henderson@linaro.org>,
"Alistair Francis" <alistair.francis@wdc.com>,
"Artyom Tarasenko" <atar4qemu@gmail.com>,
qemu-arm@nongnu.org
Subject: Re: [PATCH 00/15] hw: expand DEFINE_MACHINE to explicit TypeInfo registration
Date: Tue, 3 Nov 2026 13:55:07 +0000 [thread overview]
Message-ID: <aunnuwhsx9ZOOXBX@redhat.com> (raw)
In-Reply-To: <CAE2XoE_P2mZAT8wZwzFsTqJTK8nxNSSqJRrOM2T-AJkQjwJHBw@mail.gmail.com>
On Tue, Nov 03, 2026 at 09:48:44PM +0800, Yonggang Luo wrote:
> On Tue, Nov 3, 2026 at 9:23 PM BALATON Zoltan <balaton@eik.bme.hu> wrote:
> >
> > On Tue, 3 Nov 2026, Yonggang Luo wrote:
> > > On Tue, Nov 3, 2026 at 4:16 PM Daniel P. Berrangé <berrange@redhat.com> wrote:
> > >>
> > >> On Fri, Oct 30, 2026 at 05:51:44PM -0800, Pierrick Bouvier wrote:
> > >>> On 10/30/2026 4:09 PM, BALATON Zoltan wrote:
> > >>>> On Fri, 30 Oct 2026, Yonggang Luo wrote:
> > >>>>> DEFINE_MACHINE and DEFINE_MACHINE_EXTENDED hide the TypeInfo and the
> > >>>>> type_init
> > >>>>> function that calls type_register_static(). A later change needs to
> > >>>>> pass a
> > >>>>
> > >>>> That's the point of the macro to hide the boiler plate code.
> > >>>>
> > >>>>> target mask into that registration, and the macros have no parameter
> > >>>>> for it.
> > >>>>
> > >>>> Couldn't you just change the macros to take that parameter instead of
> > >>>> expanding it everywhere?
> > >>>>
> > >>>
> > >>> Problem of macros is that they don't have default parameters, so you
> > >>> need variants for everything:
> > >>>
> > >>> DEFINE_MACHINE
> > >>> DEFINE_MACHINE_EXTENDED
> > >>> DEFINE_MACHINE_WITH_INTERFACES
> > >>> DEFINE_MACHINE_WITH_INTERFACE_ARRAY
> > >>> and now would need a new variant, with variant for other existing ones.
> > >>>
> > >>> In the end, it's just simpler to remove this and add the boilerplate.
> > >>> It's written once and never modified, so using a macro just save typing
> > >>> those lines once.
> > >>
> > >> For each machine, it is only written once, but we add machines
> > >> over time, and every time a new machine is added the code style
> > >> is slightly different. We introduced all the variuos DEFINE_*
> > >> macros for QOM to better ensure consistent style and usage as
> > >> new code is added over time.
> > >
> > > I understand that the DEFINE_* macros are bloating because of this.
> > > Indeed currently the only two macros used are "DEFINE_MACHINE" and
> > > "DEFINE_MACHINE_EXTENDED"
> >
> > There are a few machines using some others but these are the most used.
> > That suggests maybe we should change the convenience wrappers to match
> > what machines need but DEFINE_MACHINE_EXTENDED is meant to be the one that
> > allows all parameters which should be rarely needed.
> >
> > > ; each time people want to add a new attribute, the macros is twiced.
> >
> > Not necessarily. The SECURE parameter did that to preserve previous
> > behaviour but if you add new parameter changing all callers (which is the
> > same as expanding the macro that would also change all callers) then it's
> > just a new parameter added not changing the number of DEFINE_MACHINE*
> > wrappers. Rearranging the wrappers to make DEFINE_MACHINE_EXTENDED used
> > less is an independent change.
> >
> > > And the usage of DEFINE_MACHINE_EXTENDED is rare and can be replaced
> > > with DEFINE_TYPES or TypeInfo
> > > and be more explicit. When we used as macro parameter, we need think
> >
> > But that defies the purpose of hiding the QOM boiler plate as much as
> > possible. New people are confused by QOM and it's easier for them to look
> > up documentation on the DEFINE_MACHINE* macros to see what parameter is
> > what and not care about how it's stored in QOM TypeInfo or what is that
> > at all.
> >
> > > what's that parameter means, and for
> > > TypeInfo, we can directly know what that member is about(because we
> > > are assigned with the member name).
> >
> > The parameter also has a name and documentation so it's not simpler to
> > look up TypeInfo than look at the macro definition or docs. In fact it's
> > harder to guess from TypeInfo as then you also need to get into QOM.
> >
> > > That's why I suggest keeping a single DEFINE_MACHINE, just like
> > > DEFINE_TYPES; as they are the most
> > > used macros(and simple enough), and won't suffer from changes much.
> >
> > That means exposing all the boiler plate for all machines other than the
> > simplest case. I think it would be better to keep DEFINE_MACHINE_EXTENDED
> > but maybe rethink the existing wrappers and drop unused ones and maybe add
> > new ones that reduce the usage of DEFINE_MACHINE_EXTENDED but still keep
> > the boiler plate hidden.
>
> Thanks, I'll go this way, remove unused macros, and keep DEFINE_MACHINE_EXTENDED
> and extend both DEFINE_MACHINE_EXTENDED DEFINE_MACHINE supports
> "targets" or "arch_mask" parameter.
Given that we don't need to do general per-arch type filtering in
QOM, we could just move 'is_available' out of TypeInfo, and into the
MachineClass, so it is a regular class level property, which can be
set in the class_init methods, and thus avoid any changes to the
DEFINE_MACHINE macros.
With regards,
Daniel
--
|: https://berrange.com ~~ https://hachyderm.io/@berrange :|
|: https://libvirt.org ~~ https://entangle-photo.org :|
|: https://pixelfed.art/berrange ~~ https://fstop138.berrange.com :|
next prev parent reply other threads:[~2026-11-03 13:56 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-30 15:15 [PATCH 00/15] hw: expand DEFINE_MACHINE to explicit TypeInfo registration Yonggang Luo
2026-10-30 15:15 ` [PATCH 01/15] hw/alpha: expand DEFINE_MACHINE in dp264.c Yonggang Luo
2026-10-30 15:15 ` [PATCH 02/15] hw/m68k: expand DEFINE_MACHINE for M68K machines Yonggang Luo
2026-10-30 15:15 ` [PATCH 03/15] hw/microblaze: expand DEFINE_MACHINE for MicroBlaze Yonggang Luo
2026-10-30 15:15 ` [PATCH 04/15] hw/tricore: expand DEFINE_MACHINE in tricore_testboard.c Yonggang Luo
2026-10-30 15:15 ` [PATCH 05/15] hw/arm: expand DEFINE_MACHINE for ARM machines Yonggang Luo
2026-10-30 15:15 ` [PATCH 06/15] hw/riscv: expand DEFINE_MACHINE for RISC-V machines Yonggang Luo
2026-10-30 15:15 ` [PATCH 07/15] hw/core/null-machine: expand DEFINE_MACHINE Yonggang Luo
2026-10-30 15:15 ` [PATCH 08/15] hw/mips: expand DEFINE_MACHINE for MIPS machines Yonggang Luo
2026-10-30 15:15 ` [PATCH 09/15] hw/ppc: expand DEFINE_MACHINE for PowerPC machines Yonggang Luo
2026-10-30 15:15 ` [PATCH 10/15] hw/sh4: expand DEFINE_MACHINE in r2d.c Yonggang Luo
2026-10-30 15:15 ` [PATCH 11/15] hw/sparc: expand DEFINE_MACHINE in leon3.c Yonggang Luo
2026-10-30 15:15 ` [PATCH 12/15] hw/xenpv: expand DEFINE_MACHINE in xen_machine_pv.c Yonggang Luo
2026-10-30 15:15 ` [PATCH 13/15] hw/xtensa: expand DEFINE_MACHINE in sim.c Yonggang Luo
2026-10-30 15:15 ` [PATCH 14/15] hw/xtensa: expand DEFINE_MACHINE in virt.c Yonggang Luo
2026-10-30 15:15 ` [PATCH 15/15] hw/core/boards: remove unused DEFINE_MACHINE* macros Yonggang Luo
2026-10-30 17:49 ` [PATCH 00/15] hw: expand DEFINE_MACHINE to explicit TypeInfo registration Pierrick Bouvier
2026-10-31 0:09 ` BALATON Zoltan
2026-10-31 1:51 ` Pierrick Bouvier
2026-10-31 2:56 ` Yonggang Luo
2026-10-31 12:42 ` BALATON Zoltan
2026-10-31 14:12 ` Yonggang Luo
2026-10-31 17:06 ` BALATON Zoltan
2026-10-31 17:15 ` Yonggang Luo
2026-10-31 23:29 ` BALATON Zoltan
2026-11-01 3:11 ` Yonggang Luo
2026-11-01 20:57 ` BALATON Zoltan
2026-11-02 3:04 ` Yonggang Luo
2026-11-02 14:55 ` BALATON Zoltan
2026-11-02 19:52 ` Yonggang Luo
2026-11-03 13:13 ` BALATON Zoltan
2026-11-03 13:26 ` BALATON Zoltan
2026-11-03 13:54 ` Yonggang Luo
2026-11-02 3:06 ` Yonggang Luo
2026-11-01 3:26 ` Yonggang Luo
2026-11-03 8:15 ` Daniel P. Berrangé
2026-11-03 9:15 ` Yonggang Luo
2026-11-03 13:23 ` BALATON Zoltan
2026-11-03 13:48 ` Yonggang Luo
2026-11-03 13:55 ` Daniel P. Berrangé [this message]
2026-11-03 14:17 ` Yonggang Luo
2026-11-03 18:08 ` Yonggang Luo
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=aunnuwhsx9ZOOXBX@redhat.com \
--to=berrange@redhat.com \
--cc=alistair.francis@wdc.com \
--cc=alistair@alistair23.me \
--cc=anthony@xenproject.org \
--cc=antonynpavlov@gmail.com \
--cc=arikalo@gmail.com \
--cc=atar4qemu@gmail.com \
--cc=aurelien@aurel32.net \
--cc=balaton@eik.bme.hu \
--cc=balbi@kernel.org \
--cc=chao.liu@processmission.com \
--cc=chenhuacai@kernel.org \
--cc=chigot@adacore.com \
--cc=daniel.barboza@oss.qualcomm.com \
--cc=edgar.iglesias@gmail.com \
--cc=erdnaxe@crans.org \
--cc=gaurav.sharma_7@nxp.com \
--cc=hpoussin@reactos.org \
--cc=jcd@tribudubois.net \
--cc=jcmvbkbc@gmail.com \
--cc=jiaxun.yang@flygoat.com \
--cc=konrad.frederic@yahoo.fr \
--cc=liwei1518@gmail.com \
--cc=luoyonggang@gmail.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=nieklinnenbank@gmail.com \
--cc=palmer@dabbelt.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@mailo.com \
--cc=philmd@oss.qualcomm.com \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sai.pavan.boddu@amd.com \
--cc=sstabellini@kernel.org \
--cc=strahinja.p.jankovic@gmail.com \
--cc=sundeep.lkml@gmail.com \
--cc=th.huth+qemu@posteo.eu \
--cc=xen-devel@lists.xenproject.org \
--cc=yoshinori.sato@nifty.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 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.