diff mbox series

[3/6] accel: Clarify accel_cpu_common_[un]realize() use unassigned vCPU

Message ID 20240528145953.65398-4-philmd@linaro.org (mailing list archive)
State New, archived
Headers show
Series accel: Restrict TCG plugin (un)registration to TCG accel | expand

Commit Message

Philippe Mathieu-Daudé May 28, 2024, 2:59 p.m. UTC
In preparation of introducing [un]realize handlers for
when vCPUs are assigned, rename current handlers using
the '_unassigned' suffix.

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 accel/tcg/internal-common.h |  4 ++--
 include/qemu/accel.h        | 17 +++++++++++------
 accel/accel-target.c        | 11 ++++++-----
 accel/tcg/cpu-exec.c        |  4 ++--
 accel/tcg/tcg-all.c         |  4 ++--
 cpu-target.c                |  4 ++--
 6 files changed, 25 insertions(+), 19 deletions(-)
diff mbox series

Patch

diff --git a/accel/tcg/internal-common.h b/accel/tcg/internal-common.h
index a8fc3db774..ec2c6317b7 100644
--- a/accel/tcg/internal-common.h
+++ b/accel/tcg/internal-common.h
@@ -53,7 +53,7 @@  TranslationBlock *tb_link_page(TranslationBlock *tb);
 void cpu_restore_state_from_tb(CPUState *cpu, TranslationBlock *tb,
                                uintptr_t host_pc);
 
-bool tcg_exec_realizefn(CPUState *cpu, Error **errp);
-void tcg_exec_unrealizefn(CPUState *cpu);
+bool tcg_exec_realize_unassigned(CPUState *cpu, Error **errp);
+void tcg_exec_unrealize_unassigned(CPUState *cpu);
 
 #endif
