From patchwork Sun Jun 14 10:52:22 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gleb Natapov X-Patchwork-Id: 30144 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 n5EAqdfq017533 for ; Sun, 14 Jun 2009 10:52:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756620AbZFNKwa (ORCPT ); Sun, 14 Jun 2009 06:52:30 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1756678AbZFNKw3 (ORCPT ); Sun, 14 Jun 2009 06:52:29 -0400 Received: from mx2.redhat.com ([66.187.237.31]:33926 "EHLO mx2.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756161AbZFNKwX (ORCPT ); Sun, 14 Jun 2009 06:52:23 -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 n5EAqQeY023688 for ; Sun, 14 Jun 2009 06:52:26 -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 n5EAqPAg020598; Sun, 14 Jun 2009 06:52:25 -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 n5EAqO20003131; Sun, 14 Jun 2009 06:52:24 -0400 Received: by dhcp-1-237.tlv.redhat.com (Postfix, from userid 13519) id D76C818D47C; Sun, 14 Jun 2009 13:52:22 +0300 (IDT) From: Gleb Natapov To: avi@redhat.com Cc: kvm@vger.kernel.org Subject: [PATCH 6/6] Retrieve mp state info in cpu_synchronize_state() Date: Sun, 14 Jun 2009 13:52:22 +0300 Message-Id: <1244976742-22926-6-git-send-email-gleb@redhat.com> In-Reply-To: <1244976742-22926-1-git-send-email-gleb@redhat.com> References: <1244976742-22926-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 af3fd91..41dcdc3 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -187,6 +187,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)