@@ -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;
@@ -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)
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(-)