cpus: wait for CPU creation at central place
We can now also wait for the CPU creation for single-threaded TCG, so we can move the waiting bits further out. Signed-off-by: David Hildenbrand <david@redhat.com> Message-Id: <20180209195239.16048-3-david@redhat.com> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a342173ab7
commit
81e9631168
22
cpus.c
22
cpus.c
@ -1856,9 +1856,6 @@ static void qemu_tcg_init_vcpu(CPUState *cpu)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cpu->hThread = qemu_thread_get_handle(cpu->thread);
|
cpu->hThread = qemu_thread_get_handle(cpu->thread);
|
||||||
#endif
|
#endif
|
||||||
while (!cpu->created) {
|
|
||||||
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
/* For non-MTTCG cases we share the thread */
|
/* For non-MTTCG cases we share the thread */
|
||||||
cpu->thread = single_tcg_cpu_thread;
|
cpu->thread = single_tcg_cpu_thread;
|
||||||
@ -1884,9 +1881,6 @@ static void qemu_hax_start_vcpu(CPUState *cpu)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cpu->hThread = qemu_thread_get_handle(cpu->thread);
|
cpu->hThread = qemu_thread_get_handle(cpu->thread);
|
||||||
#endif
|
#endif
|
||||||
while (!cpu->created) {
|
|
||||||
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_kvm_start_vcpu(CPUState *cpu)
|
static void qemu_kvm_start_vcpu(CPUState *cpu)
|
||||||
@ -1900,9 +1894,6 @@ static void qemu_kvm_start_vcpu(CPUState *cpu)
|
|||||||
cpu->cpu_index);
|
cpu->cpu_index);
|
||||||
qemu_thread_create(cpu->thread, thread_name, qemu_kvm_cpu_thread_fn,
|
qemu_thread_create(cpu->thread, thread_name, qemu_kvm_cpu_thread_fn,
|
||||||
cpu, QEMU_THREAD_JOINABLE);
|
cpu, QEMU_THREAD_JOINABLE);
|
||||||
while (!cpu->created) {
|
|
||||||
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_hvf_start_vcpu(CPUState *cpu)
|
static void qemu_hvf_start_vcpu(CPUState *cpu)
|
||||||
@ -1921,9 +1912,6 @@ static void qemu_hvf_start_vcpu(CPUState *cpu)
|
|||||||
cpu->cpu_index);
|
cpu->cpu_index);
|
||||||
qemu_thread_create(cpu->thread, thread_name, qemu_hvf_cpu_thread_fn,
|
qemu_thread_create(cpu->thread, thread_name, qemu_hvf_cpu_thread_fn,
|
||||||
cpu, QEMU_THREAD_JOINABLE);
|
cpu, QEMU_THREAD_JOINABLE);
|
||||||
while (!cpu->created) {
|
|
||||||
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_whpx_start_vcpu(CPUState *cpu)
|
static void qemu_whpx_start_vcpu(CPUState *cpu)
|
||||||
@ -1940,9 +1928,6 @@ static void qemu_whpx_start_vcpu(CPUState *cpu)
|
|||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
cpu->hThread = qemu_thread_get_handle(cpu->thread);
|
cpu->hThread = qemu_thread_get_handle(cpu->thread);
|
||||||
#endif
|
#endif
|
||||||
while (!cpu->created) {
|
|
||||||
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void qemu_dummy_start_vcpu(CPUState *cpu)
|
static void qemu_dummy_start_vcpu(CPUState *cpu)
|
||||||
@ -1956,9 +1941,6 @@ static void qemu_dummy_start_vcpu(CPUState *cpu)
|
|||||||
cpu->cpu_index);
|
cpu->cpu_index);
|
||||||
qemu_thread_create(cpu->thread, thread_name, qemu_dummy_cpu_thread_fn, cpu,
|
qemu_thread_create(cpu->thread, thread_name, qemu_dummy_cpu_thread_fn, cpu,
|
||||||
QEMU_THREAD_JOINABLE);
|
QEMU_THREAD_JOINABLE);
|
||||||
while (!cpu->created) {
|
|
||||||
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void qemu_init_vcpu(CPUState *cpu)
|
void qemu_init_vcpu(CPUState *cpu)
|
||||||
@ -1988,6 +1970,10 @@ void qemu_init_vcpu(CPUState *cpu)
|
|||||||
} else {
|
} else {
|
||||||
qemu_dummy_start_vcpu(cpu);
|
qemu_dummy_start_vcpu(cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
while (!cpu->created) {
|
||||||
|
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cpu_stop_current(void)
|
void cpu_stop_current(void)
|
||||||
|
Loading…
Reference in New Issue
Block a user