diff mbox

[RFC,v2,16/39] pc: Eliminate all *_machine_options() functions

Message ID 1402688658-22333-17-git-send-email-ehabkost@redhat.com
State New
Headers show

Commit Message

Eduardo Habkost June 13, 2014, 7:43 p.m. UTC
Finally eliminate all *_machine_options() functions, and make the
class_init functions for older machine-types simply reuse the class_init
functions from newer machine-types.

To allow compat_props reuse, the the PC_COMPAT_* macros were changed to
not nest within the older PC_COMPAT_* macros anymore.

As a side-effect, we fix duplication of PC_COMPAT_* variables on the
PC_Q35_COMPAT_* macros, which were expanded as the following tree:

  PC_Q35_COMPAT_1_4:
      PC_COMPAT_1_4:
          PC_COMPAT_1_5:
              PC_COMPAT_1_6:
                  PC_COMPAT_1_7:
                      PC_COMPAT_2_0:
                          [pc-2.0 vars]
                      [pc-1.7 vars]
                  [pc-1.6 vars]
              [pc-1.5 vars]
          [pc-1.5 vars]
      PC_Q35_COMPAT_1_5:
          PC_COMPAT_1_5:
              PC_COMPAT_1_6:
                  PC_COMPAT_1_7:
                      PC_COMPAT_2_0:
                          [pc-2.0 vars]
                      [pc-1.7 vars]
                  [pc-1.6 vars]
              [pc-1.5 vars]
          PC_Q35_COMPAT_1_6:
              PC_COMPAT_1_6:
                  PC_COMPAT_1_7:
                      PC_COMPAT_2_0:
                          [pc-2.0 vars]
                      [pc-1.7 vars]
                  [pc-1.6 vars]
              PC_Q35_COMPAT_1_7:
                  PC_COMPAT_1_7:
                      PC_COMPAT_2_0:
                          [pc-2.0 vars]
                      [pc-1.7 vars]
                  PC_Q35_COMPAT_2_0:
                      PC_COMPAT_2_0:
                          [pc-2.0 vars]
                      [pc-q35-2.0 vars]
                  [pc-q35-1.7 vars]
              [pc-q35-1.6 vars]
          [pc-q35-1.5 vars]
      [pc-q35-1.4 vars]

In other words, the contents of PC_COMPAT_2_0 appeared 5 times inside
PC_Q35_COMPAT_1_4.

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/i386/pc_piix.c    | 84 ++++++++++++++--------------------------------------
 hw/i386/pc_q35.c     | 15 +++++-----
 include/hw/i386/pc.h | 14 ++-------
 3 files changed, 33 insertions(+), 80 deletions(-)
diff mbox

Patch

diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 1c5f4b5..6594f36 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -421,16 +421,10 @@  static TypeInfo pc_i440fx_machine_type_info = {
     .abstract = true,
 };
 
-
-static void pc_i440fx_2_1_machine_options(MachineClass *mc)
-{
-    mc->default_machine_opts = "firmware=bios-256k.bin";
-}
-
 static void pc_i440fx_machine_v2_1_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
-    pc_i440fx_2_1_machine_options(mc);
+    mc->default_machine_opts = "firmware=bios-256k.bin";
     mc->alias = "pc";
     mc->init = pc_init_pci;
     mc->is_default = 1;
@@ -450,7 +444,9 @@  static void pc_i440fx_machine_v2_0_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_2_0,
         { /* end of list */ }
     };
-    pc_i440fx_2_1_machine_options(mc);
+    pc_i440fx_machine_v2_1_class_init(oc, data);
+    mc->alias = NULL;
+    mc->is_default = false;
     mc->init = pc_init_pci_2_0;
     mc->name = "pc-i440fx-2.0";
     machine_class_add_compat_props(mc, compat_props);
@@ -462,12 +458,6 @@  static TypeInfo pc_i440fx_machine_v2_0_type_info = {
     .class_init = pc_i440fx_machine_v2_0_class_init,
 };
 
-static void pc_i440fx_1_7_machine_options(MachineClass *mc)
-{
-    pc_i440fx_2_1_machine_options(mc);
-    mc->default_machine_opts = NULL;
-}
-
 static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -475,7 +465,8 @@  static void pc_i440fx_machine_v1_7_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_7,
         { /* end of list */ }
     };
-    pc_i440fx_1_7_machine_options(mc);
+    pc_i440fx_machine_v2_0_class_init(oc, data);
+    mc->default_machine_opts = NULL;
     mc->init = pc_init_pci_1_7;
     mc->name = "pc-i440fx-1.7";
     machine_class_add_compat_props(mc, compat_props);
