From patchwork Mon Jun 15 13:23:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 30322 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 n5FDOPro028570 for ; Mon, 15 Jun 2009 13:24:27 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760934AbZFONXY (ORCPT ); Mon, 15 Jun 2009 09:23:24 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1758890AbZFONXY (ORCPT ); Mon, 15 Jun 2009 09:23:24 -0400 Received: from mx2.redhat.com ([66.187.237.31]:44165 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760892AbZFONXR (ORCPT ); Mon, 15 Jun 2009 09:23:17 -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 n5FDNKvX026676 for ; Mon, 15 Jun 2009 09:23:20 -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 n5FDNJQE009570; Mon, 15 Jun 2009 09:23:20 -0400 Received: from dhcp-1-237.tlv.redhat.com (dhcp-1-237.tlv.redhat.com [10.35.1.237]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n5FDNIUc025637; Mon, 15 Jun 2009 09:23:19 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id 6784618D47E; Mon, 15 Jun 2009 16:23:17 +0300 (IDT) From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH 5/8] Retrieve mp state info in cpu_synchronize_state() Date: Mon, 15 Jun 2009 16:23:14 +0300 Message-Id: <1245072197-7538-6-git-send-email-gleb@redhat.com> In-Reply-To: <1245072197-7538-1-git-send-email-gleb@redhat.com> References: <1245072197-7538-1-git-send-email-gleb@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 And set env->halted based on the value to show accurate vcpu state in QEMU monitor. Signed-off-by: Gleb Natapov --- qemu-kvm.c | 27 +++++++++++++++++++++++++++ qemu-kvm.h | 2 ++ 2 files changed, 29 insertions(+), 0 deletions(-) diff --git a/qemu-kvm.c b/qemu-kvm.c index 5fa7154..3ae4b45 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -200,6 +200,33 @@ void kvm_save_registers(CPUState *env) on_vcpu(env, kvm_do_save_registers, env); } +static void kvm_do_load_mpstate(void *_env) +{ + CPUState *env = _env; + + kvm_arch_load_mpstate(env); +} + +void kvm_load_mpstate(CPUState *env) +{ + if (kvm_enabled() && qemu_system_ready) + on_vcpu(env, kvm_do_load_mpstate, env); +} + +static void kvm_do_save_mpstate(void *_env) +{ + CPUState *env = _env; + + kvm_arch_save_mpstate(env); + env->halted = (env->mp_state == KVM_MP_STATE_HALTED); +} + +void kvm_save_mpstate(CPUState *env) +{ + if (kvm_enabled()) + on_vcpu(env, kvm_do_save_mpstate, env); +} + int kvm_cpu_exec(CPUState *env) { int r; diff --git a/qemu-kvm.h b/qemu-kvm.h index 3b73fe9..22452e9 100644 --- a/qemu-kvm.h +++ b/qemu-kvm.h @@ -221,11 +221,13 @@ static inline int kvm_sync_vcpus(void) { return 0; } static inline void kvm_arch_get_registers(CPUState *env) { kvm_save_registers(env); + kvm_save_mpstate(env); } static inline void kvm_arch_put_registers(CPUState *env) { kvm_load_registers(env); + kvm_load_mpstate(env); } static inline void cpu_synchronize_state(CPUState *env, int modified)