Message ID | 20220323171751.78612-12-philippe.mathieu.daude@gmail.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | accel: Fix vCPU memory leaks | expand |
On 3/23/22 10:17, Philippe Mathieu-Daudé wrote: > +bool rr_destroy_vcpu_thread_precheck(CPUState *cpu) > +{ > + if (single_tcg_cpu_thread) { > + single_tcg_cpu_thread = NULL; > + return true; > + } > + return false; > +} This would become void rr_destroy_vcpu_thread(CPUState *cpu) { if (single_tcg_cpu_thread) { g_free(single_tcg_cpu_thread); g_free(single_tcg_halt_cond); single_tcg_cpu_thread = NULL; single_tcg_halt_cond = NULL; } } r~
diff --git a/accel/tcg/tcg-accel-ops-rr.c b/accel/tcg/tcg-accel-ops-rr.c index 006b787289..6fe8e20356 100644 --- a/accel/tcg/tcg-accel-ops-rr.c +++ b/accel/tcg/tcg-accel-ops-rr.c @@ -295,3 +295,12 @@ void rr_create_vcpu_thread_postcheck(CPUState *cpu) cpu->created = true; } } + +bool rr_destroy_vcpu_thread_precheck(CPUState *cpu) +{ + if (single_tcg_cpu_thread) { + single_tcg_cpu_thread = NULL; + return true; + } + return false; +} diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 127dd6fee5..0b0dbcc47a 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -102,6 +102,7 @@ static void tcg_accel_ops_init(AccelOpsClass *ops) ops->vcpu_thread_fn = rr_vcpu_thread_fn; ops->create_vcpu_thread_precheck = rr_create_vcpu_thread_precheck; ops->create_vcpu_thread_postcheck = rr_create_vcpu_thread_postcheck; + ops->destroy_vcpu_thread_precheck = rr_destroy_vcpu_thread_precheck; ops->kick_vcpu_thread = rr_kick_vcpu_thread; if (icount_enabled()) {