From patchwork Mon Jul 6 20:12:52 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 34305 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 n66KD1P9007173 for ; Mon, 6 Jul 2009 20:13:02 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753332AbZGFUM5 (ORCPT ); Mon, 6 Jul 2009 16:12:57 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753854AbZGFUM4 (ORCPT ); Mon, 6 Jul 2009 16:12:56 -0400 Received: from mx2.redhat.com ([66.187.237.31]:59239 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752744AbZGFUMw (ORCPT ); Mon, 6 Jul 2009 16:12:52 -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 n66KCuxj016534 for ; Mon, 6 Jul 2009 16:12:56 -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 n66KCtlD031478; Mon, 6 Jul 2009 16:12:55 -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 n66KCrSX031854; Mon, 6 Jul 2009 16:12:54 -0400 From: Glauber Costa To: kvm@vger.kernel.org Cc: avi@redhat.com Subject: [PATCH v3 5/5] remove wrappers around ex-libkvm functions Date: Mon, 6 Jul 2009 16:12:52 -0400 Message-Id: <1246911172-5869-6-git-send-email-glommer@redhat.com> In-Reply-To: <1246911172-5869-5-git-send-email-glommer@redhat.com> References: <1246911172-5869-1-git-send-email-glommer@redhat.com> <1246911172-5869-2-git-send-email-glommer@redhat.com> <1246911172-5869-3-git-send-email-glommer@redhat.com> <1246911172-5869-4-git-send-email-glommer@redhat.com> <1246911172-5869-5-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 Some functions in qemu existed only to call libkvm counterparts. Merge some of them Signed-off-by: Glauber Costa --- libkvm-all.h | 6 ++-- qemu-kvm.c | 75 ++++++++++++++-------------------------------------------- 2 files changed, 21 insertions(+), 60 deletions(-) diff --git a/libkvm-all.h b/libkvm-all.h index 6964b7a..118425f 100644 --- a/libkvm-all.h +++ b/libkvm-all.h @@ -98,9 +98,9 @@ int kvm_arch_run(kvm_vcpu_context_t vcpu); void kvm_show_code(kvm_vcpu_context_t vcpu); int handle_halt(kvm_vcpu_context_t vcpu); -int handle_shutdown(kvm_context_t kvm, void *env); -void post_kvm_run(kvm_context_t kvm, void *env); -int pre_kvm_run(kvm_context_t kvm, void *env); +int handle_shutdown(kvm_context_t kvm, CPUState *env); +void post_kvm_run(kvm_context_t kvm, CPUState *env); +int pre_kvm_run(kvm_context_t kvm, CPUState *env); int handle_io_window(kvm_context_t kvm); int handle_debug(kvm_vcpu_context_t vcpu, void *env); int try_push_interrupts(kvm_context_t kvm); diff --git a/qemu-kvm.c b/qemu-kvm.c index 40d59a7..fd30f44 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -174,27 +174,6 @@ int kvm_mmio_write(void *opaque, uint64_t addr, uint8_t *data, int len) return 0; } -static int kvm_io_window(void *opaque) -{ - return 1; -} - -static int kvm_halt(void *opaque, kvm_vcpu_context_t vcpu) -{ - return kvm_arch_halt(opaque, vcpu); -} - -static int kvm_shutdown(void *opaque, void *data) -{ - CPUState *env = (CPUState *)data; - - /* stop the current vcpu from going back to guest mode */ - env->kvm_cpu_state.stopped = 1; - - qemu_system_reset_request(); - return 1; -} - static int handle_unhandled(kvm_context_t kvm, kvm_vcpu_context_t vcpu, uint64_t reason) { @@ -991,45 +970,21 @@ static int handle_mmio(kvm_vcpu_context_t vcpu) int handle_io_window(kvm_context_t kvm) { - return kvm_io_window(kvm->opaque); + return 1; } int handle_halt(kvm_vcpu_context_t vcpu) { - return kvm_halt(vcpu->kvm->opaque, vcpu); -} - -int handle_shutdown(kvm_context_t kvm, void *env) -{ - return kvm_shutdown(kvm->opaque, env); -} - -static int kvm_try_push_interrupts(void *opaque) -{ - return kvm_arch_try_push_interrupts(opaque); + return kvm_arch_halt(vcpu->kvm->opaque, vcpu); } -static void kvm_post_run(void *opaque, void *data) +int handle_shutdown(kvm_context_t kvm, CPUState *env) { - CPUState *env = (CPUState *)data; - - pthread_mutex_lock(&qemu_mutex); - kvm_arch_post_kvm_run(opaque, env); -} - -static int kvm_pre_run(void *opaque, void *data) -{ - CPUState *env = (CPUState *)data; - - kvm_arch_pre_kvm_run(opaque, env); - - pthread_mutex_unlock(&qemu_mutex); - return 0; -} + /* stop the current vcpu from going back to guest mode */ + env->kvm_cpu_state.stopped = 1; -int try_push_interrupts(kvm_context_t kvm) -{ - return kvm_try_push_interrupts(kvm->opaque); + qemu_system_reset_request(); + return 1; } static inline void push_nmi(kvm_context_t kvm) @@ -1039,14 +994,20 @@ static inline void push_nmi(kvm_context_t kvm) #endif /* KVM_CAP_USER_NMI */ } -void post_kvm_run(kvm_context_t kvm, void *env) +void post_kvm_run(kvm_context_t kvm, CPUState *env) { - kvm_post_run(kvm->opaque, env); + pthread_mutex_lock(&qemu_mutex); + kvm_arch_post_kvm_run(kvm->opaque, env); } -int pre_kvm_run(kvm_context_t kvm, void *env) +int pre_kvm_run(kvm_context_t kvm, CPUState *env) { - return kvm_pre_run(kvm->opaque, env); + kvm_arch_pre_kvm_run(kvm->opaque, env); + + if (env->exit_request) + return 1; + pthread_mutex_unlock(&qemu_mutex); + return 0; } int kvm_get_interrupt_flag(kvm_vcpu_context_t vcpu) @@ -1070,7 +1031,7 @@ again: push_nmi(kvm); #if !defined(__s390__) if (!kvm->irqchip_in_kernel) - run->request_interrupt_window = try_push_interrupts(kvm); + run->request_interrupt_window = kvm_arch_try_push_interrupts(env); #endif r = pre_kvm_run(kvm, env); if (r)