Factor accel_create_vcpu_thread() out of system/cpus.c to be able to access accel/ internal definitions.
Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org> --- include/qemu/accel.h | 2 ++ accel/accel-common.c | 20 ++++++++++++++++++++ system/cpus.c | 4 +--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/include/qemu/accel.h b/include/qemu/accel.h index 3c9aaf9523c..a351eebe567 100644 --- a/include/qemu/accel.h +++ b/include/qemu/accel.h @@ -93,6 +93,8 @@ void accel_cpu_instance_init(CPUState *cpu); bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp); +void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu); + /** * accel_cpu_common_realize: * @cpu: The CPU that needs to call accel-specific cpu realization. diff --git a/accel/accel-common.c b/accel/accel-common.c index 4f3b42e7112..6bd4ef47c2c 100644 --- a/accel/accel-common.c +++ b/accel/accel-common.c @@ -10,6 +10,7 @@ #include "qemu/osdep.h" #include "qemu/accel.h" #include "qemu/target-info.h" +#include "system/accel-ops.h" #include "accel/accel-cpu.h" #include "accel-internal.h" @@ -88,6 +89,25 @@ void accel_cpu_instance_init(CPUState *cpu) } } +void accel_create_vcpu_thread(AccelState *accel, CPUState *cpu) +{ + AccelClass *ac; + + if (!accel) { + accel = current_accel(); + } + ac = ACCEL_GET_CLASS(accel); + + /* accelerators all implement the AccelOpsClass */ + g_assert(ac->ops); + + if (ac->ops->create_vcpu_thread != NULL) { + ac->ops->create_vcpu_thread(cpu); + } else { + g_assert_not_reached(); + } +} + bool accel_cpu_realize(AccelState *accel, CPUState *cpu, Error **errp) { AccelClass *acc; diff --git a/system/cpus.c b/system/cpus.c index 4835e5ced48..b6dff01c7ea 100644 --- a/system/cpus.c +++ b/system/cpus.c @@ -709,9 +709,7 @@ void qemu_init_vcpu(CPUState *cpu) cpu_address_space_init(cpu, 0, "cpu-memory", cpu->memory); } - /* accelerators all implement the AccelOpsClass */ - g_assert(cpus_accel != NULL && cpus_accel->create_vcpu_thread != NULL); - cpus_accel->create_vcpu_thread(cpu); + accel_create_vcpu_thread(NULL, cpu); while (!cpu->created) { qemu_cond_wait(&qemu_cpu_cond, &bql); -- 2.49.0