aboutsummaryrefslogtreecommitdiff
path: root/cpus.c
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2018-01-30 16:40:12 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2018-02-07 14:09:25 +0100
commitdbadee4ff4a02d4b4cc138dd63b769b1d9391896 (patch)
tree3acdc2a359e2329db777cce572ab582ee67939bb /cpus.c
parent8178e6376f311a5691ab6122e15863faa9a1f008 (diff)
cpus: join thread when removing a vCPU
If no one joins the thread, its associated memory is leaked. Reported-by: CheneyLin <linzc@zju.edu.cn> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'cpus.c')
-rw-r--r--cpus.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/cpus.c b/cpus.c
index fe127ac9cf..8d8bb7c6d3 100644
--- a/cpus.c
+++ b/cpus.c
@@ -1752,19 +1752,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 */