And set env->halted based on the value to show accurate vcpu state in QEMU monitor. Signed-off-by: Gleb Natapov <gleb@xxxxxxxxxx> --- 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) -- 1.6.2.1 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html