From patchwork Wed Jan 9 18:53:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eduardo Habkost X-Patchwork-Id: 210819 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 DC66C2C0193 for ; Thu, 10 Jan 2013 05:53:38 +1100 (EST) Received: from localhost ([::1]:42712 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt0mP-0005I0-01 for incoming@patchwork.ozlabs.org; Wed, 09 Jan 2013 13:53:37 -0500 Received: from eggs.gnu.org ([208.118.235.92]:50346) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt0lO-0003B2-2W for qemu-devel@nongnu.org; Wed, 09 Jan 2013 13:52:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tt0lH-0005eW-QM for qemu-devel@nongnu.org; Wed, 09 Jan 2013 13:52:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:31339) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tt0lH-0005dt-H3 for qemu-devel@nongnu.org; Wed, 09 Jan 2013 13:52:27 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r09IqQoo030118 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 9 Jan 2013 13:52:26 -0500 Received: from blackpad.lan.raisama.net (vpn1-7-24.gru2.redhat.com [10.97.7.24]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r09IqQRq011524; Wed, 9 Jan 2013 13:52:26 -0500 Received: by blackpad.lan.raisama.net (Postfix, from userid 500) id 80CA6203D30; Wed, 9 Jan 2013 16:54:03 -0200 (BRST) From: Eduardo Habkost To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2013 16:53:44 -0200 Message-Id: <1357757632-1950-5-git-send-email-ehabkost@redhat.com> In-Reply-To: <1357757632-1950-1-git-send-email-ehabkost@redhat.com> References: <1357757632-1950-1-git-send-email-ehabkost@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: kvm@vger.kernel.org, Gleb Natapov , "Michael S. Tsirkin" , Marcelo Tosatti , Igor Mammedov , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [RFC 04/12] kvm: Create kvm_arch_vcpu_id() function 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 This will allow each architecture to define how the VCPU ID is set on the KVM_CREATE_VCPU ioctl call. Signed-off-by: Eduardo Habkost --- Cc: kvm@vger.kernel.org Cc: Michael S. Tsirkin Cc: Gleb Natapov Cc: Marcelo Tosatti Changes v2: - Get CPUState as argument instead of CPUArchState --- include/sysemu/kvm.h | 3 +++ kvm-all.c | 2 +- target-i386/kvm.c | 5 +++++ target-ppc/kvm.c | 5 +++++ target-s390x/kvm.c | 5 +++++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h index 22acf91..384ee66 100644 --- a/include/sysemu/kvm.h +++ b/include/sysemu/kvm.h @@ -196,6 +196,9 @@ int kvm_arch_init(KVMState *s); int kvm_arch_init_vcpu(CPUState *cpu); +/* Returns VCPU ID to be used on KVM_CREATE_VCPU ioctl() */ +unsigned long kvm_arch_vcpu_id(CPUState *cpu); + void kvm_arch_reset_vcpu(CPUState *cpu); int kvm_arch_on_sigbus_vcpu(CPUState *cpu, int code, void *addr); diff --git a/kvm-all.c b/kvm-all.c index 6e2164b..d37359f 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -222,7 +222,7 @@ int kvm_init_vcpu(CPUState *cpu) DPRINTF("kvm_init_vcpu\n"); - ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, cpu->cpu_index); + ret = kvm_vm_ioctl(s, KVM_CREATE_VCPU, kvm_arch_vcpu_id(cpu)); if (ret < 0) { DPRINTF("kvm_create_vcpu failed\n"); goto err; diff --git a/target-i386/kvm.c b/target-i386/kvm.c index 3acff40..5f3f789 100644 --- a/target-i386/kvm.c +++ b/target-i386/kvm.c @@ -411,6 +411,11 @@ static void cpu_update_state(void *opaque, int running, RunState state) } } +unsigned long kvm_arch_vcpu_id(CPUState *cpu) +{ + return cpu->cpu_index; +} + int kvm_arch_init_vcpu(CPUState *cs) { struct { diff --git a/target-ppc/kvm.c b/target-ppc/kvm.c index e4a387f..bdcd133 100644 --- a/target-ppc/kvm.c +++ b/target-ppc/kvm.c @@ -384,6 +384,11 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu) #endif /* !defined (TARGET_PPC64) */ +unsigned long kvm_arch_vcpu_id(CPUState *cpu) +{ + return cpu->cpu_index; +} + int kvm_arch_init_vcpu(CPUState *cs) { PowerPCCPU *cpu = POWERPC_CPU(cs); diff --git a/target-s390x/kvm.c b/target-s390x/kvm.c index 6ec5e6d..bd9864c 100644 --- a/target-s390x/kvm.c +++ b/target-s390x/kvm.c @@ -72,6 +72,11 @@ int kvm_arch_init(KVMState *s) return 0; } +unsigned long kvm_arch_vcpu_id(CPUState *cpu) +{ + return cpu->cpu_index; +} + int kvm_arch_init_vcpu(CPUState *cpu) { int ret = 0;