qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v6 17/28] compat: replace PC_COMPAT_2_3 & HW_COMPAT_


From: Marc-André Lureau
Subject: [Qemu-devel] [PATCH v6 17/28] compat: replace PC_COMPAT_2_3 & HW_COMPAT_2_3 macros
Date: Thu, 13 Dec 2018 01:48:39 +0400

Use static arrays instead.  I decided to rename the conflicting
pc_compat_2_3() function with pc_compat_2_3_fn().

Suggested-by: Eduardo Habkost <address@hidden>
Signed-off-by: Marc-André Lureau <address@hidden>
---
 include/hw/boards.h  |  3 ++
 include/hw/compat.h  | 39 --------------------
 include/hw/i386/pc.h | 88 ++------------------------------------------
 hw/core/machine.c    | 41 +++++++++++++++++++++
 hw/i386/pc.c         | 86 +++++++++++++++++++++++++++++++++++++++++++
 hw/i386/pc_piix.c    | 13 +++----
 hw/ppc/spapr.c       |  2 +-
 7 files changed, 139 insertions(+), 133 deletions(-)

diff --git a/include/hw/boards.h b/include/hw/boards.h
index 053e362f28..a51d896a70 100644
--- a/include/hw/boards.h
+++ b/include/hw/boards.h
@@ -320,4 +320,7 @@ extern const size_t hw_compat_2_5_len;
 extern GlobalProperty hw_compat_2_4[];
 extern const size_t hw_compat_2_4_len;
 
+extern GlobalProperty hw_compat_2_3[];
+extern const size_t hw_compat_2_3_len;
+
 #endif
diff --git a/include/hw/compat.h b/include/hw/compat.h
index 05ff05e159..fbe64d5983 100644
--- a/include/hw/compat.h
+++ b/include/hw/compat.h
@@ -1,45 +1,6 @@
 #ifndef HW_COMPAT_H
 #define HW_COMPAT_H
 
-#define HW_COMPAT_2_3 \
-    {\
-        .driver   = "virtio-blk-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-balloon-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-serial-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-9p-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = "virtio-rng-pci",\
-        .property = "any_layout",\
-        .value    = "off",\
-    },{\
-        .driver   = TYPE_PCI_DEVICE,\
-        .property = "x-pcie-lnksta-dllla",\
-        .value    = "off",\
-    },{\
-        .driver   = "migration",\
-        .property = "send-configuration",\
-        .value    = "off",\
-    },{\
-        .driver   = "migration",\
-        .property = "send-section-footer",\
-        .value    = "off",\
-    },{\
-        .driver   = "migration",\
-        .property = "store-global-state",\
-        .value    = "off",\
-    },
-
 #define HW_COMPAT_2_2 \
     /* empty */
 
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index a9045f6bea..def40cd545 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -327,6 +327,9 @@ extern const size_t pc_compat_2_5_len;
 extern GlobalProperty pc_compat_2_4[];
 extern const size_t pc_compat_2_4_len;
 
+extern GlobalProperty pc_compat_2_3[];
+extern const size_t pc_compat_2_3_len;
+
 /* Helper for setting model-id for CPU models that changed model-id
  * depending on QEMU versions up to QEMU 2.4.
  */
@@ -347,91 +350,6 @@ extern const size_t pc_compat_2_4_len;
         .value    = "QEMU Virtual CPU version " v,\
     },
 
