[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v4 07/13] accel-ops: Introduce create_vcpu_thread_precheck / post
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v4 07/13] accel-ops: Introduce create_vcpu_thread_precheck / postcheck handlers |
Date: |
Wed, 23 Mar 2022 18:17:45 +0100 |
From: Philippe Mathieu-Daudé <f4bug@amsat.org>
Introduce precheck/postcheck handlers which will help to
refactor code common to the various create_vcpu_thread()
implementations.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
include/sysemu/accel-ops.h | 4 ++++
softmmu/cpus.c | 8 +++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/include/sysemu/accel-ops.h b/include/sysemu/accel-ops.h
index 6013c9444c..26b542d35c 100644
--- a/include/sysemu/accel-ops.h
+++ b/include/sysemu/accel-ops.h
@@ -31,6 +31,10 @@ struct AccelOpsClass {
bool (*cpus_are_resettable)(void);
void (*create_vcpu_thread)(CPUState *cpu); /* MANDATORY NON-NULL */
+ /* If non-NULL, return whether common vCPU thread must be created */
+ bool (*create_vcpu_thread_precheck)(CPUState *cpu);
+ void (*create_vcpu_thread_postcheck)(CPUState *cpu);
+
void (*kick_vcpu_thread)(CPUState *cpu);
bool (*cpu_thread_is_idle)(CPUState *cpu);
diff --git a/softmmu/cpus.c b/softmmu/cpus.c
index 7b75bb66d5..857e2081ba 100644
--- a/softmmu/cpus.c
+++ b/softmmu/cpus.c
@@ -637,7 +637,13 @@ void qemu_init_vcpu(CPUState *cpu)
/* accelerators all implement the AccelOpsClass */
g_assert(cpus_accel != NULL && cpus_accel->create_vcpu_thread != NULL);
- cpus_accel->create_vcpu_thread(cpu);
+ if (cpus_accel->create_vcpu_thread_precheck == NULL
+ || cpus_accel->create_vcpu_thread_precheck(cpu)) {
+ cpus_accel->create_vcpu_thread(cpu);
+ }
+ if (cpus_accel->create_vcpu_thread_postcheck) {
+ cpus_accel->create_vcpu_thread_postcheck(cpu);
+ }
while (!cpu->created) {
qemu_cond_wait(&qemu_cpu_cond, &qemu_global_mutex);
--
2.35.1
- Re: [PATCH v4 01/13] cpu: Free cpu->cpu_ases in cpu_address_space_destroy(), (continued)
- [PATCH v4 02/13] target/i386/kvm: Free xsave_buf when destroying vCPU, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 03/13] target/i386/hvf: Free resources when vCPU is destroyed, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 04/13] accel/hvf: Remove pointless assertion, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 05/13] accel/tcg: Init TCG cflags in vCPU thread handler, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 06/13] accel/tcg: Reorganize tcg_accel_ops_init(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 07/13] accel-ops: Introduce create_vcpu_thread_precheck / postcheck handlers,
Philippe Mathieu-Daudé <=
- [PATCH v4 08/13] accel/tcg: Extract rr_create_vcpu_thread_precheck(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 09/13] accel/all: Extract common_vcpu_thread_create(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 10/13] accel-ops: Introduce common_vcpu_thread_destroy() and .precheck handler, Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 11/13] accel/tcg: Add rr_destroy_vcpu_thread_precheck(), Philippe Mathieu-Daudé, 2022/03/23
- [PATCH v4 12/13] softmmu/cpus: Free cpu->thread in generic_destroy_vcpu_thread(), Philippe Mathieu-Daudé, 2022/03/23