qemu CPUState already provides "stop" and "stopped" states. And they mean exactly that. There is no need for us to provide our own. Signed-off-by: Glauber Costa <glommer@xxxxxxxxxx> --- cpu-defs.h | 2 -- qemu-kvm.c | 30 ++++++++++++------------------ vl.c | 2 +- 3 files changed, 13 insertions(+), 21 deletions(-) diff --git a/cpu-defs.h b/cpu-defs.h index 7570096..fce366f 100644 --- a/cpu-defs.h +++ b/cpu-defs.h @@ -142,8 +142,6 @@ struct qemu_work_item; struct KVMCPUState { pthread_t thread; int signalled; - int stop; - int stopped; int created; void *vcpu_ctx; struct qemu_work_item *queued_work_first, *queued_work_last; diff --git a/qemu-kvm.c b/qemu-kvm.c index 0f5f14f..8eeace4 100644 --- a/qemu-kvm.c +++ b/qemu-kvm.c @@ -91,7 +91,7 @@ static int kvm_debug(void *opaque, void *data, if (handle) { kvm_debug_cpu_requested = env; - env->kvm_cpu_state.stopped = 1; + env->stopped = 1; } return handle; } @@ -977,7 +977,7 @@ int handle_halt(kvm_vcpu_context_t vcpu) int handle_shutdown(kvm_context_t kvm, CPUState *env) { /* stop the current vcpu from going back to guest mode */ - env->kvm_cpu_state.stopped = 1; + env->stopped = 1; qemu_system_reset_request(); return 1; @@ -1815,7 +1815,7 @@ int kvm_cpu_exec(CPUState *env) static int is_cpu_stopped(CPUState *env) { - return !vm_running || env->kvm_cpu_state.stopped; + return !vm_running || env->stopped; } static void flush_queued_work(CPUState *env) @@ -1861,9 +1861,9 @@ static void kvm_main_loop_wait(CPUState *env, int timeout) cpu_single_env = env; flush_queued_work(env); - if (env->kvm_cpu_state.stop) { - env->kvm_cpu_state.stop = 0; - env->kvm_cpu_state.stopped = 1; + if (env->stop) { + env->stop = 0; + env->stopped = 1; pthread_cond_signal(&qemu_pause_cond); } @@ -1875,7 +1875,7 @@ static int all_threads_paused(void) CPUState *penv = first_cpu; while (penv) { - if (penv->kvm_cpu_state.stop) + if (penv->stop) return 0; penv = (CPUState *)penv->next_cpu; } @@ -1889,11 +1889,11 @@ static void pause_all_threads(void) while (penv) { if (penv != cpu_single_env) { - penv->kvm_cpu_state.stop = 1; + penv->stop = 1; pthread_kill(penv->kvm_cpu_state.thread, SIG_IPI); } else { - penv->kvm_cpu_state.stop = 0; - penv->kvm_cpu_state.stopped = 1; + penv->stop = 0; + penv->stopped = 1; cpu_exit(penv); } penv = (CPUState *)penv->next_cpu; @@ -1910,8 +1910,8 @@ static void resume_all_threads(void) assert(!cpu_single_env); while (penv) { - penv->kvm_cpu_state.stop = 0; - penv->kvm_cpu_state.stopped = 0; + penv->stop = 0; + penv->stopped = 0; pthread_kill(penv->kvm_cpu_state.thread, SIG_IPI); penv = (CPUState *)penv->next_cpu; } @@ -2676,12 +2676,6 @@ int kvm_log_stop(target_phys_addr_t phys_addr, target_phys_addr_t len) return 0; } -void qemu_kvm_cpu_stop(CPUState *env) -{ - if (kvm_enabled()) - env->kvm_cpu_state.stopped = 1; -} - int kvm_set_boot_cpu_id(uint32_t id) { return kvm_set_boot_vcpu_id(kvm_context, id); diff --git a/vl.c b/vl.c index b3df596..6ef7690 100644 --- a/vl.c +++ b/vl.c @@ -3553,7 +3553,7 @@ void qemu_system_reset_request(void) reset_requested = 1; } if (cpu_single_env) { - qemu_kvm_cpu_stop(cpu_single_env); + cpu_single_env->stopped = 1; } qemu_notify_event(); } -- 1.6.2.2 -- 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