-#define PC_COMPAT_2_3 \
-    HW_COMPAT_2_3 \
-    PC_CPU_MODEL_IDS("2.3.0") \
-    {\
-        .driver   = TYPE_X86_CPU,\
-        .property = "arat",\
-        .value    = "off",\
-    },{\
-        .driver   = "qemu64" "-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(4),\
-    },{\
-        .driver   = "kvm64" "-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(5),\
-    },{\
-        .driver   = "pentium3" "-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(2),\
-    },{\
-        .driver   = "n270" "-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(5),\
-    },{\
-        .driver   = "Conroe" "-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(4),\
-    },{\
-        .driver   = "Penryn" "-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(4),\
-    },{\
-        .driver   = "Nehalem" "-" TYPE_X86_CPU,\
-        .property = "min-level",\
-        .value    = stringify(4),\
-    },{\
-        .driver   = "n270" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Penryn" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Conroe" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Nehalem" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Westmere" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "SandyBridge" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "IvyBridge" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Haswell" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Haswell-noTSX" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Broadwell" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver   = "Broadwell-noTSX" "-" TYPE_X86_CPU,\
-        .property = "min-xlevel",\
-        .value    = stringify(0x8000000a),\
-    },{\
-        .driver = TYPE_X86_CPU,\
-        .property = "kvm-no-smi-migration",\
-        .value    = "on",\
-    },
-
 #define PC_COMPAT_2_2 \
     HW_COMPAT_2_2 \
     PC_CPU_MODEL_IDS("2.2.0") \
diff --git a/hw/core/machine.c b/hw/core/machine.c
index a14e343cba..449f7ec8f6 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -255,6 +255,47 @@ GlobalProperty hw_compat_2_4[] = {
 };
 const size_t hw_compat_2_4_len = G_N_ELEMENTS(hw_compat_2_4);
 
+GlobalProperty hw_compat_2_3[] = {
+    {
+        .driver   = "virtio-blk-pci",
+        .property = "any_layout",
+        .value    = "off",
+    },{
+        .driver   = "virtio-balloon-pci",
+        .property = "any_layout",
+        .value    = "off",
+    },{
+        .driver   = "virtio-serial-pci",
+        .property = "any_layout",
+        .value    = "off",
+    },{
+        .driver   = "virtio-9p-pci",
+        .property = "any_layout",
+        .value    = "off",
+    },{
+        .driver   = "virtio-rng-pci",
+        .property = "any_layout",
+        .value    = "off",
+    },{
+        .driver   = TYPE_PCI_DEVICE,
+        .property = "x-pcie-lnksta-dllla",
+        .value    = "off",
+    },{
+        .driver   = "migration",
+        .property = "send-configuration",
+        .value    = "off",
+    },{
+        .driver   = "migration",
+        .property = "send-section-footer",
+        .value    = "off",
+    },{
+        .driver   = "migration",
+        .property = "store-global-state",
+        .value    = "off",
+    },
+};
+const size_t hw_compat_2_3_len = G_N_ELEMENTS(hw_compat_2_3);
+
 static char *machine_get_accel(Object *obj, Error **errp)
 {
     MachineState *ms = MACHINE(obj);
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index e4410767c9..02363962e0 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -349,6 +349,92 @@ GlobalProperty pc_compat_2_4[] = {
 };
 const size_t pc_compat_2_4_len = G_N_ELEMENTS(pc_compat_2_4);
 
+GlobalProperty pc_compat_2_3[] = {
+    PC_CPU_MODEL_IDS("2.3.0")
+    {
+        .driver   = TYPE_X86_CPU,
+        .property = "arat",
+        .value    = "off",
+    },{
+        .driver   = "qemu64" "-" TYPE_X86_CPU,
+        .property = "min-level",
+        .value    = stringify(4),
+    },{
+        .driver   = "kvm64" "-" TYPE_X86_CPU,
+        .property = "min-level",
+        .value    = stringify(5),
+    },{
+        .driver   = "pentium3" "-" TYPE_X86_CPU,
+        .property = "min-level",
+        .value    = stringify(2),
+    },{
+        .driver   = "n270" "-" TYPE_X86_CPU,
+        .property = "min-level",
+        .value    = stringify(5),
+    },{
+        .driver   = "Conroe" "-" TYPE_X86_CPU,
+        .property = "min-level",
+        .value    = stringify(4),
+    },{
+        .driver   = "Penryn" "-" TYPE_X86_CPU,
+        .property = "min-level",
+        .value    = stringify(4),
+    },{
+        .driver   = "Nehalem" "-" TYPE_X86_CPU,
+        .property = "min-level",
+        .value    = stringify(4),
+    },{
+        .driver   = "n270" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Penryn" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Conroe" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Nehalem" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Westmere" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "SandyBridge" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "IvyBridge" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Haswell" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Haswell-noTSX" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Broadwell" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver   = "Broadwell-noTSX" "-" TYPE_X86_CPU,
+        .property = "min-xlevel",
+        .value    = stringify(0x8000000a),
+    },{
+        .driver = TYPE_X86_CPU,
+        .property = "kvm-no-smi-migration",
+        .value    = "on",
+    },
+};
+const size_t pc_compat_2_3_len = G_N_ELEMENTS(pc_compat_2_3);
+
 void gsi_handler(void *opaque, int n, int level)
 {
     GSIState *s = opaque;
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1465d367d1..d06fdf2bb9 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -310,7 +310,7 @@ static void pc_init1(MachineState *machine,
  * HW_COMPAT_*, PC_COMPAT_*, or * pc_*_machine_options().
  */
 
-static void pc_compat_2_3(MachineState *machine)
+static void pc_compat_2_3_fn(MachineState *machine)
 {
     PCMachineState *pcms = PC_MACHINE(machine);
     if (kvm_enabled()) {
@@ -320,7 +320,7 @@ static void pc_compat_2_3(MachineState *machine)
 
 static void pc_compat_2_2(MachineState *machine)
 {
-    pc_compat_2_3(machine);
+    pc_compat_2_3_fn(machine);
 }
 
 static void pc_compat_2_1(MachineState *machine)
@@ -566,16 +566,13 @@ DEFINE_I440FX_MACHINE(v2_4, "pc-i440fx-2.4", NULL,
 
 static void pc_i440fx_2_3_machine_options(MachineClass *m)
 {
-    static GlobalProperty compat[] = {
-        PC_COMPAT_2_3
-    };
-
     pc_i440fx_2_4_machine_options(m);
     m->hw_version = "2.3.0";
-    compat_props_add(m->compat_props, compat, G_N_ELEMENTS(compat));
+    compat_props_add(m->compat_props, hw_compat_2_3, hw_compat_2_3_len);
+    compat_props_add(m->compat_props, pc_compat_2_3, pc_compat_2_3_len);
 }
 
-DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3,
+DEFINE_I440FX_MACHINE(v2_3, "pc-i440fx-2.3", pc_compat_2_3_fn,
                       pc_i440fx_2_3_machine_options);
 
 static void pc_i440fx_2_2_machine_options(MachineClass *m)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 9ab8484579..29f88f2372 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -4263,7 +4263,6 @@ DEFINE_SPAPR_MACHINE(2_4, "2.4", false);
 static void spapr_machine_2_3_class_options(MachineClass *mc)
 {
     static GlobalProperty compat[] = {
-        HW_COMPAT_2_3
         {
             .driver   = "spapr-pci-host-bridge",
             .property = "dynamic-reconfiguration",
@@ -4271,6 +4270,7 @@ static void spapr_machine_2_3_class_options(MachineClass 
*mc)
         },
     };
     spapr_machine_2_4_class_options(mc);
+    compat_props_add(mc->compat_props, hw_compat_2_3, hw_compat_2_3_len);
     compat_props_add(mc->compat_props, compat, G_N_ELEMENTS(compat));
 }
 DEFINE_SPAPR_MACHINE(2_3, "2.3", false);
-- 
2.20.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]