]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
accel: Keep reference to AccelOpsClass in AccelClass
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 6 Jun 2025 10:07:47 +0000 (12:07 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 4 Jul 2025 12:43:46 +0000 (14:43 +0200)
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>

accel/accel-system.c
accel/tcg/tcg-accel-ops.c
include/qemu/accel.h
include/system/accel-ops.h

index a0f562ae9ff2ff17b170e3012345ee66a835c9e3..64bc991b1ce70fe3e327bc562758ed54ad401ef9 100644 (file)
@@ -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);
 }
index 71776bc29c0b0b2cd6477d95589bb031f60c8ba2..279dbfa1cf7e392312f7deeaa7c99d815371978c 100644 (file)
@@ -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;
index fbd3d897fef1692f95ec6df128e0e57831df1b33..9dea31454291cb65768598a7d63102ab72063137 100644 (file)
@@ -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);
index e775ecc348c99a3ed616e2810af0ef42c0d2aa0f..a786c7d478a971a0b605791a5a137b3afc081b02 100644 (file)
@@ -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);