From patchwork Tue Jun 24 18:02:02 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 363595 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2B4E51400E0 for ; Wed, 25 Jun 2014 04:11:49 +1000 (EST) Received: from localhost ([::1]:33256 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzV60-0006Pe-Gn for incoming@patchwork.ozlabs.org; Tue, 24 Jun 2014 14:05:28 -0400 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 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s5OI2JvG013929 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 24 Jun 2014 14:02:20 -0400 Received: from localhost (ovpn-113-127.phx2.redhat.com [10.3.113.127]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s5OI2IKT011598; Tue, 24 Jun 2014 14:02:18 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org, "Michael S. Tsirkin" 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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 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 Subject: [Qemu-devel] [PATCH 2/4] pc: Eliminate nesting of common PC_COMPAT_* macros X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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",\