diff --git a/include/qemu/accel.h b/include/qemu/accel.h
index 972a849a2b..dd18c41dc0 100644
--- a/include/qemu/accel.h
+++ b/include/qemu/accel.h
@@ -43,8 +43,8 @@  typedef struct AccelClass {
     bool (*has_memory)(MachineState *ms, AddressSpace *as,
                        hwaddr start_addr, hwaddr size);
 #endif
-    bool (*cpu_common_realize)(CPUState *cpu, Error **errp);
-    void (*cpu_common_unrealize)(CPUState *cpu);
+    bool (*cpu_common_realize_unassigned)(CPUState *cpu, Error **errp);
+    void (*cpu_common_unrealize_unassigned)(CPUState *cpu);
 
     /* gdbstub related hooks */
     int (*gdbstub_supported_sstep_flags)(void);
@@ -92,17 +92,22 @@  void accel_setup_post(MachineState *ms);
 void accel_cpu_instance_init(CPUState *cpu);
 
 /**
- * accel_cpu_common_realize:
+ * accel_cpu_common_realize_unassigned:
  * @cpu: The CPU that needs to call accel-specific cpu realization.
  * @errp: currently unused.
+ *
+ * The @cpu index is not yet assigned.
  */
-bool accel_cpu_common_realize(CPUState *cpu, Error **errp);
+bool accel_cpu_common_realize_unassigned(CPUState *cpu, Error **errp);
 
 /**
- * accel_cpu_common_unrealize:
+ * accel_cpu_common_unrealize_unassigned:
  * @cpu: The CPU that needs to call accel-specific cpu unrealization.
+ *
+ * The @cpu index is no more assigned, @cpu has been removed from the global
+ * #cpus_queue.
  */
-void accel_cpu_common_unrealize(CPUState *cpu);
+void accel_cpu_common_unrealize_unassigned(CPUState *cpu);
 
 /**
  * accel_supported_gdbstub_sstep_flags:
diff --git a/accel/accel-target.c b/accel/accel-target.c
index 08626c00c2..e0a79c0fce 100644
--- a/accel/accel-target.c
+++ b/accel/accel-target.c
@@ -119,7 +119,7 @@  void accel_cpu_instance_init(CPUState *cpu)
     }
 }
 
-bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
+bool accel_cpu_common_realize_unassigned(CPUState *cpu, Error **errp)
 {
     CPUClass *cc = CPU_GET_CLASS(cpu);
     AccelState *accel = current_accel();
@@ -132,21 +132,22 @@  bool accel_cpu_common_realize(CPUState *cpu, Error **errp)
     }
 
     /* generic realization */
-    if (acc->cpu_common_realize && !acc->cpu_common_realize(cpu, errp)) {
+    if (acc->cpu_common_realize_unassigned
+            && !acc->cpu_common_realize_unassigned(cpu, errp)) {
         return false;
     }
 
     return true;
 }
 
-void accel_cpu_common_unrealize(CPUState *cpu)
+void accel_cpu_common_unrealize_unassigned(CPUState *cpu)
 {
     AccelState *accel = current_accel();
     AccelClass *acc = ACCEL_GET_CLASS(accel);
 
     /* generic unrealization */
-    if (acc->cpu_common_unrealize) {
-        acc->cpu_common_unrealize(cpu);
+    if (acc->cpu_common_unrealize_unassigned) {
+        acc->cpu_common_unrealize_unassigned(cpu);
     }
 }
 
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index 2972f75b96..08769cf91e 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -1074,7 +1074,7 @@  int cpu_exec(CPUState *cpu)
     return ret;
 }
 
-bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
+bool tcg_exec_realize_unassigned(CPUState *cpu, Error **errp)
 {
     static bool tcg_target_initialized;
 
@@ -1094,7 +1094,7 @@  bool tcg_exec_realizefn(CPUState *cpu, Error **errp)
 }
 
 /* undo the initializations in reverse order */
-void tcg_exec_unrealizefn(CPUState *cpu)
+void tcg_exec_unrealize_unassigned(CPUState *cpu)
 {
 #ifndef CONFIG_USER_ONLY
     tcg_iommu_free_notifier_list(cpu);
diff --git a/accel/tcg/tcg-all.c b/accel/tcg/tcg-all.c
index 2090907dba..c08a6acc21 100644
--- a/accel/tcg/tcg-all.c
+++ b/accel/tcg/tcg-all.c
@@ -227,8 +227,8 @@  static void tcg_accel_class_init(ObjectClass *oc, void *data)
     AccelClass *ac = ACCEL_CLASS(oc);
     ac->name = "tcg";
     ac->init_machine = tcg_init_machine;
-    ac->cpu_common_realize = tcg_exec_realizefn;
-    ac->cpu_common_unrealize = tcg_exec_unrealizefn;
+    ac->cpu_common_realize_unassigned = tcg_exec_realize_unassigned;
+    ac->cpu_common_unrealize_unassigned = tcg_exec_unrealize_unassigned;
     ac->allowed = &tcg_allowed;
     ac->gdbstub_supported_sstep_flags = tcg_gdbstub_supported_sstep_flags;
 
diff --git a/cpu-target.c b/cpu-target.c
index 5af120e8aa..9ab5a28cb5 100644
--- a/cpu-target.c
+++ b/cpu-target.c
@@ -136,7 +136,7 @@  bool cpu_exec_realizefn(CPUState *cpu, Error **errp)
     /* cache the cpu class for the hotpath */
     cpu->cc = CPU_GET_CLASS(cpu);
 
-    if (!accel_cpu_common_realize(cpu, errp)) {
+    if (!accel_cpu_common_realize_unassigned(cpu, errp)) {
         return false;
     }
 
@@ -176,7 +176,7 @@  void cpu_exec_unrealizefn(CPUState *cpu)
      * Now that the vCPU has been removed from the RCU list, we can call
      * accel_cpu_common_unrealize, which may free fields using call_rcu.
      */
-    accel_cpu_common_unrealize(cpu);
+    accel_cpu_common_unrealize_unassigned(cpu);
 }
 
 /*