[Devel] [PATCH hci-8.0/hci-8.1 1/6] i386/pc: raise the limit of compat arrays per Virtuozzo machine type to four #VSTOR-152264

Denis V. Lunev den at openvz.org
Thu Oct 29 12:56:40 MSK 2026


From: Denis V. Lunev <den at openvz.org>

A row of VZ_Q35_MT or VZ_PC_MT can name at most three compat arrays:
COUNT_ARGS counts up to three, VZ_COMPATS_EXPAND has variants for zero
to three, and __vz_compat_props has three slots per row. No row needs
more yet, which is why the limit never showed. The i440fx vz7.16.0 row
uses all three (hw_compat_vz_9_1, hw_compat_vz_7_16,
pc_vz_7_16_compat), and the next commit adds pc_vz_9_2_compat to it.
With a fourth argument COUNT_ARGS returns that argument instead of a
count, and the build fails on an undefined VZ_COMPATS_EXPAND_<name>.

Raise the limit to four.

Signed-off-by: Denis V. Lunev <den at openvz.org>
---
 hw/i386/pc_piix.c    | 2 +-
 hw/i386/pc_q35.c     | 2 +-
 include/hw/i386/pc.h | 7 +++++--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 9a73dcfad4b..1a50c2a645c 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -1087,7 +1087,7 @@ enum {
 static struct {
     GlobalProperty *prop;
     const size_t *len;
-} __vz_compat_props[][3] = {
+} __vz_compat_props[][4] = {
     { VZ_COMPATS_EXPAND(hw_compat_vz, pc_vz_compat) },
     VZ_PC_MT(AS_ARRAY)
 };
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index 9bb0c7e1649..2f4a14b4e01 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -1004,7 +1004,7 @@ enum {
 static struct {
     GlobalProperty *prop;
     const size_t *len;
-} __vz_compat_props[][3] = {
+} __vz_compat_props[][4] = {
     { VZ_COMPATS_EXPAND(hw_compat_vz, pc_vz_compat) },
     VZ_Q35_MT(AS_ARRAY)
 };
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 5140c9c1f23..4d8a01528b8 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -428,8 +428,8 @@ extern const size_t pc_vz_7_4_compat_len;
 /*
  * Helper macros for defining VZ machine types, both pc and q35
  */
-#define _GET_NTH_ARG(_0, _1, _2, _3, N, ...) N
-#define COUNT_ARGS(...) _GET_NTH_ARG(__VA_ARGS__, 3, 2, 1, 0)
+#define _GET_NTH_ARG(_0, _1, _2, _3, _4, N, ...) N
+#define COUNT_ARGS(...) _GET_NTH_ARG(__VA_ARGS__, 4, 3, 2, 1, 0)
 
 #define VZ_COMPATS_EXPAND_0()
 #define VZ_COMPATS_EXPAND_1(prop1) {prop1, &prop1##_len}
@@ -437,6 +437,9 @@ extern const size_t pc_vz_7_4_compat_len;
     {prop1, &prop1##_len}, {prop2, &prop2##_len}
 #define VZ_COMPATS_EXPAND_3(prop1, prop2, prop3)  \
     {prop1, &prop1##_len}, {prop2, &prop2##_len}, {prop3, &prop3##_len}
+#define VZ_COMPATS_EXPAND_4(prop1, prop2, prop3, prop4)  \
+    {prop1, &prop1##_len}, {prop2, &prop2##_len}, {prop3, &prop3##_len}, \
+    {prop4, &prop4##_len}
 
 #define VZ_COMPATS_EXPAND_N(n, ...) VZ_COMPATS_EXPAND_##n(__VA_ARGS__)
 #define VZ_COMPATS_EXPAND_(n, ...)  VZ_COMPATS_EXPAND_N(n, __VA_ARGS__)
-- 
2.53.0



More information about the Devel mailing list