From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Cc: "Daniel P. Berrangé" <berrange@redhat.com>,
"Thomas Huth" <thuth@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 06/22] hw/m68k: convert 'virt' machine definitions to use new macros
Date: Tue, 2 Jul 2024 07:00:56 +0200 [thread overview]
Message-ID: <20240702050112.35907-7-philmd@linaro.org> (raw)
In-Reply-To: <20240702050112.35907-1-philmd@linaro.org>
From: Daniel P. Berrangé <berrange@redhat.com>
This changes the DEFINE_VIRT_MACHINE macro to use the common
helpers for constructing versioned symbol names and strings,
bringing greater consistency across targets.
A DEFINE_VIRT_MACHINE_AS_LATEST helper is added so that it
is not required to pass 'false' for every single historical
machine type.
Reviewed-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240620165742.1711389-6-berrange@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/m68k/virt.c | 55 ++++++++++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 24 deletions(-)
diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c
index 09bc9bdfef..cd6ee692f7 100644
--- a/hw/m68k/virt.c
+++ b/hw/m68k/virt.c
@@ -335,99 +335,106 @@ static void virt_machine_register_types(void)
type_init(virt_machine_register_types)
-#define DEFINE_VIRT_MACHINE(major, minor, latest) \
- static void virt_##major##_##minor##_class_init(ObjectClass *oc, \
- void *data) \
+#define DEFINE_VIRT_MACHINE_IMPL(latest, ...) \
+ static void MACHINE_VER_SYM(class_init, virt, __VA_ARGS__)( \
+ ObjectClass *oc, \
+ void *data) \
{ \
MachineClass *mc = MACHINE_CLASS(oc); \
- virt_machine_##major##_##minor##_options(mc); \
- mc->desc = "QEMU " # major "." # minor " M68K Virtual Machine"; \
+ MACHINE_VER_SYM(options, virt, __VA_ARGS__)(mc); \
+ mc->desc = "QEMU " MACHINE_VER_STR(__VA_ARGS__) " M68K Virtual Machine"; \
if (latest) { \
mc->alias = "virt"; \
} \
} \
- static const TypeInfo machvirt_##major##_##minor##_info = { \
- .name = MACHINE_TYPE_NAME("virt-" # major "." # minor), \
- .parent = MACHINE_TYPE_NAME("virt"), \
- .class_init = virt_##major##_##minor##_class_init, \
- }; \
- static void machvirt_machine_##major##_##minor##_init(void) \
+ static const TypeInfo MACHINE_VER_SYM(info, virt, __VA_ARGS__) = \
{ \
- type_register_static(&machvirt_##major##_##minor##_info); \
+ .name = MACHINE_VER_TYPE_NAME("virt", __VA_ARGS__), \
+ .parent = MACHINE_TYPE_NAME("virt"), \
+ .class_init = MACHINE_VER_SYM(class_init, virt, __VA_ARGS__), \
+ }; \
+ static void MACHINE_VER_SYM(register, virt, __VA_ARGS__)(void) \
+ { \
+ type_register_static(&MACHINE_VER_SYM(info, virt, __VA_ARGS__)); \
} \
- type_init(machvirt_machine_##major##_##minor##_init);
+ type_init(MACHINE_VER_SYM(register, virt, __VA_ARGS__));
+
+#define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \
+ DEFINE_VIRT_MACHINE_IMPL(true, major, minor)
+#define DEFINE_VIRT_MACHINE(major, minor) \
+ DEFINE_VIRT_MACHINE_IMPL(false, major, minor)
static void virt_machine_9_1_options(MachineClass *mc)
{
}
-DEFINE_VIRT_MACHINE(9, 1, true)
+DEFINE_VIRT_MACHINE_AS_LATEST(9, 1)
static void virt_machine_9_0_options(MachineClass *mc)
{
virt_machine_9_1_options(mc);
compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len);
}
-DEFINE_VIRT_MACHINE(9, 0, false)
+DEFINE_VIRT_MACHINE(9, 0)
static void virt_machine_8_2_options(MachineClass *mc)
{
virt_machine_9_0_options(mc);
compat_props_add(mc->compat_props, hw_compat_8_2, hw_compat_8_2_len);
}
-DEFINE_VIRT_MACHINE(8, 2, false)
+DEFINE_VIRT_MACHINE(8, 2)
static void virt_machine_8_1_options(MachineClass *mc)
{
virt_machine_8_2_options(mc);
compat_props_add(mc->compat_props, hw_compat_8_1, hw_compat_8_1_len);
}
-DEFINE_VIRT_MACHINE(8, 1, false)
+DEFINE_VIRT_MACHINE(8, 1)
static void virt_machine_8_0_options(MachineClass *mc)
{
virt_machine_8_1_options(mc);
compat_props_add(mc->compat_props, hw_compat_8_0, hw_compat_8_0_len);
}
-DEFINE_VIRT_MACHINE(8, 0, false)
+DEFINE_VIRT_MACHINE(8, 0)
static void virt_machine_7_2_options(MachineClass *mc)
{
virt_machine_8_0_options(mc);
compat_props_add(mc->compat_props, hw_compat_7_2, hw_compat_7_2_len);
}
-DEFINE_VIRT_MACHINE(7, 2, false)
+DEFINE_VIRT_MACHINE(7, 2)
static void virt_machine_7_1_options(MachineClass *mc)
{
virt_machine_7_2_options(mc);
compat_props_add(mc->compat_props, hw_compat_7_1, hw_compat_7_1_len);
}
-DEFINE_VIRT_MACHINE(7, 1, false)
+DEFINE_VIRT_MACHINE(7, 1)
static void virt_machine_7_0_options(MachineClass *mc)
{
virt_machine_7_1_options(mc);
compat_props_add(mc->compat_props, hw_compat_7_0, hw_compat_7_0_len);
}
-DEFINE_VIRT_MACHINE(7, 0, false)
+DEFINE_VIRT_MACHINE(7, 0)
static void virt_machine_6_2_options(MachineClass *mc)
{
virt_machine_7_0_options(mc);
compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
}
-DEFINE_VIRT_MACHINE(6, 2, false)
+DEFINE_VIRT_MACHINE(6, 2)
static void virt_machine_6_1_options(MachineClass *mc)
{
virt_machine_6_2_options(mc);
compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len);
}
-DEFINE_VIRT_MACHINE(6, 1, false)
+DEFINE_VIRT_MACHINE(6, 1)
static void virt_machine_6_0_options(MachineClass *mc)
{
virt_machine_6_1_options(mc);
compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len);
}
-DEFINE_VIRT_MACHINE(6, 0, false)
+DEFINE_VIRT_MACHINE(6, 0)
--
2.41.0
next prev parent reply other threads:[~2024-07-02 5:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-02 5:00 [PULL 00/22] Misc HW patches for 2024-07-02 Philippe Mathieu-Daudé
2024-07-02 5:00 ` [PULL 01/22] hw/net/spapr: prevent potential NULL dereference Philippe Mathieu-Daudé
2024-07-02 5:00 ` [PULL 02/22] include/hw: add helpers for defining versioned machine types Philippe Mathieu-Daudé
2024-07-02 5:00 ` [PULL 03/22] hw/arm: convert 'virt' machine definitions to use new macros Philippe Mathieu-Daudé
2024-07-02 5:00 ` [PULL 04/22] hw/s390x: convert 'ccw' " Philippe Mathieu-Daudé
2024-07-02 5:00 ` [PULL 05/22] hw/ppc: convert 'spapr' " Philippe Mathieu-Daudé
2024-07-02 5:00 ` Philippe Mathieu-Daudé [this message]
2024-07-02 5:00 ` [PULL 07/22] hw/i386: convert 'i440fx' " Philippe Mathieu-Daudé
2024-07-02 5:00 ` [PULL 08/22] hw/i386: convert 'q35' " Philippe Mathieu-Daudé
2024-07-02 5:00 ` [PULL 09/22] include/hw: add macros for deprecation & removal of versioned machines Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 10/22] include/hw: temporarily disable deletion of versioned machine types Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 11/22] hw: set deprecation info for all " Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 12/22] hw: skip registration of outdated " Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 13/22] hw/ppc: remove obsolete manual deprecation reason string of spapr machines Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 14/22] hw/i386: remove obsolete manual deprecation reason string of i440fx machines Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 15/22] docs: document special exception for machine type deprecation & removal Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 16/22] system/physmem: Fix reference to dump-guest-core Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 17/22] hw/ide/macio: switch from using qemu_allocate_irq() to qdev input GPIOs Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 18/22] hvf: Drop ifdef for macOS versions older than 12.0 Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 19/22] audio: " Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 20/22] block/file-posix: " Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 21/22] net/vmnet: " Philippe Mathieu-Daudé
2024-07-02 5:01 ` [PULL 22/22] Remove inclusion of hw/hw.h from files that don't need it Philippe Mathieu-Daudé
2024-07-02 16:50 ` [PULL 00/22] Misc HW patches for 2024-07-02 Richard Henderson
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=20240702050112.35907-7-philmd@linaro.org \
--to=philmd@linaro.org \
--cc=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
--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).