[Buildroot] [PATCH v6 6/6] package/kvm-unit-tests: allow kvmtool to be used
Romain Naour
romain.naour at smile.fr
Tue Mar 10 22:44:10 UTC 2026
Hello Alex, All,
Le 25/02/2026 à 11:55, Alex Bennée a écrit :
> For some targets launching tests with kvmtool is an option which makes
> for an even smaller test image. Create a new symbol which can be
> expanded with additional targets that will allow the skipping of the
> selection of QEMU if not needed.
>
> Reviewed-by: Thomas Huth <huth at tuxfamily.org>
> Signed-off-by: Alex Bennée <alex.bennee at linaro.org>
>
> ---
> v2
> - expand to include riscv, didn't bother with 32 bit arm given its deprecated
> - only expand target when arch can support it
> - update comment depends
> ---
> package/kvm-unit-tests/Config.in | 12 +++++++++---
> package/kvm-unit-tests/kvm-unit-tests.mk | 11 +++++++++++
> 2 files changed, 20 insertions(+), 3 deletions(-)
>
> diff --git a/package/kvm-unit-tests/Config.in b/package/kvm-unit-tests/Config.in
> index 74c32f46e0..f5b4177106 100644
> --- a/package/kvm-unit-tests/Config.in
> +++ b/package/kvm-unit-tests/Config.in
> @@ -13,6 +13,11 @@ config BR2_PACKAGE_KVM_UNIT_TESTS_ARCH_SUPPORTS
> default y if BR2_powerpc64 || BR2_powerpc64le
> default y if BR2_s390x
>
> +# Some architectures can use kvmtool instead of QEMU to launch the tests
> +config BR2_PACKAGE_KVM_UNIT_TESTS_CAN_USE_KVMTOOL
> + bool
> + default y if (BR2_aarch64 || BR2_riscv) && BR2_PACKAGE_KVMTOOL
Since it's a choice, It would be better to let the user select if KVMTOOL or
QEMU should be used.
> +
> config BR2_PACKAGE_KVM_UNIT_TESTS
> bool "kvm-unit-tests"
> depends on BR2_PACKAGE_KVM_UNIT_TESTS_ARCH_SUPPORTS
> @@ -24,8 +29,8 @@ config BR2_PACKAGE_KVM_UNIT_TESTS
> depends on (BR2_PACKAGE_GLIBC_UTILS || \
> BR2_UCLIBC_INSTALL_UTILS || \
> BR2_TOOLCHAIN_EXTERNAL_LIBC_UTILS_COPY) # runtime getconf
> - select BR2_PACKAGE_QEMU
> - select BR2_PACKAGE_QEMU_SYSTEM # runtime for qemu-system-$ARCH
> + select BR2_PACKAGE_QEMU if !BR2_PACKAGE_KVM_UNIT_TESTS_CAN_USE_KVMTOOL
> + select BR2_PACKAGE_QEMU_SYSTEM if !BR2_PACKAGE_KVM_UNIT_TESTS_CAN_USE_KVMTOOL # runtime for qemu-system-$ARCH
> select BR2_PACKAGE_COREUTILS # runtime for timeout
> select BR2_PACKAGE_BASH # runtime
> select BR2_PACKAGE_NMAP
> @@ -55,4 +60,5 @@ comment "kvm-unit-tests needs a toolchain w/ utils, gcc >= 8 and qemu"
When BR2_PACKAGE_KVM_UNIT_TESTS_CAN_USE_KVMTOOL is set, the comment is not
accurate since it contains 'qemu'.
> depends on !(BR2_PACKAGE_GLIBC_UTILS || \
> BR2_UCLIBC_INSTALL_UTILS || \
> BR2_TOOLCHAIN_EXTERNAL_LIBC_UTILS_COPY)
> - depends on !BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET
> + depends on !(BR2_PACKAGE_QEMU_ARCH_SUPPORTS_TARGET || \
> + BR2_PACKAGE_KVM_UNIT_TESTS_CAN_USE_KVMTOOL)
> diff --git a/package/kvm-unit-tests/kvm-unit-tests.mk b/package/kvm-unit-tests/kvm-unit-tests.mk
> index efc3c859aa..02191275a2 100644
> --- a/package/kvm-unit-tests/kvm-unit-tests.mk
> +++ b/package/kvm-unit-tests/kvm-unit-tests.mk
> @@ -40,6 +40,17 @@ KVM_UNIT_TESTS_CONF_OPTS =\
> --processor="$(GCC_TARGET_CPU)" \
> --endian="$(KVM_UNIT_TESTS_ENDIAN)"
>
> +# The default runner is QEMU but kvmtool can also be used on some
> +# architectures. The flag only works for those architectures that can
> +# support both.
> +ifeq ($(BR2_PACKAGE_KVM_UNIT_TESTS_CAN_USE_KVMTOOL), y)
> +ifeq ($(BR2_PACKAGE_QEMU_SYSTEM),y)
> +KVM_UNIT_TESTS_CONF_OPTS += --target=qemu
> +else ifeq ($(BR2_PACKAGE_KVMTOOL),y)
> +KVM_UNIT_TESTS_CONF_OPTS += --target=kvmtool
What if BR2_PACKAGE_QEMU_SYSTEM and BR2_PACKAGE_KVMTOOL are both enabled and the
used want to run tests with kvmtool ?
Best regards,
Romain
> +endif
> +endif
> +
> ifeq ($(BR2_ARM64_PAGE_SIZE_4K),y)
> KVM_UNIT_TESTS_CONF_OPTS += --page-size=4k
> else ifeq ($(BR2_ARM64_PAGE_SIZE_16K),y)
More information about the buildroot
mailing list