From patchwork Thu Oct 7 12:48:06 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anthony Liguori X-Patchwork-Id: 67050 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2703FB6EDF for ; Thu, 7 Oct 2010 23:51:26 +1100 (EST) Received: from localhost ([127.0.0.1]:32772 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3pw9-00050b-P2 for incoming@patchwork.ozlabs.org; Thu, 07 Oct 2010 08:51:05 -0400 Received: from [140.186.70.92] (port=59374 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P3ptH-000453-9h for qemu-devel@nongnu.org; Thu, 07 Oct 2010 08:48:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1P3ptF-0002QF-OP for qemu-devel@nongnu.org; Thu, 07 Oct 2010 08:48:07 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:47030) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1P3ptF-0002Py-Lg for qemu-devel@nongnu.org; Thu, 07 Oct 2010 08:48:05 -0400 Received: from d01relay06.pok.ibm.com (d01relay06.pok.ibm.com [9.56.227.116]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id o97CVZOl011373 for ; Thu, 7 Oct 2010 08:31:35 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay06.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o97Cm1kf1019904 for ; Thu, 7 Oct 2010 08:48:01 -0400 Received: from d01av01.pok.ibm.com (loopback [127.0.0.1]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id o97Cm0us007771 for ; Thu, 7 Oct 2010 08:48:01 -0400 Received: from [9.65.58.135] (sig-9-65-58-135.mts.ibm.com [9.65.58.135]) by d01av01.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id o97ClwS4007677; Thu, 7 Oct 2010 08:47:58 -0400 Message-ID: <4CADC186.3050309@linux.vnet.ibm.com> Date: Thu, 07 Oct 2010 07:48:06 -0500 From: Anthony Liguori User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.12) Gecko/20100915 Lightning/1.0b1 Thunderbird/3.0.8 MIME-Version: 1.0 To: "Roedel, Joerg" References: <1285593377-1754-1-git-send-email-joerg.roedel@amd.com> <1285593377-1754-2-git-send-email-joerg.roedel@amd.com> <20101006185306.GA8237@amt.cnet> <4CACCD0B.5090302@linux.vnet.ibm.com> <20101007084215.GB1983@amd.com> In-Reply-To: <20101007084215.GB1983@amd.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Anthony Liguori , "kvm@vger.kernel.org" , Marcelo Tosatti , "qemu-devel@nongnu.org" , Alexander Graf , Avi Kivity Subject: [Qemu-devel] Re: [PATCH 1/3] Make kvm64 the default cpu model when kvm_enabled() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org On 10/07/2010 03:42 AM, Roedel, Joerg wrote: > On Wed, Oct 06, 2010 at 03:24:59PM -0400, Anthony Liguori wrote: > >>>> + qemu_compat_version = machine->compat_version; >>>> + >>>> if (display_type == DT_NOGRAPHIC) { >>>> if (default_parallel) >>>> add_device_config(DEV_PARALLEL, "null"); >>>> -- >>>> 1.7.0.4 >>>> >>>> >>> Looks fine to me, given CPUs are not in qdev. Anthony? >>> >>> >> The idea is fine, but why not just add the default CPU to the machine >> description? >> > If I remember correctly the reason was that the machine description was > not accessible in the cpuid initialization path because it is a function > local variable. Not tested at all but I think the attached patch addresses it in a pretty nice way. There's a couple ways you could support your patch on top of this. You could add a kvm_cpu_model to the machine structure that gets defaulted too if kvm_enabled(). You could also introduce a new KVM machine type that gets defaulted to if no explicit machine is specified. > I could have made it a global variable but considered > the compat_version approach simpler. The qemu_compat_version might also > be useful at other places. > The reason we've avoided having a builtin notion of versions is that we have many downstreams where versioning would get very complicated. If we stick to features it makes it much easier for downstreams. Regards, Anthony Liguori > Joerg > > From d2370c88cef4b07d48ba3c4804e35ae2db8db7c0 Mon Sep 17 00:00:00 2001 From: Anthony Liguori Date: Thu, 7 Oct 2010 07:43:42 -0500 Subject: [PATCH] machine: make default cpu model part of machine structure Signed-off-by: Anthony Liguori diff --git a/hw/boards.h b/hw/boards.h index 6f0f0d7..8c6ef27 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -16,6 +16,7 @@ typedef struct QEMUMachine { const char *name; const char *alias; const char *desc; + const char *cpu_model; QEMUMachineInitFunc *init; int use_scsi; int max_cpus; diff --git a/hw/pc.c b/hw/pc.c index 69b13bf..0826107 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -866,14 +866,6 @@ void pc_cpus_init(const char *cpu_model) int i; /* init CPUs */ - if (cpu_model == NULL) { -#ifdef TARGET_X86_64 - cpu_model = "qemu64"; -#else - cpu_model = "qemu32"; -#endif - } - for(i = 0; i < smp_cpus; i++) { pc_new_cpu(cpu_model); } diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 12359a7..919b4d6 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -204,17 +204,22 @@ static void pc_init_isa(ram_addr_t ram_size, const char *initrd_filename, const char *cpu_model) { - if (cpu_model == NULL) - cpu_model = "486"; pc_init1(ram_size, boot_device, kernel_filename, kernel_cmdline, initrd_filename, cpu_model, 0); } +#ifdef TARGET_X86_64 +#define DEF_CPU_MODEL "qemu64" +#else +#define DEF_CPU_MODEL "qemu32" +#endif + static QEMUMachine pc_machine = { .name = "pc-0.13", .alias = "pc", .desc = "Standard PC", + .cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .is_default = 1, @@ -223,6 +228,7 @@ static QEMUMachine pc_machine = { static QEMUMachine pc_machine_v0_12 = { .name = "pc-0.12", .desc = "Standard PC", + .cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -242,6 +248,7 @@ static QEMUMachine pc_machine_v0_12 = { static QEMUMachine pc_machine_v0_11 = { .name = "pc-0.11", .desc = "Standard PC, qemu 0.11", + .cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -277,6 +284,7 @@ static QEMUMachine pc_machine_v0_11 = { static QEMUMachine pc_machine_v0_10 = { .name = "pc-0.10", .desc = "Standard PC, qemu 0.10", + .cpu_model = DEF_CPU_MODEL, .init = pc_init_pci, .max_cpus = 255, .compat_props = (GlobalProperty[]) { @@ -324,6 +332,7 @@ static QEMUMachine pc_machine_v0_10 = { static QEMUMachine isapc_machine = { .name = "isapc", .desc = "ISA-only PC", + .cpu_model = "486", .init = pc_init_isa, .max_cpus = 1, }; diff --git a/vl.c b/vl.c index df414ef..3a55cc8 100644 --- a/vl.c +++ b/vl.c @@ -2904,6 +2904,10 @@ int main(int argc, char **argv, char **envp) } qemu_add_globals(); + if (cpu_model == NULL) { + cpu_model = machine->cpu_model; + } + machine->init(ram_size, boot_devices, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); -- 1.7.0.4