Commit 1b879fe489 for qemu.org
commit 1b879fe489f8894c5b07438f0b10706db916ca4f
Author: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Date: Fri Nov 6 17:53:26 2026 +0000
multi-target: restrict whpx-accel-*-cpu to matching target
On windows x64 host:
$ ./build/tests/unit/test-multi-target
Type 'whpx-accel-x86_64-cpu' is missing its parent 'accel-x86_64-cpu'
(same for windows-arm64 hosts and whpx-accel-aarch64-cpu)
Parent type is conditionally registered from current target:
register_accel_target_type uses '"accel-" + target_cpu_type()' as type
name. Since whpx-common.c is shared between arm and x86_64 targets,
only register whpx accelerator cpu type when current target cpu type
matches the one it was compiled for.
Reviewed-by: Mohamed Mediouni <mohamed@unpredictable.fr>
Link: https://lore.kernel.org/qemu-devel/20261106175326.22629-1-pierrick.bouvier@oss.qualcomm.com
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
diff --git a/accel/whpx/whpx-common.c b/accel/whpx/whpx-common.c
index 78d2827809..20c684638b 100644
--- a/accel/whpx/whpx-common.c
+++ b/accel/whpx/whpx-common.c
@@ -20,6 +20,7 @@
#include "hw/core/boards.h"
#include "hw/intc/ioapic.h"
#include "qemu/error-report.h"
+#include "qemu/target-info.h"
#include "qapi/error.h"
#include "qapi/qapi-types-common.h"
#include "qapi/qapi-type-infos-common.h"
@@ -492,11 +493,18 @@ static void whpx_cpu_accel_class_init(ObjectClass *oc, const void *data)
acc->cpu_instance_init = whpx_cpu_instance_init;
}
+/* TYPE_ACCEL_CPU is only registered for current target cpu type */
+static bool whpx_cpu_accel_is_available(void)
+{
+ return !strcmp(target_cpu_type(), CPU_RESOLVING_TYPE);
+}
+
static const TypeInfo whpx_cpu_accel_type = {
.name = ACCEL_CPU_NAME("whpx"),
.parent = TYPE_ACCEL_CPU,
.class_init = whpx_cpu_accel_class_init,
+ .is_available = whpx_cpu_accel_is_available,
.abstract = true,
};