diff mbox

[5/8] Retrieve mp state info in cpu_synchronize_state()

Message ID 1245072197-7538-6-git-send-email-gleb@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gleb Natapov June 15, 2009, 1:23 p.m. UTC
And set env->halted based on the value to show accurate vcpu state in
QEMU monitor.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 qemu-kvm.c |   27 +++++++++++++++++++++++++++
 qemu-kvm.h |    2 ++
 2 files changed, 29 insertions(+), 0 deletions(-)
diff mbox

Patch

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)