On 4/28/24 15:14, Philippe Mathieu-Daudé wrote:
Introduce a per-accelerator handler that can be call
when a vCPU exits.
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
include/sysemu/accel-ops.h | 1 +
system/cpus.c | 3 +++
2 files changed, 4 insertions(+)
Reviewed-by: Richard Henderson <richard.hender...@linaro.org>
r~
diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index ef91fc28bb..35dfb7e266 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -35,6 +35,7 @@ struct AccelOpsClass {
void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
void (*kick_vcpu_thread)(CPUState *cpu);
bool (*cpu_thread_is_idle)(CPUState *cpu);
+ void (*exit_vcpu_thread)(CPUState *cpu);
void (*synchronize_post_reset)(CPUState *cpu);
void (*synchronize_post_init)(CPUState *cpu);
diff --git a/system/cpus.c b/system/cpus.c
index e0530ad603..d0d585e8b9 100644
--- a/system/cpus.c
+++ b/system/cpus.c
@@ -425,6 +425,9 @@ void cpu_exit(CPUState *cpu)
/* Ensure cpu_exec will see the exit request after TCG has exited. */
smp_wmb();
qatomic_set(&cpu->neg.icount_decr.u16.high, -1);
+ if (cpus_accel->exit_vcpu_thread) {
+ cpus_accel->exit_vcpu_thread(cpu);
+ }
}
static void qemu_cpu_stop(CPUState *cpu, bool exit)