From patchwork Mon Sep 27 13:16:15 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 65847 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 208F6B70CC for ; Mon, 27 Sep 2010 23:19:39 +1000 (EST) Received: from localhost ([127.0.0.1]:52602 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0DcF-0005HE-Vd for incoming@patchwork.ozlabs.org; Mon, 27 Sep 2010 09:19:36 -0400 Received: from [140.186.70.92] (port=51944 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1P0DZB-00040U-8L for qemu-devel@nongnu.org; Mon, 27 Sep 2010 09:16:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1P0DZ9-0006al-RZ for qemu-devel@nongnu.org; Mon, 27 Sep 2010 09:16:25 -0400 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:34171 helo=TX2EHSOBE008.bigfish.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1P0DZ9-0006ag-NE for qemu-devel@nongnu.org; Mon, 27 Sep 2010 09:16:23 -0400 Received: from mail184-tx2-R.bigfish.com (10.9.14.242) by TX2EHSOBE008.bigfish.com (10.9.40.28) with Microsoft SMTP Server id 8.1.340.0; Mon, 27 Sep 2010 13:16:22 +0000 Received: from mail184-tx2 (localhost.localdomain [127.0.0.1]) by mail184-tx2-R.bigfish.com (Postfix) with ESMTP id 39958C70450; Mon, 27 Sep 2010 13:16:22 +0000 (UTC) X-SpamScore: 1 X-BigFish: VS1(zzzz1202hzz8275bhz32i87h2a8h43h64h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail184-tx2 (localhost.localdomain [127.0.0.1]) by mail184-tx2 (MessageSwitch) id 1285593381718195_19110; Mon, 27 Sep 2010 13:16:21 +0000 (UTC) Received: from TX2EHSMHS028.bigfish.com (unknown [10.9.14.241]) by mail184-tx2.bigfish.com (Postfix) with ESMTP id A070D1A98054; Mon, 27 Sep 2010 13:16:21 +0000 (UTC) Received: from ausb3extmailp01.amd.com (163.181.251.8) by TX2EHSMHS028.bigfish.com (10.9.99.128) with Microsoft SMTP Server (TLS) id 14.0.482.44; Mon, 27 Sep 2010 13:16:19 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp01.amd.com (Switch-3.2.7/Switch-3.2.7) with SMTP id o8RDJl7S026332; Mon, 27 Sep 2010 08:19:50 -0500 X-WSS-ID: 0L9EQ6Z-02-JO3-02 X-M-MSG: Received: from sausexhtp02.amd.com (sausexhtp02.amd.com [163.181.3.152]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (No client certificate requested) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 2CBB9C88B0; Mon, 27 Sep 2010 08:16:10 -0500 (CDT) Received: from storexhtp02.amd.com (172.24.4.4) by sausexhtp02.amd.com (163.181.3.152) with Microsoft SMTP Server (TLS) id 8.3.83.0; Mon, 27 Sep 2010 08:16:14 -0500 Received: from gwo.osrc.amd.com (165.204.16.204) by storexhtp02.amd.com (172.24.4.4) with Microsoft SMTP Server id 8.3.83.0; Mon, 27 Sep 2010 09:16:13 -0400 Received: from lemmy.osrc.amd.com (lemmy.osrc.amd.com [165.204.15.93]) by gwo.osrc.amd.com (Postfix) with ESMTP id B461349C222; Mon, 27 Sep 2010 14:16:12 +0100 (BST) Received: by lemmy.osrc.amd.com (Postfix, from userid 1000) id 8EB44A0733; Mon, 27 Sep 2010 15:16:30 +0200 (CEST) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti Date: Mon, 27 Sep 2010 15:16:15 +0200 Message-ID: <1285593377-1754-2-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1285593377-1754-1-git-send-email-joerg.roedel@amd.com> References: <1285593377-1754-1-git-send-email-joerg.roedel@amd.com> MIME-Version: 1.0 X-Reverse-DNS: unknown X-detected-operating-system: by eggs.gnu.org: Windows 2000 SP4, XP SP1+ Cc: Joerg Roedel , Alexander Graf , kvm@vger.kernel.org, qemu-devel@nongnu.org Subject: [Qemu-devel] [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 As requested by Alex this patch makes kvm64 the default CPU model when qemu is started with -enable-kvm. This takes only effect for qemu-versions newer or equal to 0.14.0. Signed-off-by: Joerg Roedel --- hw/boards.h | 1 + hw/pc.c | 21 ++++++++++++++++----- hw/pc_piix.c | 6 ++++++ qemu-version.h | 35 +++++++++++++++++++++++++++++++++++ vl.c | 4 ++++ 5 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 qemu-version.h diff --git a/hw/boards.h b/hw/boards.h index 6f0f0d7..2d41b2d 100644 --- a/hw/boards.h +++ b/hw/boards.h @@ -19,6 +19,7 @@ typedef struct QEMUMachine { QEMUMachineInitFunc *init; int use_scsi; int max_cpus; + unsigned int compat_version; unsigned int no_serial:1, no_parallel:1, use_virtcon:1, diff --git a/hw/pc.c b/hw/pc.c index 69b13bf..372ec4c 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -40,6 +40,16 @@ #include "sysbus.h" #include "sysemu.h" #include "blockdev.h" +#include "kvm.h" +#include "qemu-version.h" + +#ifdef TARGET_X86_64 +#define DEFAULT_KVM_CPU_MODEL "kvm64" +#define DEFAULT_QEMU_CPU_MODEL "qemu64" +#else +#define DEFAULT_KVM_CPU_MODEL "kvm32" +#define DEFAULT_QEMU_CPU_MODEL "qemu32" +#endif /* output Bochs bios info messages */ //#define DEBUG_BIOS @@ -867,11 +877,12 @@ void pc_cpus_init(const char *cpu_model) /* init CPUs */ if (cpu_model == NULL) { -#ifdef TARGET_X86_64 - cpu_model = "qemu64"; -#else - cpu_model = "qemu32"; -#endif + if (kvm_enabled() && + qemu_compat_version >= QEMU_COMPAT_VERSION(0, 14, 0)) { + cpu_model = DEFAULT_KVM_CPU_MODEL; + } else { + cpu_model = DEFAULT_QEMU_CPU_MODEL; + } } for(i = 0; i < smp_cpus; i++) { diff --git a/hw/pc_piix.c b/hw/pc_piix.c index 12359a7..9e46b71 100644 --- a/hw/pc_piix.c +++ b/hw/pc_piix.c @@ -35,6 +35,7 @@ #include "sysemu.h" #include "sysbus.h" #include "blockdev.h" +#include "qemu-version.h" #define MAX_IDE_BUS 2 @@ -217,6 +218,7 @@ static QEMUMachine pc_machine = { .desc = "Standard PC", .init = pc_init_pci, .max_cpus = 255, + .compat_version = QEMU_COMPAT_VERSION(0, 13, 0), .is_default = 1, }; @@ -225,6 +227,7 @@ static QEMUMachine pc_machine_v0_12 = { .desc = "Standard PC", .init = pc_init_pci, .max_cpus = 255, + .compat_version = QEMU_COMPAT_VERSION(0, 12, 0), .compat_props = (GlobalProperty[]) { { .driver = "virtio-serial-pci", @@ -244,6 +247,7 @@ static QEMUMachine pc_machine_v0_11 = { .desc = "Standard PC, qemu 0.11", .init = pc_init_pci, .max_cpus = 255, + .compat_version = QEMU_COMPAT_VERSION(0, 11, 0), .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", @@ -279,6 +283,7 @@ static QEMUMachine pc_machine_v0_10 = { .desc = "Standard PC, qemu 0.10", .init = pc_init_pci, .max_cpus = 255, + .compat_version = QEMU_COMPAT_VERSION(0, 10, 0), .compat_props = (GlobalProperty[]) { { .driver = "virtio-blk-pci", @@ -325,6 +330,7 @@ static QEMUMachine isapc_machine = { .name = "isapc", .desc = "ISA-only PC", .init = pc_init_isa, + .compat_version = QEMU_COMPAT_VERSION(0, 10, 0), .max_cpus = 1, }; diff --git a/qemu-version.h b/qemu-version.h new file mode 100644 index 0000000..b4bfe48 --- /dev/null +++ b/qemu-version.h @@ -0,0 +1,35 @@ +/* + * qemu-version.h + * + * Defines needed for handling QEMU version compatibility + * + * Copyright (c) 2010 Joerg Roedel + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef _QEMU_VERSION_H_ +#define _QEMU_VERSION_H_ + +extern unsigned int qemu_compat_version; + +#define QEMU_COMPAT_VERSION(major, minor, patchlevel) \ + ((unsigned int)(major << 16) | (minor << 8) | (patchlevel)) + +#endif diff --git a/vl.c b/vl.c index d352d18..37727f3 100644 --- a/vl.c +++ b/vl.c @@ -161,6 +161,7 @@ int main(int argc, char **argv) #include "qemu-queue.h" #include "cpus.h" #include "arch_init.h" +#include "qemu-version.h" //#define DEBUG_NET //#define DEBUG_SLIRP @@ -169,6 +170,7 @@ int main(int argc, char **argv) #define MAX_VIRTIO_CONSOLES 1 +unsigned int qemu_compat_version; static const char *data_dir; const char *bios_name = NULL; enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB; @@ -2696,6 +2698,8 @@ int main(int argc, char **argv, char **envp) default_sdcard = 0; } + qemu_compat_version = machine->compat_version; + if (display_type == DT_NOGRAPHIC) { if (default_parallel) add_device_config(DEV_PARALLEL, "null");