aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPhilippe Mathieu-Daudé <philmd@linaro.org>2025-01-30 11:37:28 +0100
committerFabiano Rosas <farosas@suse.de>2025-02-03 12:15:50 -0300
commitb5467913722a008eedeed71bccf20a38175a5818 (patch)
tree58fff08ff8c2d6127346f4d6542d8e1cd9c4e86b /tests
parent6f02691ff47255798def37bc47021e847c8d843d (diff)
downloadqemu-b5467913722a008eedeed71bccf20a38175a5818.zip
qemu-b5467913722a008eedeed71bccf20a38175a5818.tar.gz
qemu-b5467913722a008eedeed71bccf20a38175a5818.tar.bz2
tests/qtest: Make qtest_has_accel() generic
Since commit b14a0b7469f ("accel: Use QOM classes for accel types") accelerators are registered as QOM objects. Use QOM as a generic API to query for available accelerators. This is in particular useful to query hardware accelerators such HFV, Xen or WHPX which otherwise have their definitions poisoned in "exec/poison.h". Reviewed-by: Thomas Huth <thuth@redhat.com> Reviewed-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Message-ID: <20250130103728.536-3-philmd@linaro.org> Signed-off-by: Fabiano Rosas <farosas@suse.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtest/libqtest.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index f416cf8..fe8606b 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -30,6 +30,7 @@
#include "libqtest.h"
#include "libqmp.h"
+#include "qemu/accel.h"
#include "qemu/ctype.h"
#include "qemu/cutils.h"
#include "qemu/sockets.h"
@@ -1063,13 +1064,10 @@ static bool qtest_qom_has_concrete_type(const char *parent_typename,
bool qtest_has_accel(const char *accel_name)
{
- if (g_str_equal(accel_name, "tcg")) {
-#if defined(CONFIG_TCG)
- return true;
-#else
- return false;
-#endif
- } else if (g_str_equal(accel_name, "kvm")) {
+ static QList *list;
+ g_autofree char *accel_type = NULL;
+
+ if (g_str_equal(accel_name, "kvm")) {
int i;
const char *arch = qtest_get_arch();
const char *targets[] = { CONFIG_KVM_TARGETS };
@@ -1081,11 +1079,12 @@ bool qtest_has_accel(const char *accel_name)
}
}
}
- } else {
- /* not implemented */
- g_assert_not_reached();
+ return false;
}
- return false;
+
+ accel_type = g_strconcat(accel_name, ACCEL_CLASS_SUFFIX, NULL);
+
+ return qtest_qom_has_concrete_type("accel", accel_type, &list);
}
bool qtest_get_irq(QTestState *s, int num)