Skip to content

Commit

Permalink
cpus: join thread when removing a vCPU
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
bonzini committed Feb 7, 2018
1 parent 8178e63 commit dbadee4
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions cpus.c
Expand Up @@ -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 */
Expand Down

0 comments on commit dbadee4

Please sign in to comment.