From: "Daniel P. Berrangé" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Halil Pasic" <pasic@linux.ibm.com>,
devel@lists.libvirt.org,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eric Farman" <farman@linux.ibm.com>,
qemu-s390x@nongnu.org,
"Richard Henderson" <richard.henderson@linaro.org>,
"Nicholas Piggin" <npiggin@gmail.com>,
"David Hildenbrand" <david@redhat.com>,
"Ilya Leoshkevich" <iii@linux.ibm.com>,
"David Gibson" <david@gibson.dropbear.id.au>,
qemu-arm@nongnu.org, "Cédric Le Goater" <clegoate@redhat.com>,
"Harsh Prateek Bora" <harshpb@linux.ibm.com>,
"Yanan Wang" <wangyanan55@huawei.com>,
"Eduardo Habkost" <eduardo@habkost.net>,
"Peter Maydell" <peter.maydell@linaro.org>,
"Daniel Henrique Barboza" <danielhb413@gmail.com>,
"Thomas Huth" <thuth@redhat.com>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Marcel Apfelbaum" <marcel.apfelbaum@gmail.com>,
"Christian Borntraeger" <borntraeger@linux.ibm.com>,
"Laurent Vivier" <laurent@vivier.eu>,
qemu-ppc@nongnu.org, "Daniel P. Berrangé" <berrange@redhat.com>
Subject: [PATCH v2 03/14] hw/s390x: convert 'ccw' machine definitions to use new macros
Date: Thu, 20 Jun 2024 17:57:31 +0100 [thread overview]
Message-ID: <20240620165742.1711389-4-berrange@redhat.com> (raw)
In-Reply-To: <20240620165742.1711389-1-berrange@redhat.com>
This changes the DEFINE_CCW_MACHINE macro to use the common
helpers for constructing versioned symbol names and strings,
bringing greater consistency across targets.
The added benefit is that it avoids the need to repeat the
version number twice in two different formats in the calls
to DEFINE_CCW_MACHINE.
A DEFINE_CCW_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>
---
hw/s390x/s390-virtio-ccw.c | 96 +++++++++++++++++++++-----------------
1 file changed, 53 insertions(+), 43 deletions(-)
diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c
index 3d0bc3e7f2..efed539bc6 100644
--- a/hw/s390x/s390-virtio-ccw.c
+++ b/hw/s390x/s390-virtio-ccw.c
@@ -15,6 +15,7 @@
#include "qapi/error.h"
#include "exec/ram_addr.h"
#include "exec/confidential-guest-support.h"
+#include "hw/boards.h"
#include "hw/s390x/s390-virtio-hcall.h"
#include "hw/s390x/sclp.h"
#include "hw/s390x/s390_flic.h"
@@ -816,35 +817,44 @@ static const TypeInfo ccw_machine_info = {
},
};
-#define DEFINE_CCW_MACHINE(suffix, verstr, latest) \
- static void ccw_machine_##suffix##_class_init(ObjectClass *oc, \
- void *data) \
+#define DEFINE_CCW_MACHINE_IMPL(latest, ...) \
+ static void MACHINE_VER_SYM(class_init, ccw, __VA_ARGS__)( \
+ ObjectClass *oc, \
+ void *data) \
{ \
MachineClass *mc = MACHINE_CLASS(oc); \
- ccw_machine_##suffix##_class_options(mc); \
- mc->desc = "Virtual s390x machine (version " verstr ")"; \
+ MACHINE_VER_SYM(class_options, ccw, __VA_ARGS__)(mc); \
+ mc->desc = "Virtual s390x machine (version " MACHINE_VER_STR(__VA_ARGS__) ")"; \
if (latest) { \
mc->alias = "s390-ccw-virtio"; \
mc->is_default = true; \
} \
} \
- static void ccw_machine_##suffix##_instance_init(Object *obj) \
+ static void MACHINE_VER_SYM(instance_init, ccw, __VA_ARGS__)(Object *obj) \
{ \
MachineState *machine = MACHINE(obj); \
- current_mc = S390_CCW_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \
- ccw_machine_##suffix##_instance_options(machine); \
+ current_mc = S390_CCW_MACHINE_CLASS(MACHINE_GET_CLASS(machine)); \
+ MACHINE_VER_SYM(instance_options, ccw, __VA_ARGS__)(machine); \
} \
- static const TypeInfo ccw_machine_##suffix##_info = { \
- .name = MACHINE_TYPE_NAME("s390-ccw-virtio-" verstr), \
+ static const TypeInfo MACHINE_VER_SYM(info, ccw, __VA_ARGS__) = \
+ { \
+ .name = MACHINE_VER_TYPE_NAME("s390-ccw-virtio", __VA_ARGS__), \
.parent = TYPE_S390_CCW_MACHINE, \
- .class_init = ccw_machine_##suffix##_class_init, \
- .instance_init = ccw_machine_##suffix##_instance_init, \
+ .class_init = MACHINE_VER_SYM(class_init, ccw, __VA_ARGS__), \
+ .instance_init = MACHINE_VER_SYM(instance_init, ccw, __VA_ARGS__), \
}; \
- static void ccw_machine_register_##suffix(void) \
+ static void MACHINE_VER_SYM(register, ccw, __VA_ARGS__)(void) \
{ \
- type_register_static(&ccw_machine_##suffix##_info); \
+ type_register_static(&MACHINE_VER_SYM(info, ccw, __VA_ARGS__)); \
} \
- type_init(ccw_machine_register_##suffix)
+ type_init(MACHINE_VER_SYM(register, ccw, __VA_ARGS__))
+
+#define DEFINE_CCW_MACHINE_AS_LATEST(major, minor) \
+ DEFINE_CCW_MACHINE_IMPL(true, major, minor)
+
+#define DEFINE_CCW_MACHINE(major, minor) \
+ DEFINE_CCW_MACHINE_IMPL(false, major, minor)
+
static void ccw_machine_9_1_instance_options(MachineState *machine)
{
@@ -853,7 +863,7 @@ static void ccw_machine_9_1_instance_options(MachineState *machine)
static void ccw_machine_9_1_class_options(MachineClass *mc)
{
}
-DEFINE_CCW_MACHINE(9_1, "9.1", true);
+DEFINE_CCW_MACHINE_AS_LATEST(9, 1);
static void ccw_machine_9_0_instance_options(MachineState *machine)
{
@@ -865,7 +875,7 @@ static void ccw_machine_9_0_class_options(MachineClass *mc)
ccw_machine_9_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len);
}
-DEFINE_CCW_MACHINE(9_0, "9.0", false);
+DEFINE_CCW_MACHINE(9, 0);
static void ccw_machine_8_2_instance_options(MachineState *machine)
{
@@ -877,7 +887,7 @@ static void ccw_machine_8_2_class_options(MachineClass *mc)
ccw_machine_9_0_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_8_2, hw_compat_8_2_len);
}
-DEFINE_CCW_MACHINE(8_2, "8.2", false);
+DEFINE_CCW_MACHINE(8, 2);
static void ccw_machine_8_1_instance_options(MachineState *machine)
{
@@ -891,7 +901,7 @@ static void ccw_machine_8_1_class_options(MachineClass *mc)
mc->smp_props.drawers_supported = false;
mc->smp_props.books_supported = false;
}
-DEFINE_CCW_MACHINE(8_1, "8.1", false);
+DEFINE_CCW_MACHINE(8, 1);
static void ccw_machine_8_0_instance_options(MachineState *machine)
{
@@ -903,7 +913,7 @@ static void ccw_machine_8_0_class_options(MachineClass *mc)
ccw_machine_8_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_8_0, hw_compat_8_0_len);
}
-DEFINE_CCW_MACHINE(8_0, "8.0", false);
+DEFINE_CCW_MACHINE(8, 0);
static void ccw_machine_7_2_instance_options(MachineState *machine)
{
@@ -915,7 +925,7 @@ static void ccw_machine_7_2_class_options(MachineClass *mc)
ccw_machine_8_0_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_7_2, hw_compat_7_2_len);
}
-DEFINE_CCW_MACHINE(7_2, "7.2", false);
+DEFINE_CCW_MACHINE(7, 2);
static void ccw_machine_7_1_instance_options(MachineState *machine)
{
@@ -939,7 +949,7 @@ static void ccw_machine_7_1_class_options(MachineClass *mc)
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
s390mc->max_threads = S390_MAX_CPUS;
}
-DEFINE_CCW_MACHINE(7_1, "7.1", false);
+DEFINE_CCW_MACHINE(7, 1);
static void ccw_machine_7_0_instance_options(MachineState *machine)
{
@@ -954,7 +964,7 @@ static void ccw_machine_7_0_class_options(MachineClass *mc)
ccw_machine_7_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_7_0, hw_compat_7_0_len);
}
-DEFINE_CCW_MACHINE(7_0, "7.0", false);
+DEFINE_CCW_MACHINE(7, 0);
static void ccw_machine_6_2_instance_options(MachineState *machine)
{
@@ -969,7 +979,7 @@ static void ccw_machine_6_2_class_options(MachineClass *mc)
ccw_machine_7_0_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_6_2, hw_compat_6_2_len);
}
-DEFINE_CCW_MACHINE(6_2, "6.2", false);
+DEFINE_CCW_MACHINE(6, 2);
static void ccw_machine_6_1_instance_options(MachineState *machine)
{
@@ -987,7 +997,7 @@ static void ccw_machine_6_1_class_options(MachineClass *mc)
compat_props_add(mc->compat_props, hw_compat_6_1, hw_compat_6_1_len);
mc->smp_props.prefer_sockets = true;
}
-DEFINE_CCW_MACHINE(6_1, "6.1", false);
+DEFINE_CCW_MACHINE(6, 1);
static void ccw_machine_6_0_instance_options(MachineState *machine)
{
@@ -1002,7 +1012,7 @@ static void ccw_machine_6_0_class_options(MachineClass *mc)
ccw_machine_6_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_6_0, hw_compat_6_0_len);
}
-DEFINE_CCW_MACHINE(6_0, "6.0", false);
+DEFINE_CCW_MACHINE(6, 0);
static void ccw_machine_5_2_instance_options(MachineState *machine)
{
@@ -1014,7 +1024,7 @@ static void ccw_machine_5_2_class_options(MachineClass *mc)
ccw_machine_6_0_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_5_2, hw_compat_5_2_len);
}
-DEFINE_CCW_MACHINE(5_2, "5.2", false);
+DEFINE_CCW_MACHINE(5, 2);
static void ccw_machine_5_1_instance_options(MachineState *machine)
{
@@ -1026,7 +1036,7 @@ static void ccw_machine_5_1_class_options(MachineClass *mc)
ccw_machine_5_2_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_5_1, hw_compat_5_1_len);
}
-DEFINE_CCW_MACHINE(5_1, "5.1", false);
+DEFINE_CCW_MACHINE(5, 1);
static void ccw_machine_5_0_instance_options(MachineState *machine)
{
@@ -1038,7 +1048,7 @@ static void ccw_machine_5_0_class_options(MachineClass *mc)
ccw_machine_5_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_5_0, hw_compat_5_0_len);
}
-DEFINE_CCW_MACHINE(5_0, "5.0", false);
+DEFINE_CCW_MACHINE(5, 0);
static void ccw_machine_4_2_instance_options(MachineState *machine)
{
@@ -1051,7 +1061,7 @@ static void ccw_machine_4_2_class_options(MachineClass *mc)
mc->fixup_ram_size = s390_fixup_ram_size;
compat_props_add(mc->compat_props, hw_compat_4_2, hw_compat_4_2_len);
}
-DEFINE_CCW_MACHINE(4_2, "4.2", false);
+DEFINE_CCW_MACHINE(4, 2);
static void ccw_machine_4_1_instance_options(MachineState *machine)
{
@@ -1065,7 +1075,7 @@ static void ccw_machine_4_1_class_options(MachineClass *mc)
ccw_machine_4_2_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_4_1, hw_compat_4_1_len);
}
-DEFINE_CCW_MACHINE(4_1, "4.1", false);
+DEFINE_CCW_MACHINE(4, 1);
static void ccw_machine_4_0_instance_options(MachineState *machine)
{
@@ -1079,7 +1089,7 @@ static void ccw_machine_4_0_class_options(MachineClass *mc)
ccw_machine_4_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_4_0, hw_compat_4_0_len);
}
-DEFINE_CCW_MACHINE(4_0, "4.0", false);
+DEFINE_CCW_MACHINE(4, 0);
static void ccw_machine_3_1_instance_options(MachineState *machine)
{
@@ -1095,7 +1105,7 @@ static void ccw_machine_3_1_class_options(MachineClass *mc)
ccw_machine_4_0_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_3_1, hw_compat_3_1_len);
}
-DEFINE_CCW_MACHINE(3_1, "3.1", false);
+DEFINE_CCW_MACHINE(3, 1);
static void ccw_machine_3_0_instance_options(MachineState *machine)
{
@@ -1110,7 +1120,7 @@ static void ccw_machine_3_0_class_options(MachineClass *mc)
ccw_machine_3_1_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_3_0, hw_compat_3_0_len);
}
-DEFINE_CCW_MACHINE(3_0, "3.0", false);
+DEFINE_CCW_MACHINE(3, 0);
static void ccw_machine_2_12_instance_options(MachineState *machine)
{
@@ -1124,7 +1134,7 @@ static void ccw_machine_2_12_class_options(MachineClass *mc)
ccw_machine_3_0_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_2_12, hw_compat_2_12_len);
}
-DEFINE_CCW_MACHINE(2_12, "2.12", false);
+DEFINE_CCW_MACHINE(2, 12);
static void ccw_machine_2_11_instance_options(MachineState *machine)
{
@@ -1145,7 +1155,7 @@ static void ccw_machine_2_11_class_options(MachineClass *mc)
compat_props_add(mc->compat_props, hw_compat_2_11, hw_compat_2_11_len);
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
}
-DEFINE_CCW_MACHINE(2_11, "2.11", false);
+DEFINE_CCW_MACHINE(2, 11);
static void ccw_machine_2_10_instance_options(MachineState *machine)
{
@@ -1157,7 +1167,7 @@ static void ccw_machine_2_10_class_options(MachineClass *mc)
ccw_machine_2_11_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_2_10, hw_compat_2_10_len);
}
-DEFINE_CCW_MACHINE(2_10, "2.10", false);
+DEFINE_CCW_MACHINE(2, 10);
static void ccw_machine_2_9_instance_options(MachineState *machine)
{
@@ -1181,7 +1191,7 @@ static void ccw_machine_2_9_class_options(MachineClass *mc)
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
css_migration_enabled = false;
}
-DEFINE_CCW_MACHINE(2_9, "2.9", false);
+DEFINE_CCW_MACHINE(2, 9);
static void ccw_machine_2_8_instance_options(MachineState *machine)
{
@@ -1198,7 +1208,7 @@ static void ccw_machine_2_8_class_options(MachineClass *mc)
compat_props_add(mc->compat_props, hw_compat_2_8, hw_compat_2_8_len);
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
}
-DEFINE_CCW_MACHINE(2_8, "2.8", false);
+DEFINE_CCW_MACHINE(2, 8);
static void ccw_machine_2_7_instance_options(MachineState *machine)
{
@@ -1213,7 +1223,7 @@ static void ccw_machine_2_7_class_options(MachineClass *mc)
ccw_machine_2_8_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_2_7, hw_compat_2_7_len);
}
-DEFINE_CCW_MACHINE(2_7, "2.7", false);
+DEFINE_CCW_MACHINE(2, 7);
static void ccw_machine_2_6_instance_options(MachineState *machine)
{
@@ -1233,7 +1243,7 @@ static void ccw_machine_2_6_class_options(MachineClass *mc)
compat_props_add(mc->compat_props, hw_compat_2_6, hw_compat_2_6_len);
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
}
-DEFINE_CCW_MACHINE(2_6, "2.6", false);
+DEFINE_CCW_MACHINE(2, 6);
static void ccw_machine_2_5_instance_options(MachineState *machine)
{
@@ -1245,7 +1255,7 @@ static void ccw_machine_2_5_class_options(MachineClass *mc)
ccw_machine_2_6_class_options(mc);
compat_props_add(mc->compat_props, hw_compat_2_5, hw_compat_2_5_len);
}
-DEFINE_CCW_MACHINE(2_5, "2.5", false);
+DEFINE_CCW_MACHINE(2, 5);
static void ccw_machine_2_4_instance_options(MachineState *machine)
{
@@ -1270,7 +1280,7 @@ static void ccw_machine_2_4_class_options(MachineClass *mc)
compat_props_add(mc->compat_props, hw_compat_2_4, hw_compat_2_4_len);
compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
}
-DEFINE_CCW_MACHINE(2_4, "2.4", false);
+DEFINE_CCW_MACHINE(2, 4);
static void ccw_machine_register_types(void)
{
--
2.43.0
next prev parent reply other threads:[~2024-06-20 16:59 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-20 16:57 [PATCH v2 00/14] hw: define and enforce a standard lifecycle for versioned machines Daniel P. Berrangé
2024-06-20 16:57 ` [PATCH v2 01/14] include/hw: add helpers for defining versioned machine types Daniel P. Berrangé
2024-06-20 16:57 ` [PATCH v2 02/14] hw/arm: convert 'virt' machine definitions to use new macros Daniel P. Berrangé
2024-07-01 12:55 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` Daniel P. Berrangé [this message]
2024-07-01 12:53 ` [PATCH v2 03/14] hw/s390x: convert 'ccw' " Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 04/14] hw/ppc: convert 'spapr' " Daniel P. Berrangé
2024-06-20 16:57 ` [PATCH v2 05/14] hw/m68k: convert 'virt' " Daniel P. Berrangé
2024-07-01 12:54 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 06/14] hw/i386: convert 'i440fx' " Daniel P. Berrangé
2024-07-01 9:11 ` Thomas Huth
2024-07-01 12:58 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 07/14] hw/i386: convert 'q35' " Daniel P. Berrangé
2024-07-01 9:14 ` Thomas Huth
2024-07-01 12:59 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 08/14] include/hw: add macros for deprecation & removal of versioned machines Daniel P. Berrangé
2024-07-01 15:13 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 09/14] include/hw: temporarily disable deletion of versioned machine types Daniel P. Berrangé
2024-06-20 17:18 ` Thomas Huth
2024-06-20 16:57 ` [PATCH v2 10/14] hw: set deprecation info for all " Daniel P. Berrangé
2024-07-01 11:20 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 11/14] hw: skip registration of outdated " Daniel P. Berrangé
2024-07-01 15:14 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 12/14] hw/ppc: remove obsolete manual deprecation reason string of spapr machines Daniel P. Berrangé
2024-07-01 11:20 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 13/14] hw/i386: remove obsolete manual deprecation reason string of i440fx machines Daniel P. Berrangé
2024-07-01 11:21 ` Philippe Mathieu-Daudé
2024-06-20 16:57 ` [PATCH v2 14/14] docs: document special exception for machine type deprecation & removal Daniel P. Berrangé
2024-07-01 15:15 ` Philippe Mathieu-Daudé
2024-07-01 15:41 ` [PATCH v2 00/14] hw: define and enforce a standard lifecycle for versioned machines Philippe Mathieu-Daudé
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=20240620165742.1711389-4-berrange@redhat.com \
--to=berrange@redhat.com \
--cc=borntraeger@linux.ibm.com \
--cc=clegoate@redhat.com \
--cc=danielhb413@gmail.com \
--cc=david@gibson.dropbear.id.au \
--cc=david@redhat.com \
--cc=devel@lists.libvirt.org \
--cc=eduardo@habkost.net \
--cc=farman@linux.ibm.com \
--cc=harshpb@linux.ibm.com \
--cc=iii@linux.ibm.com \
--cc=laurent@vivier.eu \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=npiggin@gmail.com \
--cc=pasic@linux.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-ppc@nongnu.org \
--cc=qemu-s390x@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=thuth@redhat.com \
--cc=wangyanan55@huawei.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).