cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
PATCH 1/1 cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
When QEMU starts the RCU thread executes qemu_mutex_lock_thread causing error "qemu:qemu_cpu_kick_thread: No such process" and exits.
This isn't occur frequently but in glibc the thread id can exist and this not guarantee that the thread is on active/running state. If is inserted a sleep(1) after newthread assignment [1] the issue appears.
So not make assumption that thread exist if first_cpu->thread is set then change the validation of cpu to created that is set into cpu threads (kvm, tcg, dummy).
--- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
cpus.c +1 -1
@@ -1171,7 +1171,7 @@ void qemu_mutex_lock_iothread(void)* TCG code execution. */ if (!tcg_enabled () ||qemu_in_vcpu_thread () || - !first_cpu || !first_cpu->thread) { + !first_cpu || !first_cpu->created) {qemu_mutex_lock (&qemu_global_mutex);atomic_dec (&iothread_requesting_mutex); }else {
Signature · 1 line
1.9.1
Quoted 7 lines · Aníbal Limón
When QEMU starts the RCU thread executes
qemu_mutex_lock_threadcausing error "qemu:qemu_cpu_kick_thread: No such process" and exits.This isn't occur frequently but in glibc the thread id can exist and this not guarantee that the thread is on active/running state. If is inserted a sleep(1) after newthread assignment [1] the issue appears.
Quoted 7 lines
So not make assumption that thread exist if
first_cpu->threadis set then change the validation of cpu to created that is set into cpu threads (kvm, tcg, dummy).Signed-off-by Aníbal Limón <[email protected]>
Paolo
Quoted 18 lines
--- cpus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)cpus.c +1
-1@@ -1171,7 +1171,7 @@ void qemu_mutex_lock_iothread(void)* TCG code execution. */ if (!tcg_enabled () ||qemu_in_vcpu_thread () || - !first_cpu || !first_cpu->thread) { + !first_cpu || !first_cpu->created) {qemu_mutex_lock (&qemu_global_mutex);atomic_dec (&iothread_requesting_mutex); }else {