[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 00/15] hw: expand DEFINE_MACHINE to explicit TypeInfo registration
- To: BALATON Zoltan <balaton@xxxxxxxxxx>
- From: Yonggang Luo <luoyonggang@xxxxxxxxx>
- Date: Sat, 31 Oct 2026 22:12:20 +0800
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :reply-to:in-reply-to:references:mime-version:dkim-signature; bh=pUOpZRf0p30wCsLBnhRcgac97jM7shsYjyb+5CboCrE=; fh=7vRXhiVoUPRCCwRqKs6J8bIftUypVU/D6vh0Sy/TYq8=; b=QnaTsX+2l1qbufak3Ed65XhaLVN3EJEOsi5Us0lD7vRPtA6lgBR9bQvJPw7UENPpG8 zGbiuSR5LLseAannB8h7kGlrJH540YTyobReQMCoPztugfLWC8WD3zxbRC2CkTFbtNJm zfyI0uz/mmDyljMcQZ+wAybY12rbBssMFFmOnQtcCGi+DiCMZkleGiaW6URDujWI+IpQ Fr7khXTY+dnoNB/pq1DlwwERV8Rwx/H6xMI2OeuFJXdX8UJN7M5hqHWxA19DLXH/tm08 nJbRBMIU0EIGnFAeG6Sa9XYk1UPzR+IDk+jesPPlfXvtLZO6MqckhsNHxyI+xRGWtFLD d8Mw==; darn=lists.xenproject.org
- Arc-seal: i=1; a=rsa-sha256; t=1793455953; cv=none; d=google.com; s=arc-20260327; b=mseYNO/VWOhSdfU4CN740i0nKn1V4Pk9mjxDpAhQ7rhTLZVoFXIw/USwGXmHvqzPW9 GJnbOMPg+CKXgzDpz/xf5YPcOzLfAy+wlE4hdoFFHuyMHkW5Mi5nEtflwwYTZ0Aqy12J ZzHtg87t0dJXlU4ZYx2pkVpK/9pEeZiLc146IavCHse6ZLRTsYmZp+OZaUa/y44I3QOi tl82l6ulHd20L/+6iJUA9/WZN+VXb9a5La0Emd11jJVo5C5plTd/EUuVNujzPlOKUcX4 37EFF49Ouqes2U98mEl/wm1sfA9bpPHLGA5QoUKjtTi6MqGrSAFt3lNyOv85fQIXbgHw fzZA==
- Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=20260707 header.d=gmail.com header.i="@gmail.com" header.h="Content-Transfer-Encoding:Content-Type:Cc:To:Subject:Message-ID:Date:From:Reply-To:In-Reply-To:References:MIME-Version"
- Cc: Pierrick Bouvier <pierrick.bouvier@xxxxxxxxxxxxxxxx>, qemu-devel@xxxxxxxxxx, Anthony PERARD <anthony@xxxxxxxxxxxxxx>, Felipe Balbi <balbi@xxxxxxxxxx>, Aleksandar Rikalo <arikalo@xxxxxxxxx>, Philippe Mathieu-Daude <philmd@xxxxxxxxx>, Antony Pavlov <antonynpavlov@xxxxxxxxx>, Daniel Henrique Barboza <daniel.barboza@xxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Subbaraya Sundeep <sundeep.lkml@xxxxxxxxx>, Hervé Poussineau <hpoussin@xxxxxxxxxxx>, Max Filippov <jcmvbkbc@xxxxxxxxx>, Niek Linnenbank <nieklinnenbank@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx, qemu-riscv@xxxxxxxxxx, Jean-Christophe Dubois <jcd@xxxxxxxxxxxxxxx>, qemu-ppc@xxxxxxxxxx, Alexandre Iooss <erdnaxe@xxxxxxxxx>, Weiwei Li <liwei1518@xxxxxxxxx>, Zhao Liu <zhao1.liu@xxxxxxxxx>, Jiaxun Yang <jiaxun.yang@xxxxxxxxxxx>, Strahinja Jankovic <strahinja.p.jankovic@xxxxxxxxx>, Philippe Mathieu-Daudé <philmd@xxxxxxxxxxxxxxxx>, Thomas Huth <th.huth+qemu@xxxxxxxxx>, Clément Chigot <chigot@xxxxxxxxxxx>, Mark Cave-Ayland <mark.cave-ayland@xxxxxxxxxxxx>, Yoshinori Sato <yoshinori.sato@xxxxxxxxx>, Frederic Konrad <konrad.frederic@xxxxxxxx>, Palmer Dabbelt <palmer@xxxxxxxxxxx>, Peter Maydell <peter.maydell@xxxxxxxxxx>, Chao Liu <chao.liu@xxxxxxxxxxxxxxxxxx>, Sai Pavan Boddu <sai.pavan.boddu@xxxxxxx>, Alistair Francis <alistair@xxxxxxxxxxxxx>, Huacai Chen <chenhuacai@xxxxxxxxxx>, Aurelien Jarno <aurelien@xxxxxxxxxxx>, Gaurav Sharma <gaurav.sharma_7@xxxxxxx>, "Edgar E. Iglesias" <edgar.iglesias@xxxxxxxxx>, Richard Henderson <richard.henderson@xxxxxxxxxx>, Alistair Francis <alistair.francis@xxxxxxx>, Artyom Tarasenko <atar4qemu@xxxxxxxxx>, qemu-arm@xxxxxxxxxx
- Delivery-date: Sat, 31 Oct 2026 14:12:44 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Sat, Oct 31, 2026 at 8:42 PM BALATON Zoltan <balaton@xxxxxxxxxx> wrote:
>
> On Fri, 30 Oct 2026, 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.
> >
> >> Regards,
> >> BALATON Zoltan
> >>
> >>> This series expands every caller first, with no behavior change, so the
> >>> follow-up only replaces the type_register_static() call.
> >>>
> >>> Each machine file gains a class_init function, a TypeInfo, and a
> >>> type_init
> >>> function that calls type_register_static(). The last patch removes
> >>> DEFINE_MACHINE* and DEFINE_SECURE_MACHINE* from include/hw/core/boards.h.
>
> Macros help reading the code not saving typing. If the actual
> functionality is buried in a lot of boiler plate it's harder to understand
> and spot bugs so putting the unintresting boiler plate behind a macro is
> better even if you need a separate version for different cases. Then the
> code that uses the macro will be much more obvious and not just a lot of
I think mainly because DEFINE_MACHINE* and DEFINE_SECURE_MACHINE* are
not defined properly
that causes them to not be extended easily.
DEFINE_TYPES is another example, use them can extend easily, how about
always use DEFINE_TYPES?
Or add a DEFINE_TYPE to replace DEFINE_MACHINE* and DEFINE_SECURE_MACHINE*?
> boiler plate.
>
> Regards,
> BALATON Zoltan
--
此致
礼
罗勇刚
Yours
sincerely,
Yonggang Luo
|