#include "kvm.h"
#include "exec-all.h"
+#include "qemu-thread.h"
#include "cpus.h"
#include "compatfd.h"
}
}
-int qemu_cpu_self(void *env)
+int qemu_cpu_is_self(void *env)
{
return 1;
}
#else /* CONFIG_IOTHREAD */
-#include "qemu-thread.h"
-
QemuMutex qemu_global_mutex;
static QemuMutex qemu_fair_mutex;
qemu_mutex_init(&qemu_global_mutex);
qemu_mutex_lock(&qemu_global_mutex);
- qemu_thread_self(&io_thread);
+ qemu_thread_get_self(&io_thread);
return 0;
}
{
struct qemu_work_item wi;
- if (qemu_cpu_self(env)) {
+ if (qemu_cpu_is_self(env)) {
func(data);
return;
}
CPUState *env;
while (all_cpu_threads_idle()) {
- qemu_cond_timedwait(tcg_halt_cond, &qemu_global_mutex, 1000);
+ qemu_cond_wait(tcg_halt_cond, &qemu_global_mutex);
}
qemu_mutex_unlock(&qemu_global_mutex);
static void qemu_kvm_wait_io_event(CPUState *env)
{
while (cpu_thread_is_idle(env)) {
- qemu_cond_timedwait(env->halt_cond, &qemu_global_mutex, 1000);
+ qemu_cond_wait(env->halt_cond, &qemu_global_mutex);
}
qemu_kvm_eat_signals(env);
int r;
qemu_mutex_lock(&qemu_global_mutex);
- qemu_thread_self(env->thread);
+ qemu_thread_get_self(env->thread);
r = kvm_init_vcpu(env);
if (r < 0) {
/* and wait for machine initialization */
while (!qemu_system_ready) {
- qemu_cond_timedwait(&qemu_system_cond, &qemu_global_mutex, 100);
+ qemu_cond_wait(&qemu_system_cond, &qemu_global_mutex);
}
while (1) {
CPUState *env = arg;
qemu_tcg_init_cpu_signals();
- qemu_thread_self(env->thread);
+ qemu_thread_get_self(env->thread);
/* signal CPU creation */
qemu_mutex_lock(&qemu_global_mutex);
/* and wait for machine initialization */
while (!qemu_system_ready) {
- qemu_cond_timedwait(&qemu_system_cond, &qemu_global_mutex, 100);
+ qemu_cond_wait(&qemu_system_cond, &qemu_global_mutex);
}
while (1) {
}
}
-int qemu_cpu_self(void *_env)
+int qemu_cpu_is_self(void *_env)
{
CPUState *env = _env;
- QemuThread this;
- qemu_thread_self(&this);
-
- return qemu_thread_equal(&this, env->thread);
+ return qemu_thread_is_self(env->thread);
}
void qemu_mutex_lock_iothread(void)
}
while (!all_vcpus_paused()) {
- qemu_cond_timedwait(&qemu_pause_cond, &qemu_global_mutex, 100);
+ qemu_cond_wait(&qemu_pause_cond, &qemu_global_mutex);
penv = first_cpu;
while (penv) {
qemu_cpu_kick(penv);
void cpu_stop_current(void)
{
if (cpu_single_env) {
+ cpu_single_env->stop = 0;
cpu_single_env->stopped = 1;
cpu_exit(cpu_single_env);
+ qemu_cond_signal(&qemu_pause_cond);
}
}
void vm_stop(int reason)
{
- QemuThread me;
- qemu_thread_self(&me);
-
- if (!qemu_thread_equal(&me, &io_thread)) {
+ if (!qemu_thread_is_self(&io_thread)) {
qemu_system_vmstop_request(reason);
/*
* FIXME: should not return to device code in case
cpu_handle_debug_exception(env);
break;
}
- } else if (env->stop) {
+ } else if (env->stop || env->stopped) {
break;
}
}