]> git.ipfire.org Git - thirdparty/qemu.git/commit
cpus.c: qemu_mutex_lock_iothread fix race condition at cpu thread init
authorAníbal Limón <anibal.limon@linux.intel.com>
Thu, 3 Sep 2015 20:48:33 +0000 (15:48 -0500)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Wed, 21 Oct 2015 01:00:17 +0000 (20:00 -0500)
commitd077545dfef3d59f0286e0cb28cdb1c6d0570c22
treeda64269d5935da7ca03edeb955ab8091d7954f24
parentf6737604da3b44322a91ebaa4b184aa519bbb66a
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).

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=nptl/pthread_create.c;h=d10f4ea8004e1d8f3a268b95cc0f8d93b8d89867;hb=HEAD#l621

Cc: qemu-stable@nongnu.org
Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
Message-Id: <1441313313-3040-1-git-send-email-anibal.limon@linux.intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 46036b2462c7ff56c0af6466ea6b9248197a38a8)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
cpus.c