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>
This commit is contained in:
parent
6f02691ff4
commit
b546791372
@ -30,6 +30,7 @@
|
|||||||
|
|
||||||
#include "libqtest.h"
|
#include "libqtest.h"
|
||||||
#include "libqmp.h"
|
#include "libqmp.h"
|
||||||
|
#include "qemu/accel.h"
|
||||||
#include "qemu/ctype.h"
|
#include "qemu/ctype.h"
|
||||||
#include "qemu/cutils.h"
|
#include "qemu/cutils.h"
|
||||||
#include "qemu/sockets.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)
|
bool qtest_has_accel(const char *accel_name)
|
||||||
{
|
{
|
||||||
if (g_str_equal(accel_name, "tcg")) {
|
static QList *list;
|
||||||
#if defined(CONFIG_TCG)
|
g_autofree char *accel_type = NULL;
|
||||||
return true;
|
|
||||||
#else
|
if (g_str_equal(accel_name, "kvm")) {
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
} else if (g_str_equal(accel_name, "kvm")) {
|
|
||||||
int i;
|
int i;
|
||||||
const char *arch = qtest_get_arch();
|
const char *arch = qtest_get_arch();
|
||||||
const char *targets[] = { CONFIG_KVM_TARGETS };
|
const char *targets[] = { CONFIG_KVM_TARGETS };
|
||||||
@ -1081,11 +1079,12 @@ bool qtest_has_accel(const char *accel_name)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
return false;
|
||||||
/* not implemented */
|
|
||||||
g_assert_not_reached();
|
|
||||||
}
|
}
|
||||||
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)
|
bool qtest_get_irq(QTestState *s, int num)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user