diff options
author | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-06-06 12:07:47 +0200 |
---|---|---|
committer | Philippe Mathieu-Daudé <philmd@linaro.org> | 2025-07-04 14:43:46 +0200 |
commit | 487b25c9d93add2e0e58275d7c1ef89810fad763 (patch) | |
tree | 5f298a07e854be586ebd43e458d9cc6892640cf8 | |
parent | b64bb17d14a62ea04b605f81daec8a5a4fad3be4 (diff) | |
download | qemu-487b25c9d93add2e0e58275d7c1ef89810fad763.zip qemu-487b25c9d93add2e0e58275d7c1ef89810fad763.tar.gz qemu-487b25c9d93add2e0e58275d7c1ef89810fad763.tar.bz2 |
accel: Keep reference to AccelOpsClass in AccelClass
Allow dereferencing AccelOpsClass outside of accel/accel-system.c.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Zhao Liu <zhao1.liu@intel.com>
Message-Id: <20250703173248.44995-30-philmd@linaro.org>
-rw-r--r-- | accel/accel-system.c | 3 | ||||
-rw-r--r-- | accel/tcg/tcg-accel-ops.c | 4 | ||||
-rw-r--r-- | include/qemu/accel.h | 3 | ||||
-rw-r--r-- | include/system/accel-ops.h | 3 |
4 files changed, 10 insertions, 3 deletions
diff --git a/accel/accel-system.c b/accel/accel-system.c index a0f562a..64bc991 100644 --- a/accel/accel-system.c +++ b/accel/accel-system.c @@ -85,8 +85,9 @@ void accel_init_ops_interfaces(AccelClass *ac) * non-NULL create_vcpu_thread operation. */ ops = ACCEL_OPS_CLASS(oc); + ac->ops = ops; if (ops->ops_init) { - ops->ops_init(ops); + ops->ops_init(ac); } cpus_register_accel(ops); } diff --git a/accel/tcg/tcg-accel-ops.c b/accel/tcg/tcg-accel-ops.c index 71776bc..279dbfa 100644 --- a/accel/tcg/tcg-accel-ops.c +++ b/accel/tcg/tcg-accel-ops.c @@ -199,8 +199,10 @@ static inline void tcg_remove_all_breakpoints(CPUState *cpu) cpu_watchpoint_remove_all(cpu, BP_GDB); } -static void tcg_accel_ops_init(AccelOpsClass *ops) +static void tcg_accel_ops_init(AccelClass *ac) { + AccelOpsClass *ops = ac->ops; + if (qemu_tcg_mttcg_enabled()) { ops->create_vcpu_thread = mttcg_start_vcpu_thread; ops->kick_vcpu_thread = mttcg_kick_vcpu_thread; diff --git a/include/qemu/accel.h b/include/qemu/accel.h index fbd3d89..9dea314 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -37,6 +37,9 @@ typedef struct AccelClass { /*< public >*/ const char *name; + /* Cached by accel_init_ops_interfaces() when created */ + AccelOpsClass *ops; + int (*init_machine)(MachineState *ms); bool (*cpu_common_realize)(CPUState *cpu, Error **errp); void (*cpu_common_unrealize)(CPUState *cpu); diff --git a/include/system/accel-ops.h b/include/system/accel-ops.h index e775ecc..a786c7d 100644 --- a/include/system/accel-ops.h +++ b/include/system/accel-ops.h @@ -10,6 +10,7 @@ #ifndef ACCEL_OPS_H #define ACCEL_OPS_H +#include "qemu/accel.h" #include "exec/vaddr.h" #include "qom/object.h" @@ -31,7 +32,7 @@ struct AccelOpsClass { /*< public >*/ /* initialization function called when accel is chosen */ - void (*ops_init)(AccelOpsClass *ops); + void (*ops_init)(AccelClass *ac); bool (*cpus_are_resettable)(void); void (*cpu_reset_hold)(CPUState *cpu); |