From patchwork Tue Aug 28 17:43:49 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 180529 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7B8322C0115 for ; Wed, 29 Aug 2012 03:43:07 +1000 (EST) Received: from localhost ([::1]:38681 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6Pof-0007K1-GX for incoming@patchwork.ozlabs.org; Tue, 28 Aug 2012 13:43:05 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49218) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6PoG-0006u8-9d for qemu-devel@nongnu.org; Tue, 28 Aug 2012 13:42:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1T6Po9-0005ke-Oa for qemu-devel@nongnu.org; Tue, 28 Aug 2012 13:42:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:17860) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1T6Po9-0005kS-G4 for qemu-devel@nongnu.org; Tue, 28 Aug 2012 13:42:33 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7SHgVA9019400 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 28 Aug 2012 13:42:31 -0400 Received: from redhat.com (dhcp-4-130.tlv.redhat.com [10.35.4.130]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id q7SHgSlU005556; Tue, 28 Aug 2012 13:42:29 -0400 Date: Tue, 28 Aug 2012 20:43:49 +0300 From: "Michael S. Tsirkin" To: Anthony Liguori , avi@redhat.com, mtosatti@redhat.com, gleb@redhat.com, qemu-devel@nongnu.org, kvm@vger.kernel.org, Jan Kiszka Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mutt-Fcc: =sent X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Blue Swirl Subject: [Qemu-devel] [PATCHv4 2/4] pc: refactor compat code 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 In preparation to adding PV EOI migration for 1.2, trivially refactor some some compat code to make it easier to add version specific cpuid tweaks. Signed-off-by: Michael S. Tsirkin --- hw/pc_piix.c | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/hw/pc_piix.c b/hw/pc_piix.c index a771d79..008d42f 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -369,6 +369,22 @@ static QEMUMachine pc_machine_v1_2 = { .default_machine_opts = KVM_MACHINE_OPTIONS, }; +static void pc_machine_v1_1_compat(void) +{ +} + +static void pc_init_pci_v1_1(ram_addr_t ram_size, + const char *boot_device, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model) +{ + pc_machine_v1_1_compat(); + pc_init_pci(ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + #define PC_COMPAT_1_1 \ {\ .driver = "virtio-scsi-pci",\ @@ -403,7 +419,7 @@ static QEMUMachine pc_machine_v1_2 = { static QEMUMachine pc_machine_v1_1 = { .name = "pc-1.1", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_v1_1, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) { @@ -439,7 +455,7 @@ static QEMUMachine pc_machine_v1_1 = { static QEMUMachine pc_machine_v1_0 = { .name = "pc-1.0", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_v1_1, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) { @@ -455,7 +471,7 @@ static QEMUMachine pc_machine_v1_0 = { static QEMUMachine pc_machine_v0_15 = { .name = "pc-0.15", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_v1_1, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) { @@ -488,7 +504,7 @@ static QEMUMachine pc_machine_v0_15 = { static QEMUMachine pc_machine_v0_14 = { .name = "pc-0.14", .desc = "Standard PC", - .init = pc_init_pci, + .init = pc_init_pci_v1_1, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) { @@ -519,10 +535,22 @@ static QEMUMachine pc_machine_v0_14 = { .value = stringify(1),\ } +static void pc_init_pci_v0_13(ram_addr_t ram_size, + const char *boot_device, + const char *kernel_filename, + const char *kernel_cmdline, + const char *initrd_filename, + const char *cpu_model) +{ + pc_machine_v1_1_compat(); + pc_init_pci_no_kvmclock(ram_size, boot_device, kernel_filename, + kernel_cmdline, initrd_filename, cpu_model); +} + static QEMUMachine pc_machine_v0_13 = { .name = "pc-0.13", .desc = "Standard PC", - .init = pc_init_pci_no_kvmclock, + .init = pc_init_pci_v0_13, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) { @@ -560,7 +588,7 @@ static QEMUMachine pc_machine_v0_13 = { static QEMUMachine pc_machine_v0_12 = { .name = "pc-0.12", .desc = "Standard PC", - .init = pc_init_pci_no_kvmclock, + .init = pc_init_pci_v0_13, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) { @@ -594,7 +622,7 @@ static QEMUMachine pc_machine_v0_12 = { static QEMUMachine pc_machine_v0_11 = { .name = "pc-0.11", .desc = "Standard PC, qemu 0.11", - .init = pc_init_pci_no_kvmclock, + .init = pc_init_pci_v0_13, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) { @@ -616,7 +644,7 @@ static QEMUMachine pc_machine_v0_11 = { static QEMUMachine pc_machine_v0_10 = { .name = "pc-0.10", .desc = "Standard PC, qemu 0.10", - .init = pc_init_pci_no_kvmclock, + .init = pc_init_pci_v0_13, .max_cpus = 255, .default_machine_opts = KVM_MACHINE_OPTIONS, .compat_props = (GlobalProperty[]) {