]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
accel/system: Convert pre_resume() from AccelOpsClass to AccelClass
authorPhilippe Mathieu-Daudé <philmd@linaro.org>
Mon, 23 Jun 2025 15:58:39 +0000 (17:58 +0200)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Fri, 4 Jul 2025 13:37:07 +0000 (15:37 +0200)
Accelerators call pre_resume() once. Since it isn't a method to
call for each vCPU, move it from AccelOpsClass to AccelClass.
Adapt WHPX.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20250702185332.43650-21-philmd@linaro.org>

accel/accel-system.c
include/qemu/accel.h
include/system/accel-ops.h
system/cpus.c
target/i386/whpx/whpx-accel-ops.c
target/i386/whpx/whpx-accel-ops.h
target/i386/whpx/whpx-all.c

index af713cc9024d80f03148c8feec81a4d18d992371..c54c30f18baf9d90b5a2a3b5f9df8245726cc6c1 100644 (file)
@@ -62,6 +62,15 @@ void accel_setup_post(MachineState *ms)
     }
 }
 
+void accel_pre_resume(MachineState *ms, bool step_pending)
+{
+    AccelState *accel = ms->accelerator;
+    AccelClass *acc = ACCEL_GET_CLASS(accel);
+    if (acc->pre_resume_vm) {
+        acc->pre_resume_vm(accel, step_pending);
+    }
+}
+
 /* initialize the arch-independent accel operation interfaces */
 void accel_init_ops_interfaces(AccelClass *ac)
 {
index 1c097ac4dfb6928248037aaa8607a074797ff7cf..9e821d0faeae7d2ffd586bae5c4fccc059c0b429 100644 (file)
@@ -46,6 +46,7 @@ typedef struct AccelClass {
 
     /* system related hooks */
     void (*setup_post)(AccelState *as);
+    void (*pre_resume_vm)(AccelState *as, bool step_pending);
     bool (*has_memory)(AccelState *accel, AddressSpace *as,
                        hwaddr start_addr, hwaddr size);
 
@@ -86,6 +87,8 @@ int accel_init_machine(AccelState *accel, MachineState *ms);
 /* Called just before os_setup_post (ie just before drop OS privs) */
 void accel_setup_post(MachineState *ms);
 
+void accel_pre_resume(MachineState *ms, bool step_pending);
+
 /**
  * accel_cpu_instance_init:
  * @cpu: The CPU that needs to do accel-specific object initializations.
index a786c7d478a971a0b605791a5a137b3afc081b02..bf7383511d013f5d2a484c6ec4b94e813e4c8515 100644 (file)
@@ -61,7 +61,6 @@ struct AccelOpsClass {
      */
     void (*synchronize_state)(CPUState *cpu);
     void (*synchronize_pre_loadvm)(CPUState *cpu);
-    void (*synchronize_pre_resume)(bool step_pending);
 
     /* handle_interrupt is mandatory. */
     void (*handle_interrupt)(CPUState *cpu, int mask);
index 0d0eec82a2f2be52f66e9eca6c0caf1276990ae3..8e6da2e0606095a2b49a6fbe0fc83886e2162b01 100644 (file)
@@ -768,9 +768,7 @@ int vm_prepare_start(bool step_pending)
      * WHPX accelerator needs to know whether we are going to step
      * any CPUs, before starting the first one.
      */
-    if (cpus_accel->synchronize_pre_resume) {
-        cpus_accel->synchronize_pre_resume(step_pending);
-    }
+    accel_pre_resume(MACHINE(qdev_get_machine()), step_pending);
 
     /* We are sending this now, but the CPUs will be resumed shortly later */
     qapi_event_send_resume();
index 31cf15f0045ca118dcd15ac0c7f5fbdd985e6a3e..5f4841c9fa483b2f3c687b511021ccf74173d78e 100644 (file)
@@ -96,7 +96,6 @@ static void whpx_accel_ops_class_init(ObjectClass *oc, const void *data)
     ops->synchronize_post_init = whpx_cpu_synchronize_post_init;
     ops->synchronize_state = whpx_cpu_synchronize_state;
     ops->synchronize_pre_loadvm = whpx_cpu_synchronize_pre_loadvm;
-    ops->synchronize_pre_resume = whpx_cpu_synchronize_pre_resume;
 }
 
 static const TypeInfo whpx_accel_ops_type = {
index e6cf15511d46e38edeab74b60741a2d1a0319a7c..54cfc25a14717b20cd9d5e7819721fdc5753d683 100644 (file)
@@ -21,7 +21,6 @@ void whpx_cpu_synchronize_state(CPUState *cpu);
 void whpx_cpu_synchronize_post_reset(CPUState *cpu);
 void whpx_cpu_synchronize_post_init(CPUState *cpu);
 void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu);
-void whpx_cpu_synchronize_pre_resume(bool step_pending);
 
 /* state subset only touched by the VCPU itself during runtime */
 #define WHPX_SET_RUNTIME_STATE   1
index 721c4782b9c047553fe7b7669ae2ffcd3ddb75eb..faf56e19722881a7a6571d4aa6559ed10fd26d54 100644 (file)
@@ -2105,7 +2105,7 @@ void whpx_cpu_synchronize_pre_loadvm(CPUState *cpu)
     run_on_cpu(cpu, do_whpx_cpu_synchronize_pre_loadvm, RUN_ON_CPU_NULL);
 }
 
-void whpx_cpu_synchronize_pre_resume(bool step_pending)
+static void whpx_pre_resume_vm(AccelState *as, bool step_pending)
 {
     whpx_global.step_pending = step_pending;
 }
@@ -2697,6 +2697,7 @@ static void whpx_accel_class_init(ObjectClass *oc, const void *data)
     AccelClass *ac = ACCEL_CLASS(oc);
     ac->name = "WHPX";
     ac->init_machine = whpx_accel_init;
+    ac->pre_resume_vm = whpx_pre_resume_vm;
     ac->allowed = &whpx_allowed;
 
     object_class_property_add(oc, "kernel-irqchip", "on|off|split",