From patchwork Fri May 15 17:18:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 472879 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 CDF5E14027F for ; Sat, 16 May 2015 03:19:58 +1000 (AEST) Received: from localhost ([::1]:60681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtJHA-0008Vg-N2 for incoming@patchwork.ozlabs.org; Fri, 15 May 2015 13:19:56 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37677) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtJGW-0007O7-6P for qemu-devel@nongnu.org; Fri, 15 May 2015 13:19:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YtJGS-0002pQ-U4 for qemu-devel@nongnu.org; Fri, 15 May 2015 13:19:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56497) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YtJGS-0002oz-L9 for qemu-devel@nongnu.org; Fri, 15 May 2015 13:19:12 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t4FHJC9c027179 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 15 May 2015 13:19:12 -0400 Received: from localhost (ovpn-113-57.phx2.redhat.com [10.3.113.57]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t4FHJAgs028249; Fri, 15 May 2015 13:19:11 -0400 From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Fri, 15 May 2015 14:18:52 -0300 Message-Id: <1431710341-24696-2-git-send-email-ehabkost@redhat.com> In-Reply-To: <1431710341-24696-1-git-send-email-ehabkost@redhat.com> References: <1431710341-24696-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, jasowang@redhat.com, rth@twiddle.net, Alexander Graf , "Michael S. Tsirkin" Subject: [Qemu-devel] [PATCH 01/10] pc: Define MACHINE_OPTIONS macros consistently for all machines 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 Define a MACHINE_OPTIONS macro for each PC machine, and move every field inside the QEMUMachine structs to the macros, except for name, init, and compat_props. This also ensures that all MACHINE_OPTIONS inherit the fields from the next version, so their definitions carry only the changes that exist between one version and the next one. Comments about specific cases: pc-*-2.1: Existing PC_*_2_1_MACHINE_OPTIONS macros were defined as: PC_*_MACHINE_OPTIONS, .default_machine_opts = "firmware=bios-256k.bin" PC_*_2_2_MACHINE_OPTIONS is: PC_*_2_3_MACHINE_OPTIONS which is expanded to: PC_*_MACHINE_OPTIONS, .default_machine_opts = "firmware=bios-256k.bin", .default_display = "std" The only difference between 2_1 and 2_2 is .default_display, that's why we didn't reuse PC_*_2_2_MACHINE_OPTIONS. The good news is that having multiple initializers for a field is allowed by C99, and the last initializer overrides the previous ones. So we can reuse the 2_2 macro in 2_1 and define PC_*_2_1_MACHINE_OPTIONS as: PC_*_2_2_MACHINE_OPTIONS, .default_display = NULL pc-*-1.7: PC_*_1_7_MACHINE_OPTIONS was defined as: PC_*_MACHINE_OPTIONS PC_*_2_0_MACHINE_OPTIONS is defined as: PC_*_2_1_MACHINE_OPTIONS which is expanded to: PC_*_2_2_MACHINE_OPTIONS, .default_display = NULL which is expanded to: PC_*_2_3_MACHINE_OPTIONS, .default_display = NULL which is expanded to: PC_*_MACHINE_OPTIONS, .default_machine_opts = "firmware=bios-256k.bin", .default_display = "std", .default_display = NULL /* overrides the previous line */ So, the only difference between PC_*_1_7_MACHINE_OPTIONS and PC_*_2_0_MACHINE_OPTIONS is .default_machine_opts (as .default_display is not explicitly set by PC_*_MACHINE_OPTIONS so it is NULL). So we can keep the macro reuse pattern and define PC_*_2_0_MACHINE_OPTIONS as: PC_*_2_0_MACHINE_OPTIONS, .default_machine_opts = NULL pc-*-2.4 (alias and is_default fields): Set alias and is_default fields inside the 2.4 MACHINE_OPTIONS macro, and clear it in the 2.3 macro (that reuses the 2.4 macro). hw_machine: As all the machines older than v1.0 set hw_version explicitly, we can safely move the field to the MACHINE_OPTIONS macros without affecting the other versions that reuse them. init function: Some machines had the init function set inside the MACHINE_OPTIONS macro. Move it to the QEMUMachine declaration, to keep it consistent with the other machines. Signed-off-by: Eduardo Habkost --- hw/i386/pc_piix.c | 128 +++++++++++++++++++++++++++++++++++++----------------- hw/i386/pc_q35.c | 34 ++++++++++----- 2 files changed, 110 insertions(+), 52 deletions(-) diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 6734c62..0bbe979 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -526,18 +526,21 @@ static void pc_xen_hvm_init(MachineState *machine) #define PC_I440FX_2_4_MACHINE_OPTIONS \ PC_I440FX_MACHINE_OPTIONS, \ .default_machine_opts = "firmware=bios-256k.bin", \ - .default_display = "std" + .default_display = "std", \ + .alias = "pc", \ + .is_default = 1 static QEMUMachine pc_i440fx_machine_v2_4 = { PC_I440FX_2_4_MACHINE_OPTIONS, .name = "pc-i440fx-2.4", - .alias = "pc", .init = pc_init_pci, - .is_default = 1, }; -#define PC_I440FX_2_3_MACHINE_OPTIONS PC_I440FX_2_4_MACHINE_OPTIONS +#define PC_I440FX_2_3_MACHINE_OPTIONS \ + PC_I440FX_2_4_MACHINE_OPTIONS, \ + .alias = NULL, \ + .is_default = 0 static QEMUMachine pc_i440fx_machine_v2_3 = { PC_I440FX_2_3_MACHINE_OPTIONS, @@ -549,7 +552,8 @@ static QEMUMachine pc_i440fx_machine_v2_3 = { }, }; -#define PC_I440FX_2_2_MACHINE_OPTIONS PC_I440FX_2_3_MACHINE_OPTIONS +#define PC_I440FX_2_2_MACHINE_OPTIONS \ + PC_I440FX_2_3_MACHINE_OPTIONS static QEMUMachine pc_i440fx_machine_v2_2 = { PC_I440FX_2_2_MACHINE_OPTIONS, @@ -561,9 +565,9 @@ static QEMUMachine pc_i440fx_machine_v2_2 = { }, }; -#define PC_I440FX_2_1_MACHINE_OPTIONS \ - PC_I440FX_MACHINE_OPTIONS, \ - .default_machine_opts = "firmware=bios-256k.bin" +#define PC_I440FX_2_1_MACHINE_OPTIONS \ + PC_I440FX_2_2_MACHINE_OPTIONS, \ + .default_display = NULL static QEMUMachine pc_i440fx_machine_v2_1 = { PC_I440FX_2_1_MACHINE_OPTIONS, @@ -575,7 +579,8 @@ static QEMUMachine pc_i440fx_machine_v2_1 = { }, }; -#define PC_I440FX_2_0_MACHINE_OPTIONS PC_I440FX_2_1_MACHINE_OPTIONS +#define PC_I440FX_2_0_MACHINE_OPTIONS \ + PC_I440FX_2_1_MACHINE_OPTIONS static QEMUMachine pc_i440fx_machine_v2_0 = { PC_I440FX_2_0_MACHINE_OPTIONS, @@ -587,7 +592,9 @@ static QEMUMachine pc_i440fx_machine_v2_0 = { }, }; -#define PC_I440FX_1_7_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS +#define PC_I440FX_1_7_MACHINE_OPTIONS \ + PC_I440FX_2_0_MACHINE_OPTIONS, \ + .default_machine_opts = NULL static QEMUMachine pc_i440fx_machine_v1_7 = { PC_I440FX_1_7_MACHINE_OPTIONS, @@ -599,7 +606,8 @@ static QEMUMachine pc_i440fx_machine_v1_7 = { }, }; -#define PC_I440FX_1_6_MACHINE_OPTIONS PC_I440FX_MACHINE_OPTIONS +#define PC_I440FX_1_6_MACHINE_OPTIONS \ + PC_I440FX_1_7_MACHINE_OPTIONS static QEMUMachine pc_i440fx_machine_v1_6 = { PC_I440FX_1_6_MACHINE_OPTIONS, @@ -611,8 +619,11 @@ static QEMUMachine pc_i440fx_machine_v1_6 = { }, }; +#define PC_I440FX_1_5_MACHINE_OPTIONS \ + PC_I440FX_1_6_MACHINE_OPTIONS + static QEMUMachine pc_i440fx_machine_v1_5 = { - PC_I440FX_1_6_MACHINE_OPTIONS, + PC_I440FX_1_5_MACHINE_OPTIONS, .name = "pc-i440fx-1.5", .init = pc_init_pci_1_5, .compat_props = (GlobalProperty[]) { @@ -622,7 +633,7 @@ static QEMUMachine pc_i440fx_machine_v1_5 = { }; #define PC_I440FX_1_4_MACHINE_OPTIONS \ - PC_I440FX_1_6_MACHINE_OPTIONS, \ + PC_I440FX_1_5_MACHINE_OPTIONS, \ .hot_add_cpu = NULL static QEMUMachine pc_i440fx_machine_v1_4 = { @@ -655,8 +666,11 @@ static QEMUMachine pc_i440fx_machine_v1_4 = { .value = "off",\ }, +#define PC_I440FX_1_3_MACHINE_OPTIONS \ + PC_I440FX_1_4_MACHINE_OPTIONS + static QEMUMachine pc_machine_v1_3 = { - PC_I440FX_1_4_MACHINE_OPTIONS, + PC_I440FX_1_3_MACHINE_OPTIONS, .name = "pc-1.3", .init = pc_init_pci_1_3, .compat_props = (GlobalProperty[]) { @@ -694,12 +708,12 @@ static QEMUMachine pc_machine_v1_3 = { }, #define PC_I440FX_1_2_MACHINE_OPTIONS \ - PC_I440FX_1_4_MACHINE_OPTIONS, \ - .init = pc_init_pci_1_2 + PC_I440FX_1_3_MACHINE_OPTIONS static QEMUMachine pc_machine_v1_2 = { PC_I440FX_1_2_MACHINE_OPTIONS, .name = "pc-1.2", + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty[]) { PC_COMPAT_1_2 { /* end of list */ } @@ -738,9 +752,13 @@ static QEMUMachine pc_machine_v1_2 = { .value = "off",\ }, +#define PC_I440FX_1_1_MACHINE_OPTIONS \ + PC_I440FX_1_2_MACHINE_OPTIONS + static QEMUMachine pc_machine_v1_1 = { - PC_I440FX_1_2_MACHINE_OPTIONS, + PC_I440FX_1_1_MACHINE_OPTIONS, .name = "pc-1.1", + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty[]) { PC_COMPAT_1_1 { /* end of list */ } @@ -767,27 +785,35 @@ static QEMUMachine pc_machine_v1_1 = { .value = "no",\ }, +#define PC_I440FX_1_0_MACHINE_OPTIONS \ + PC_I440FX_1_1_MACHINE_OPTIONS, \ + .hw_version = "1.0" + static QEMUMachine pc_machine_v1_0 = { - PC_I440FX_1_2_MACHINE_OPTIONS, + PC_I440FX_1_0_MACHINE_OPTIONS, .name = "pc-1.0", + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty[]) { PC_COMPAT_1_0 { /* end of list */ } }, - .hw_version = "1.0", }; #define PC_COMPAT_0_15 \ PC_COMPAT_1_0 +#define PC_I440FX_0_15_MACHINE_OPTIONS \ + PC_I440FX_1_0_MACHINE_OPTIONS, \ + .hw_version = "0.15" + static QEMUMachine pc_machine_v0_15 = { - PC_I440FX_1_2_MACHINE_OPTIONS, + PC_I440FX_0_15_MACHINE_OPTIONS, .name = "pc-0.15", + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_15 { /* end of list */ } }, - .hw_version = "0.15", }; #define PC_COMPAT_0_14 \ @@ -818,14 +844,18 @@ static QEMUMachine pc_machine_v0_15 = { .value = stringify(2),\ }, +#define PC_I440FX_0_14_MACHINE_OPTIONS \ + PC_I440FX_0_15_MACHINE_OPTIONS, \ + .hw_version = "0.14" + static QEMUMachine pc_machine_v0_14 = { - PC_I440FX_1_2_MACHINE_OPTIONS, + PC_I440FX_0_14_MACHINE_OPTIONS, .name = "pc-0.14", + .init = pc_init_pci_1_2, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_14 { /* end of list */ } }, - .hw_version = "0.14", }; #define PC_COMPAT_0_13 \ @@ -853,17 +883,17 @@ static QEMUMachine pc_machine_v0_14 = { }, #define PC_I440FX_0_13_MACHINE_OPTIONS \ - PC_I440FX_1_2_MACHINE_OPTIONS, \ - .init = pc_init_pci_no_kvmclock + PC_I440FX_0_14_MACHINE_OPTIONS, \ + .hw_version = "0.13" static QEMUMachine pc_machine_v0_13 = { PC_I440FX_0_13_MACHINE_OPTIONS, .name = "pc-0.13", + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_13 { /* end of list */ } }, - .hw_version = "0.13", }; #define PC_COMPAT_0_12 \ @@ -890,14 +920,18 @@ static QEMUMachine pc_machine_v0_13 = { .value = "1",\ }, +#define PC_I440FX_0_12_MACHINE_OPTIONS \ + PC_I440FX_0_13_MACHINE_OPTIONS, \ + .hw_version = "0.12" + static QEMUMachine pc_machine_v0_12 = { - PC_I440FX_0_13_MACHINE_OPTIONS, + PC_I440FX_0_12_MACHINE_OPTIONS, .name = "pc-0.12", + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_12 { /* end of list */ } }, - .hw_version = "0.12", }; #define PC_COMPAT_0_11 \ @@ -920,14 +954,18 @@ static QEMUMachine pc_machine_v0_12 = { .value = "0.11",\ }, +#define PC_I440FX_0_11_MACHINE_OPTIONS \ + PC_I440FX_0_12_MACHINE_OPTIONS, \ + .hw_version = "0.11" + static QEMUMachine pc_machine_v0_11 = { - PC_I440FX_0_13_MACHINE_OPTIONS, + PC_I440FX_0_11_MACHINE_OPTIONS, .name = "pc-0.11", + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_11 { /* end of list */ } }, - .hw_version = "0.11", }; #define PC_COMPAT_0_10 \ @@ -954,36 +992,46 @@ static QEMUMachine pc_machine_v0_11 = { .value = "0.10",\ }, +#define PC_I440FX_0_10_MACHINE_OPTIONS \ + PC_I440FX_0_11_MACHINE_OPTIONS, \ + .hw_version = "0.10" + static QEMUMachine pc_machine_v0_10 = { - PC_I440FX_0_13_MACHINE_OPTIONS, + PC_I440FX_0_10_MACHINE_OPTIONS, .name = "pc-0.10", + .init = pc_init_pci_no_kvmclock, .compat_props = (GlobalProperty[]) { PC_COMPAT_0_10 { /* end of list */ } }, - .hw_version = "0.10", }; +#define ISAPC_MACHINE_OPTIONS \ + PC_COMMON_MACHINE_OPTIONS, \ + .desc = "ISA-only PC", \ + .max_cpus = 1 + static QEMUMachine isapc_machine = { - PC_COMMON_MACHINE_OPTIONS, + ISAPC_MACHINE_OPTIONS, .name = "isapc", - .desc = "ISA-only PC", .init = pc_init_isa, - .max_cpus = 1, .compat_props = (GlobalProperty[]) { { /* end of list */ } }, }; #ifdef CONFIG_XEN +#define XENFV_MACHINE_OPTIONS \ + PC_COMMON_MACHINE_OPTIONS, \ + .desc = "Xen Fully-virtualized PC", \ + .max_cpus = HVM_MAX_VCPUS, \ + .default_machine_opts = "accel=xen", \ + .hot_add_cpu = pc_hot_add_cpu + static QEMUMachine xenfv_machine = { - PC_COMMON_MACHINE_OPTIONS, + XENFV_MACHINE_OPTIONS, .name = "xenfv", - .desc = "Xen Fully-virtualized PC", .init = pc_xen_hvm_init, - .max_cpus = HVM_MAX_VCPUS, - .default_machine_opts = "accel=xen", - .hot_add_cpu = pc_hot_add_cpu, }; #endif diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index 0051666..196178e 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -424,16 +424,18 @@ static void pc_q35_init_1_4(MachineState *machine) #define PC_Q35_2_4_MACHINE_OPTIONS \ PC_Q35_MACHINE_OPTIONS, \ .default_machine_opts = "firmware=bios-256k.bin", \ - .default_display = "std" + .default_display = "std", \ + .alias = "q35" static QEMUMachine pc_q35_machine_v2_4 = { PC_Q35_2_4_MACHINE_OPTIONS, .name = "pc-q35-2.4", - .alias = "q35", .init = pc_q35_init, }; -#define PC_Q35_2_3_MACHINE_OPTIONS PC_Q35_2_4_MACHINE_OPTIONS +#define PC_Q35_2_3_MACHINE_OPTIONS \ + PC_Q35_2_4_MACHINE_OPTIONS, \ + .alias = NULL static QEMUMachine pc_q35_machine_v2_3 = { PC_Q35_2_3_MACHINE_OPTIONS, @@ -445,7 +447,8 @@ static QEMUMachine pc_q35_machine_v2_3 = { }, }; -#define PC_Q35_2_2_MACHINE_OPTIONS PC_Q35_2_3_MACHINE_OPTIONS +#define PC_Q35_2_2_MACHINE_OPTIONS \ + PC_Q35_2_3_MACHINE_OPTIONS static QEMUMachine pc_q35_machine_v2_2 = { PC_Q35_2_2_MACHINE_OPTIONS, @@ -457,9 +460,9 @@ static QEMUMachine pc_q35_machine_v2_2 = { }, }; -#define PC_Q35_2_1_MACHINE_OPTIONS \ - PC_Q35_MACHINE_OPTIONS, \ - .default_machine_opts = "firmware=bios-256k.bin" +#define PC_Q35_2_1_MACHINE_OPTIONS \ + PC_Q35_2_2_MACHINE_OPTIONS, \ + .default_display = NULL static QEMUMachine pc_q35_machine_v2_1 = { PC_Q35_2_1_MACHINE_OPTIONS, @@ -471,7 +474,8 @@ static QEMUMachine pc_q35_machine_v2_1 = { }, }; -#define PC_Q35_2_0_MACHINE_OPTIONS PC_Q35_2_1_MACHINE_OPTIONS +#define PC_Q35_2_0_MACHINE_OPTIONS \ + PC_Q35_2_1_MACHINE_OPTIONS static QEMUMachine pc_q35_machine_v2_0 = { PC_Q35_2_0_MACHINE_OPTIONS, @@ -483,7 +487,9 @@ static QEMUMachine pc_q35_machine_v2_0 = { }, }; -#define PC_Q35_1_7_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS +#define PC_Q35_1_7_MACHINE_OPTIONS \ + PC_Q35_2_0_MACHINE_OPTIONS, \ + .default_machine_opts = NULL static QEMUMachine pc_q35_machine_v1_7 = { PC_Q35_1_7_MACHINE_OPTIONS, @@ -495,7 +501,8 @@ static QEMUMachine pc_q35_machine_v1_7 = { }, }; -#define PC_Q35_1_6_MACHINE_OPTIONS PC_Q35_MACHINE_OPTIONS +#define PC_Q35_1_6_MACHINE_OPTIONS \ + PC_Q35_MACHINE_OPTIONS static QEMUMachine pc_q35_machine_v1_6 = { PC_Q35_1_6_MACHINE_OPTIONS, @@ -507,8 +514,11 @@ static QEMUMachine pc_q35_machine_v1_6 = { }, }; +#define PC_Q35_1_5_MACHINE_OPTIONS \ + PC_Q35_1_6_MACHINE_OPTIONS + static QEMUMachine pc_q35_machine_v1_5 = { - PC_Q35_1_6_MACHINE_OPTIONS, + PC_Q35_1_5_MACHINE_OPTIONS, .name = "pc-q35-1.5", .init = pc_q35_init_1_5, .compat_props = (GlobalProperty[]) { @@ -518,7 +528,7 @@ static QEMUMachine pc_q35_machine_v1_5 = { }; #define PC_Q35_1_4_MACHINE_OPTIONS \ - PC_Q35_1_6_MACHINE_OPTIONS, \ + PC_Q35_1_5_MACHINE_OPTIONS, \ .hot_add_cpu = NULL static QEMUMachine pc_q35_machine_v1_4 = {