If no one joins the thread, its associated memory is leaked.
Reported-by: CheneyLin <[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
---
cpus.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/cpus.c b/cpus.c
index 03b4533b7d..e8c3ba064c 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1795,19 +1795,14 @@ void resume_all_vcpus(void)
}
}
-void cpu_remove(CPUState *cpu)
+void cpu_remove_sync(CPUState *cpu)
{
cpu->stop = true;
cpu->unplug = true;
qemu_cpu_kick(cpu);
-}
-
-void cpu_remove_sync(CPUState *cpu)
-{
- cpu_remove(cpu);
- while (cpu->created) {
- qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
- }
+ qemu_mutex_unlock_iothread();
+ qemu_thread_join(cpu->thread);
+ qemu_mutex_lock_iothread();
}
/* For temporary buffers for forming a name */
--
2.14.3