@@ -494,7 +485,7 @@  static void pc_i440fx_machine_v1_6_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_6,
         { /* end of list */ }
     };
-    pc_i440fx_1_7_machine_options(mc);
+    pc_i440fx_machine_v1_7_class_init(oc, data);
     mc->init = pc_init_pci_1_6;
     mc->name = "pc-i440fx-1.6";
     machine_class_add_compat_props(mc, compat_props);
@@ -513,7 +504,7 @@  static void pc_i440fx_machine_v1_5_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_5,
         { /* end of list */ }
     };
-    pc_i440fx_1_7_machine_options(mc);
+    pc_i440fx_machine_v1_6_class_init(oc, data);
     mc->init = pc_init_pci_1_5;
     mc->name = "pc-i440fx-1.5";
     machine_class_add_compat_props(mc, compat_props);
@@ -525,12 +516,6 @@  static TypeInfo pc_i440fx_machine_v1_5_type_info = {
     .class_init = pc_i440fx_machine_v1_5_class_init,
 };
 
-static void pc_i440fx_1_4_machine_options(MachineClass *mc)
-{
-    pc_i440fx_1_7_machine_options(mc);
-    mc->hot_add_cpu = NULL;
-}
-
 static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -538,7 +523,8 @@  static void pc_i440fx_machine_v1_4_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_4,
         { /* end of list */ }
     };
-    pc_i440fx_1_4_machine_options(mc);
+    pc_i440fx_machine_v1_5_class_init(oc, data);
+    mc->hot_add_cpu = NULL;
     mc->init = pc_init_pci_1_4;
     mc->name = "pc-i440fx-1.4";
     machine_class_add_compat_props(mc, compat_props);
@@ -551,7 +537,6 @@  static TypeInfo pc_i440fx_machine_v1_4_type_info = {
 };
 
 #define PC_COMPAT_1_3 \
-	PC_COMPAT_1_4, \
         {\
             .driver   = "usb-tablet",\
             .property = "usb_version",\
@@ -577,7 +562,7 @@  static void pc_machine_v1_3_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_3,
         { /* end of list */ }
     };
-    pc_i440fx_1_4_machine_options(mc);
+    pc_i440fx_machine_v1_4_class_init(oc, data);
     mc->init = pc_init_pci_1_3;
     mc->name = "pc-1.3";
     machine_class_add_compat_props(mc, compat_props);
@@ -590,7 +575,6 @@  static TypeInfo pc_machine_v1_3_type_info = {
 };
 
 #define PC_COMPAT_1_2 \
-        PC_COMPAT_1_3,\
         {\
             .driver   = "nec-usb-xhci",\
             .property = "msi",\
@@ -617,12 +601,6 @@  static TypeInfo pc_machine_v1_3_type_info = {
             .value    = "off",\
         }
 
-static void pc_i440fx_1_2_machine_options(MachineClass *mc)
-{
-    pc_i440fx_1_4_machine_options(mc);
-    mc->init = pc_init_pci_1_2;
-}
-
 static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -630,7 +608,8 @@  static void pc_machine_v1_2_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_2,
         { /* end of list */ }
     };
-    pc_i440fx_1_2_machine_options(mc);
+    pc_machine_v1_3_class_init(oc, data);
+    mc->init = pc_init_pci_1_2;
     mc->name = "pc-1.2";
     machine_class_add_compat_props(mc, compat_props);
 }
@@ -642,7 +621,6 @@  static TypeInfo pc_machine_v1_2_type_info = {
 };
 
 #define PC_COMPAT_1_1 \
-        PC_COMPAT_1_2,\
         {\
             .driver   = "virtio-scsi-pci",\
             .property = "hotplug",\
@@ -680,7 +658,7 @@  static void pc_machine_v1_1_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_1,
         { /* end of list */ }
     };
-    pc_i440fx_1_2_machine_options(mc);
+    pc_machine_v1_2_class_init(oc, data);
     mc->name = "pc-1.1";
     machine_class_add_compat_props(mc, compat_props);
 }
@@ -718,7 +696,7 @@  static void pc_machine_v1_0_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_1_0,
         { /* end of list */ }
     };
-    pc_i440fx_1_2_machine_options(mc);
+    pc_machine_v1_1_class_init(oc, data);
     mc->hw_version = "1.0";
     mc->name = "pc-1.0";
     machine_class_add_compat_props(mc, compat_props);
@@ -730,20 +708,12 @@  static TypeInfo pc_machine_v1_0_type_info = {
     .class_init = pc_machine_v1_0_class_init,
 };
 
