From patchwork Thu Oct 13 15:24:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Graf X-Patchwork-Id: 119551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A6507B70BF for ; Fri, 14 Oct 2011 02:21:28 +1100 (EST) Received: from localhost ([::1]:33241 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REN64-0006tm-2X for incoming@patchwork.ozlabs.org; Thu, 13 Oct 2011 11:21:24 -0400 Received: from eggs.gnu.org ([140.186.70.92]:38070) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REN5z-0006tV-2M for qemu-devel@nongnu.org; Thu, 13 Oct 2011 11:21:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REN5t-0004dA-RD for qemu-devel@nongnu.org; Thu, 13 Oct 2011 11:21:19 -0400 Received: from cantor2.suse.de ([195.135.220.15]:33134 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REN5t-0004cl-FS for qemu-devel@nongnu.org; Thu, 13 Oct 2011 11:21:13 -0400 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 48F6F8EE5B for ; Thu, 13 Oct 2011 17:21:11 +0200 (CEST) From: Alexander Graf To: qemu-devel@nongnu.org Date: Thu, 13 Oct 2011 17:24:13 +0200 Message-Id: <1318519453-6672-1-git-send-email-agraf@suse.de> X-Mailer: git-send-email 1.7.3.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 195.135.220.15 Subject: [Qemu-devel] [PATCH] KVM: Use -cpu host as default on x86 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 When running QEMU without -cpu parameter, the user usually wants a sane default. So far, we're using the qemu64/qemu32 CPU type, which basically means "the maximum TCG can emulate". That's a really good default when using TCG, but when running with KVM we much rather want a default saying "the maximum KVM can support". Fortunately we already have such a CPU type. It's called "host". All we need to do is to select it by default when not getting a -cpu passed in. This fixes a lot of subtile breakage in the GNU toolchain (libgmp) which hicks up on QEMU's non-existent CPU models. Signed-off-by: Alexander Graf --- hw/pc.c | 10 +++++++--- hw/pc.h | 2 +- hw/pc_piix.c | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 203627d..e0c48f2 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -941,17 +941,21 @@ static CPUState *pc_new_cpu(const char *cpu_model) return env; } -void pc_cpus_init(const char *cpu_model) +void pc_cpus_init(const char *cpu_model, int kvm_enabled) { int i; /* init CPUs */ if (cpu_model == NULL) { + if (kvm_enabled) { + cpu_model = "host"; + } else { #ifdef TARGET_X86_64 - cpu_model = "qemu64"; + cpu_model = "qemu64"; #else - cpu_model = "qemu32"; + cpu_model = "qemu32"; #endif + } } for(i = 0; i < smp_cpus; i++) { diff --git a/hw/pc.h b/hw/pc.h index f3e21b6..b5519ff 100644 --- a/hw/pc.h +++ b/hw/pc.h @@ -130,7 +130,7 @@ void pc_register_ferr_irq(qemu_irq irq); void pc_cmos_set_s3_resume(void *opaque, int irq, int level); void pc_acpi_smi_interrupt(void *opaque, int irq, int level); -void pc_cpus_init(const char *cpu_model); +void pc_cpus_init(const char *cpu_model, int kvm_enabled); void pc_memory_init(MemoryRegion *system_memory, const char *kernel_filename, const char *kernel_cmdline, diff --git a/hw/pc_piix.c b/hw/pc_piix.c index ce1c87f..a080191 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -99,7 +99,7 @@ static void pc_init1(MemoryRegion *system_memory, MemoryRegion *pci_memory; MemoryRegion *rom_memory; - pc_cpus_init(cpu_model); + pc_cpus_init(cpu_model, kvm_enabled()); if (kvmclock_enabled) { kvmclock_create();