From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36852) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzV3B-0000tU-8M for qemu-devel@nongnu.org; Tue, 24 Jun 2014 14:02:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzV33-00032b-GI for qemu-devel@nongnu.org; Tue, 24 Jun 2014 14:02:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:19567) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzV33-00032R-8d for qemu-devel@nongnu.org; Tue, 24 Jun 2014 14:02:25 -0400 From: Eduardo Habkost Date: Tue, 24 Jun 2014 15:02:02 -0300 Message-Id: <1403632924-16603-3-git-send-email-ehabkost@redhat.com> In-Reply-To: <1403632924-16603-1-git-send-email-ehabkost@redhat.com> References: <1403632924-16603-1-git-send-email-ehabkost@redhat.com> Subject: [Qemu-devel] [PATCH 2/4] pc: Eliminate nesting of common PC_COMPAT_* macros List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, "Michael S. Tsirkin" Cc: Peter Maydell , Marcel Apfelbaum , Alexey Kardashevskiy , Markus Armbruster , Paul Mackerras , Anthony Liguori , Igor Mammedov , Paolo Bonzini , =?UTF-8?q?Andreas=20F=C3=A4rber?= , Alexander Graf The PC_COMPAT_* macros include each other, and the PC_Q35_COMPAT_* macros _also_ included each other. That caused lots of properties to appear multiple times on PC_Q35_COMPAT_*. For example, PC_Q35_COMPAT_1_4 expanded to the following: 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.4 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 pc-2.0 variables from PC_COMPAT_2_0 appeared 5 times inside PC_Q35_COMPAT_1_4. This makes the following changes: * Reusable PC_COMPAT_* macros on pc.h have NO nesting; * Instead of using PC_COMPAT_* directly, now pc_piix.c has its own PC_I440FX_COMPAT_* macros. * Machine-type-specific PC_*_COMPAT_* macros on .c files are nested, and reuse the common PC_COMPAT_* macros. Thus the expansion of PC_Q35_COMPAT_1_4 becomes: PC_Q35_COMPAT_1_4: |-> PC_Q35_COMPAT_1_5: | |-> PC_Q35_COMPAT_1_6: | | |-> PC_Q35_COMPAT_1_7: | | | |-> PC_Q35_COMPAT_2_0: | | | | |-> PC_COMPAT_2_0: | | | | | `-> [pc-2.0 vars] | | | | `-> [pc-q35-2.0 vars] | | | |-> PC_COMPAT_1_7: | | | | `-> [pc-1.7 vars] | | | `-> [pc-q35-1.7 vars] | | |-> PC_COMPAT_1_6: | | | `-> [pc-1.6 vars] | | `-> [pc-q35-1.6 vars] | |-> PC_COMPAT_1_5: | | `-> [pc-1.5 vars] | `-> [pc-q35-1.5 vars] |-> PC_COMPAT_1_4: | `-> [pc-1.4 vars] `-> [pc-q35-1.4 vars] Signed-off-by: Eduardo Habkost --- hw/i386/pc_piix.c | 31 +++++++++++++++++++++++++------ hw/i386/pc_q35.c | 14 +++++++------- include/hw/i386/pc.h | 4 ---- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 47546b7..d8010d16 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -441,6 +441,9 @@ static QEMUMachine pc_i440fx_machine_v2_1 = { .is_default = 1, }; +#define PC_I440FX_COMPAT_2_0 \ + PC_COMPAT_2_0 + #define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS static QEMUMachine pc_i440fx_machine_v2_0 = { @@ -448,11 +451,15 @@ static QEMUMachine pc_i440fx_machine_v2_0 = { .name = "pc-i440fx-2.0", .init = pc_init_pci_2_0, .compat_props = (GlobalProperty[]) { - PC_COMPAT_2_0, + PC_I440FX_COMPAT_2_0, { /* end of list */ } }, }; +#define PC_I440FX_COMPAT_1_7 \ + PC_I440FX_COMPAT_2_0, \ + PC_COMPAT_1_7 + #define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS static QEMUMachine pc_i440fx_machine_v1_7 = { @@ -460,11 +467,15 @@ static QEMUMachine pc_i440fx_machine_v1_7 = { .name = "pc-i440fx-1.7", .init = pc_init_pci_1_7, .compat_props = (GlobalProperty[]) { - PC_COMPAT_1_7, + PC_I440FX_COMPAT_1_7, { /* end of list */ } }, }; +#define PC_I440FX_COMPAT_1_6 \ + PC_I440FX_COMPAT_1_7, \ + PC_COMPAT_1_6 + #define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS static QEMUMachine pc_i440fx_machine_v1_6 = { @@ -472,21 +483,29 @@ static QEMUMachine pc_i440fx_machine_v1_6 = { .name = "pc-i440fx-1.6", .init = pc_init_pci_1_6, .compat_props = (GlobalProperty[]) { - PC_COMPAT_1_6, + PC_I440FX_COMPAT_1_6, { /* end of list */ } }, }; +#define PC_I440FX_COMPAT_1_5 \ + PC_I440FX_COMPAT_1_6, \ + PC_COMPAT_1_5 + static QEMUMachine pc_i440fx_machine_v1_5 = { PC_I440FX_1_6_MACHINE_OPTIONS, .name = "pc-i440fx-1.5", .init = pc_init_pci_1_5, .compat_props = (GlobalProperty[]) { - PC_COMPAT_1_5, + PC_I440FX_COMPAT_1_5, { /* end of list */ } }, }; +#define PC_I440FX_COMPAT_1_4 \ + PC_I440FX_COMPAT_1_5, \ + PC_COMPAT_1_4 + #define PC_I440FX_1_4_MACHINE_OPTIONS \ PC_I440FX_1_6_MACHINE_OPTIONS, \ .hot_add_cpu = NULL @@ -496,13 +515,13 @@ static QEMUMachine pc_i440fx_machine_v1_4 = { .name = "pc-i440fx-1.4", .init = pc_init_pci_1_4, .compat_props = (GlobalProperty[]) { - PC_COMPAT_1_4, + PC_I440FX_COMPAT_1_4, { /* end of list */ } }, }; #define PC_COMPAT_1_3 \ - PC_COMPAT_1_4, \ + PC_I440FX_COMPAT_1_4, \ {\ .driver = "usb-tablet",\ .property = "usb_version",\ diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index c640e7b..57eecc3 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -383,8 +383,8 @@ static QEMUMachine pc_q35_machine_v2_0 = { }; #define PC_Q35_COMPAT_1_7 \ - PC_COMPAT_1_7, \ PC_Q35_COMPAT_2_0, \ + PC_COMPAT_1_7, \ {\ .driver = "hpet",\ .property = HPET_INTCAP,\ @@ -404,8 +404,8 @@ static QEMUMachine pc_q35_machine_v1_7 = { }; #define PC_Q35_COMPAT_1_6 \ - PC_COMPAT_1_6, \ - PC_Q35_COMPAT_1_7 + PC_Q35_COMPAT_1_7, \ + PC_COMPAT_1_6 #define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS @@ -420,8 +420,8 @@ static QEMUMachine pc_q35_machine_v1_6 = { }; #define PC_Q35_COMPAT_1_5 \ - PC_COMPAT_1_5, \ - PC_Q35_COMPAT_1_6 + PC_Q35_COMPAT_1_6, \ + PC_COMPAT_1_5 static QEMUMachine pc_q35_machine_v1_5 = { PC_Q35_1_6_MACHINE_OPTIONS, @@ -434,8 +434,8 @@ static QEMUMachine pc_q35_machine_v1_5 = { }; #define PC_Q35_COMPAT_1_4 \ - PC_COMPAT_1_4, \ - PC_Q35_COMPAT_1_5 + PC_Q35_COMPAT_1_5, \ + PC_COMPAT_1_4 #define PC_Q35_1_4_MACHINE_OPTIONS \ PC_Q35_1_6_MACHINE_OPTIONS, \ diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index fb7d68d..d988b80 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -336,7 +336,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",\ @@ -349,7 +348,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",\ @@ -373,7 +371,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",\ @@ -417,7 +414,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",\ -- 1.9.3