-#define PC_COMPAT_0_15 \
-        PC_COMPAT_1_0
-
 static void pc_machine_v0_15_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
-    static GlobalProperty compat_props[] = {
-        PC_COMPAT_0_15,
-        { /* end of list */ }
-    };
-    pc_i440fx_1_2_machine_options(mc);
+    pc_machine_v1_0_class_init(oc, data);
     mc->hw_version = "0.15";
     mc->name = "pc-0.15";
-    machine_class_add_compat_props(mc, compat_props);
 }
 
 static TypeInfo pc_machine_v0_15_type_info = {
@@ -753,7 +723,6 @@  static TypeInfo pc_machine_v0_15_type_info = {
 };
 
 #define PC_COMPAT_0_14 \
-        PC_COMPAT_0_15,\
         {\
             .driver   = "virtio-blk-pci",\
             .property = "event_idx",\
@@ -787,7 +756,7 @@  static void pc_machine_v0_14_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_0_14, 
         { /* end of list */ }
     };
-    pc_i440fx_1_2_machine_options(mc);
+    pc_machine_v0_15_class_init(oc, data);
     mc->hw_version = "0.14";
     mc->name = "pc-0.14";
     machine_class_add_compat_props(mc, compat_props);
@@ -800,7 +769,6 @@  static TypeInfo pc_machine_v0_14_type_info = {
 };
 
 #define PC_COMPAT_0_13 \
-        PC_COMPAT_0_14,\
         {\
             .driver   = TYPE_PCI_DEVICE,\
             .property = "command_serr_enable",\
@@ -823,12 +791,6 @@  static TypeInfo pc_machine_v0_14_type_info = {
             .value    = stringify(0),\
         }
 
-static void pc_i440fx_0_13_machine_options(MachineClass *mc)
-{
-    pc_i440fx_1_2_machine_options(mc);
-    mc->init = pc_init_pci_no_kvmclock;
-}
-
 static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
@@ -836,7 +798,8 @@  static void pc_machine_v0_13_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_0_13,
         { /* end of list */ }
     };
-    pc_i440fx_0_13_machine_options(mc);
+    pc_machine_v0_14_class_init(oc, data);
+    mc->init = pc_init_pci_no_kvmclock;
     mc->hw_version = "0.13";
     mc->name = "pc-0.13";
     machine_class_add_compat_props(mc, compat_props);
@@ -849,7 +812,6 @@  static TypeInfo pc_machine_v0_13_type_info = {
 };
 
 #define PC_COMPAT_0_12 \
-        PC_COMPAT_0_13,\
         {\
             .driver   = "virtio-serial-pci",\
             .property = "max_ports",\
@@ -879,7 +841,7 @@  static void pc_machine_v0_12_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_0_12,
         { /* end of list */ }
     };
-    pc_i440fx_0_13_machine_options(mc);
+    pc_machine_v0_13_class_init(oc, data);
     mc->hw_version = "0.12";
     mc->name = "pc-0.12";
     machine_class_add_compat_props(mc, compat_props);
@@ -892,7 +854,6 @@  static TypeInfo pc_machine_v0_12_type_info = {
 };
 
 #define PC_COMPAT_0_11 \
-        PC_COMPAT_0_12,\
         {\
             .driver   = "virtio-blk-pci",\
             .property = "vectors",\
@@ -918,7 +879,7 @@  static void pc_machine_v0_11_class_init(ObjectClass *oc, void *data)
         PC_COMPAT_0_11,
         { /* end of list */ }
     };
-    pc_i440fx_0_13_machine_options(mc);
+    pc_machine_v0_12_class_init(oc, data);
     mc->hw_version = "0.11";
     mc->name = "pc-0.11";
     machine_class_add_compat_props(mc, compat_props);
@@ -934,7 +895,6 @@  static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
     static GlobalProperty compat_props[] = {
-        PC_COMPAT_0_11,
         {
             .driver   = "virtio-blk-pci",
             .property = "class",
@@ -958,7 +918,7 @@  static void pc_machine_v0_10_class_init(ObjectClass *oc, void *data)
         },
         { /* end of list */ }
     };
-    pc_i440fx_0_13_machine_options(mc);
+    pc_machine_v0_11_class_init(oc, data);
     mc->hw_version = "0.10";
     mc->name = "pc-0.10";
     machine_class_add_compat_props(mc, compat_props);
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index bdc8929..e3da35c 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -335,15 +335,10 @@  static TypeInfo pc_q35_machine_type_info = {
     .abstract = true,
 };
 
-static void pc_q35_2_1_machine_options(MachineClass *mc)
-{
-    mc->default_machine_opts = "firmware=bios-256k.bin";
-}
-
 static void pc_q35_machine_v2_1_class_init(ObjectClass *oc, void *data)
 {
     MachineClass *mc = MACHINE_CLASS(oc);
-    pc_q35_2_1_machine_options(mc);
+    mc->default_machine_opts = "firmware=bios-256k.bin";
     mc->alias = "q35";
     mc->init = pc_q35_init;
     mc->name = "pc-q35-2.1";
@@ -362,7 +357,8 @@  static void pc_q35_machine_v2_0_class_init(ObjectClass *oc, void *data)
         PC_Q35_COMPAT_2_0,
         { /* end of list */ }
     };
-    pc_q35_2_1_machine_options(mc);
+    pc_q35_machine_v2_1_class_init(oc, data);
+    mc->alias = NULL;
     mc->init = pc_q35_init_2_0;
     machine_class_add_compat_props(mc, compat_props);
     mc->name = "pc-q35-2.0";
@@ -381,6 +377,8 @@  static void pc_q35_machine_v1_7_class_init(ObjectClass *oc, void *data)
         PC_Q35_COMPAT_1_7,
         { /* end of list */ }
     };
