diff mbox series

[v2,1/5] accel: Introduce AccelOpsClass::destroy_vcpu_thread()

Message ID 20220318151555.381737-2-mark.kanda@oracle.com (mailing list archive)
State New, archived
Headers show
Series vCPU hotunplug related memory leaks | expand

Commit Message

Mark Kanda March 18, 2022, 3:15 p.m. UTC
Add destroy_vcpu_thread() to AccelOps as a method for vcpu thread cleanup.
This will be used in subsequent patches.

Suggested-by: Philippe Mathieu-Daude <philippe.mathieu.daude@gmail.com>
Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
---
 include/sysemu/accel-ops.h | 1 +
 softmmu/cpus.c             | 3 +++
 2 files changed, 4 insertions(+)

Comments

Philippe Mathieu-Daudé March 18, 2022, 4:20 p.m. UTC | #1
On 18/3/22 16:15, Mark Kanda wrote:
> Add destroy_vcpu_thread() to AccelOps as a method for vcpu thread cleanup.
> This will be used in subsequent patches.
> 
> Suggested-by: Philippe Mathieu-Daude <philippe.mathieu.daude@gmail.com>

Thanks, but preferably:
Suggested-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> Signed-off-by: Mark Kanda <mark.kanda@oracle.com>
> ---
>   include/sysemu/accel-ops.h | 1 +
>   softmmu/cpus.c             | 3 +++
>   2 files changed, 4 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
diff mbox series

Patch

diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index 6013c9444c..e296b27b82 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -31,6 +31,7 @@  struct AccelOpsClass {
     bool (*cpus_are_resettable)(void);
 
     void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
+    void (*destroy_vcpu_thread)(CPUState *cpu);
     void (*kick_vcpu_thread)(CPUState *cpu);
     bool (*cpu_thread_is_idle)(CPUState *cpu);
 
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 7b75bb66d5..622f8b4608 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -609,6 +609,9 @@  void cpu_remove_sync(CPUState *cpu)
     qemu_mutex_unlock_iothread();
     qemu_thread_join(cpu->thread);
     qemu_mutex_lock_iothread();
+    if (cpus_accel->destroy_vcpu_thread) {
+        cpus_accel->destroy_vcpu_thread(cpu);
+    }
 }
 
 void cpus_register_accel(const AccelOpsClass *ops)