From patchwork Fri Jul 10 20:17:58 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 35106 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6AKIHj5020568 for ; Fri, 10 Jul 2009 20:18:17 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756741AbZGJUSO (ORCPT ); Fri, 10 Jul 2009 16:18:14 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756480AbZGJUSO (ORCPT ); Fri, 10 Jul 2009 16:18:14 -0400 Received: from mx2.redhat.com ([66.187.237.31]:53920 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756109AbZGJUSE (ORCPT ); Fri, 10 Jul 2009 16:18:04 -0400 Received: from int-mx2.corp.redhat.com (int-mx2.corp.redhat.com [172.16.27.26]) by mx2.redhat.com (8.13.8/8.13.8) with ESMTP id n6AKI4Br018146 for ; Fri, 10 Jul 2009 16:18:04 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx2.corp.redhat.com (8.13.1/8.13.1) with ESMTP id n6AKI3cN007804; Fri, 10 Jul 2009 16:18:03 -0400 Received: from localhost.localdomain (virtlab1.virt.bos.redhat.com [10.16.72.21]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n6AKI0uT026979; Fri, 10 Jul 2009 16:18:02 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH v2 7/9] provide env->kvm_fd Date: Fri, 10 Jul 2009 16:17:58 -0400 Message-Id: <1247257080-18549-8-git-send-email-glommer@redhat.com> In-Reply-To: <1247257080-18549-7-git-send-email-glommer@redhat.com> References: <1247257080-18549-1-git-send-email-glommer@redhat.com> <1247257080-18549-2-git-send-email-glommer@redhat.com> <1247257080-18549-3-git-send-email-glommer@redhat.com> <1247257080-18549-4-git-send-email-glommer@redhat.com> <1247257080-18549-5-git-send-email-glommer@redhat.com> <1247257080-18549-6-git-send-email-glommer@redhat.com> <1247257080-18549-7-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.58 on 172.16.27.26 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org qemu upstream puts kvm information on env. Do that too, since it will allow us to use CPUState in cpu-specific functions, instead of kvm-specific types. Signed-off-by: Glauber Costa --- qemu-kvm.c | 9 +++++++-- qemu-kvm.h | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index e15956a..beee038 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -503,11 +503,12 @@ void kvm_disable_pit_creation(kvm_context_t kvm) kvm->no_pit_creation = 1; } -kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int id) +kvm_vcpu_context_t kvm_create_vcpu(CPUState *env, int id) { long mmap_size; int r; kvm_vcpu_context_t vcpu_ctx = qemu_malloc(sizeof(struct kvm_vcpu_context)); + kvm_context_t kvm = kvm_context; vcpu_ctx->kvm = kvm; vcpu_ctx->id = id; @@ -518,6 +519,10 @@ kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int id) goto err; } vcpu_ctx->fd = r; + + env->kvm_fd = r; + env->kvm_state = kvm_state; + mmap_size = ioctl(kvm->fd, KVM_GET_VCPU_MMAP_SIZE, 0); if (mmap_size == -1) { fprintf(stderr, "get vcpu mmap size: %m\n"); @@ -2013,7 +2018,7 @@ static void *ap_main_loop(void *_env) env->thread_id = kvm_get_thread_id(); sigfillset(&signals); sigprocmask(SIG_BLOCK, &signals, NULL); - env->kvm_cpu_state.vcpu_ctx = kvm_create_vcpu(kvm_context, env->cpu_index); + env->kvm_cpu_state.vcpu_ctx = kvm_create_vcpu(env, env->cpu_index); #ifdef USE_KVM_DEVICE_ASSIGNMENT /* do ioperm for io ports of assigned devices */ diff --git a/qemu-kvm.h b/qemu-kvm.h index 417622d..9d10cf6 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -181,7 +181,7 @@ void kvm_create_irqchip(kvm_context_t kvm); * \param slot vcpu number (> 0) * \return 0 on success, -errno on failure */ -kvm_vcpu_context_t kvm_create_vcpu(kvm_context_t kvm, int id); +kvm_vcpu_context_t kvm_create_vcpu(CPUState *env, int id); /*! * \brief Start the VCPU