+    pc_q35_machine_v2_0_class_init(oc, data);
+    mc->default_machine_opts = NULL;
     mc->init = pc_q35_init_1_7;
     machine_class_add_compat_props(mc, compat_props);
     mc->name = "pc-q35-1.7";
@@ -399,6 +397,7 @@  static void pc_q35_machine_v1_6_class_init(ObjectClass *oc, void *data)
         PC_Q35_COMPAT_1_6,
         { /* end of list */ }
     };
+    pc_q35_machine_v1_7_class_init(oc, data);
     mc->init = pc_q35_init_1_6;
     machine_class_add_compat_props(mc, compat_props);
     mc->name = "pc-q35-1.6";
@@ -417,6 +416,7 @@  static void pc_q35_machine_v1_5_class_init(ObjectClass *oc, void *data)
         PC_Q35_COMPAT_1_5,
         { /* end of list */ }
     };
+    pc_q35_machine_v1_6_class_init(oc, data);
     mc->init = pc_q35_init_1_5;
     machine_class_add_compat_props(mc, compat_props);
     mc->name = "pc-q35-1.5";
@@ -435,6 +435,7 @@  static void pc_q35_machine_v1_4_class_init(ObjectClass *oc, void *data)
         PC_Q35_COMPAT_1_4,
         { /* end of list */ }
     };
+    pc_q35_machine_v1_5_class_init(oc, data);
     mc->hot_add_cpu = NULL;
     mc->init = pc_q35_init_1_4;
     machine_class_add_compat_props(mc, compat_props);
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index 92fab21..c78549e 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -303,7 +303,6 @@  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
 
 #define PC_Q35_COMPAT_1_7 \
         PC_COMPAT_1_7, \
-        PC_Q35_COMPAT_2_0, \
         {\
             .driver   = "hpet",\
             .property = HPET_INTCAP,\
@@ -311,16 +310,13 @@  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_Q35_COMPAT_1_6 \
-        PC_COMPAT_1_6, \
-        PC_Q35_COMPAT_1_7
+        PC_COMPAT_1_6
 
 #define PC_Q35_COMPAT_1_5 \
-        PC_COMPAT_1_5, \
-        PC_Q35_COMPAT_1_6
+        PC_COMPAT_1_5
 
 #define PC_Q35_COMPAT_1_4 \
-        PC_COMPAT_1_4, \
-        PC_Q35_COMPAT_1_5
+        PC_COMPAT_1_4
 
 #define PC_COMPAT_2_0 \
         {\
@@ -355,7 +351,6 @@  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_7 \
-        PC_COMPAT_2_0, \
         {\
             .driver   = TYPE_USB_DEVICE,\
             .property = "msos-desc",\
@@ -368,7 +363,6 @@  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_6 \
-        PC_COMPAT_1_7, \
         {\
             .driver   = "e1000",\
             .property = "mitigation",\
@@ -392,7 +386,6 @@  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_5 \
-        PC_COMPAT_1_6, \
         {\
             .driver   = "Conroe-" TYPE_X86_CPU,\
             .property = "model",\
@@ -436,7 +429,6 @@  bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *);
         }
 
 #define PC_COMPAT_1_4 \
-        PC_COMPAT_1_5, \
         {\
             .driver   = "scsi-hd",\
             .property = "discard_granularity",\