kvm-riscv.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Alexandru Elisei <alexandru.elisei@arm.com>
To: Andrew Jones <andrew.jones@linux.dev>
Cc: eric.auger@redhat.com, lvivier@redhat.com, thuth@redhat.com,
	frankja@linux.ibm.com, imbrenda@linux.ibm.com, nrb@linux.ibm.com,
	david@redhat.com, pbonzini@redhat.com, kvm@vger.kernel.org,
	kvmarm@lists.linux.dev, linuxppc-dev@lists.ozlabs.org,
	kvm-riscv@lists.infradead.org, linux-s390@vger.kernel.org,
	will@kernel.org, julien.thierry.kdev@gmail.com, maz@kernel.org,
	oliver.upton@linux.dev, suzuki.poulose@arm.com,
	yuzenghui@huawei.com, joey.gouly@arm.com, andre.przywara@arm.com,
	shahuang@redhat.com
Subject: Re: [kvm-unit-tests PATCH v4 00/13] arm/arm64: Add kvmtool to the runner script
Date: Thu, 26 Jun 2025 17:48:03 +0100	[thread overview]
Message-ID: <aF15wzSHKxYZig3N@raptor> (raw)
In-Reply-To: <20250626-f9239a18e811ef67ae5a9686@orel>

Hi Drew,

On Thu, Jun 26, 2025 at 06:42:01PM +0200, Andrew Jones wrote:
> On Wed, Jun 25, 2025 at 04:48:00PM +0100, Alexandru Elisei wrote:
> > v3 can be found here [1]. Based on top of the series that add qemu_params and
> > test_args [2].
> > 
> > To goal is to allow the user to do:
> > 
> > $ ./configure --target=kvmtool
> > $ make clean && make
> > $ ./run_tests.sh
> > 
> > to run all the tests automatically with kvmtool.
> > 
> > Reasons to use kvmtool:
> > 
> > * kvmtool is smaller and a lot easier to modify compared to qemu, which
> > means developers may prefer it when adding or prototyping new features to
> > KVM, and being able to run all the tests reliably and automatically is very
> > useful.
> > 
> > * kvmtool is faster to run the tests (a couple of times faster on
> > my rockpro64), making for a quick turnaround. But do keep in mind that not
> > all tests work on kvmtool because of missing features compared to qemu.
> > 
> > * kvmtool does things differently than qemu: different memory layout,
> > different uart, PMU emulation is disabled by default, etc. This makes it a
> > good testing vehicule for kvm-unit-tests itself.
> 
> Thanks for this Alex! I didn't test it on arm yet, but I did test it on
> riscv with the quick patch below. It works great.

From a glance, the patch looks ok to me.

> 
> Applied to arm/queue
> 
> https://gitlab.com/jones-drew/kvm-unit-tests/-/commits/arm/queue

Thanks!

Alex

> 
> drew
> 
> 
> diff --git a/README.md b/README.md
> index 723ce04cd978..cbd8a9940ec4 100644
> --- a/README.md
> +++ b/README.md
> @@ -65,8 +65,8 @@ or:
>  
>  to run them all.
>  
> -All tests can be run using QEMU. On arm and arm64, tests can also be run using
> -kvmtool.
> +All tests can be run using QEMU. On arm, arm64, riscv32, and riscv64 tests can
> +also be run using kvmtool.
>  
>  By default the runner script searches for a suitable QEMU binary in the system.
>  To select a specific QEMU binary though, specify the QEMU=path/to/binary
> @@ -97,8 +97,7 @@ variable. kvmtool supports only kvm as the accelerator.
>  
>  Check [x86/efi/README.md](./x86/efi/README.md).
>  
> -On arm and arm64, this is only supported with QEMU; kvmtool cannot run the
> -tests under UEFI.
> +This is only supported with QEMU; kvmtool cannot run the tests under UEFI.
>  
>  # Tests configuration file
>  
> diff --git a/configure b/configure
> index 470f9d7cdb3b..4a9af4e0af30 100755
> --- a/configure
> +++ b/configure
> @@ -90,7 +90,7 @@ usage() {
>  	                           selects the best value based on the host system and the
>  	                           test configuration.
>  	    --target=TARGET        target platform that the tests will be running on (qemu or
> -	                           kvmtool, default is qemu) (arm/arm64 only)
> +	                           kvmtool, default is qemu) (arm/arm64 and riscv32/riscv64 only)
>  	    --cross-prefix=PREFIX  cross compiler prefix
>  	    --cc=CC                c compiler to use ($cc)
>  	    --cflags=FLAGS         extra options to be passed to the c compiler
> @@ -284,7 +284,8 @@ fi
>  if [ -z "$target" ]; then
>      target="qemu"
>  else
> -    if [ "$arch" != "arm64" ] && [ "$arch" != "arm" ]; then
> +    if [ "$arch" != "arm64" ] && [ "$arch" != "arm" ] &&
> +       [ "$arch" != "riscv32" ] && [ "$arch" != "riscv64" ]; then
>          echo "--target is not supported for $arch"
>          usage
>      fi
> @@ -393,6 +394,10 @@ elif [ "$arch" = "riscv32" ] || [ "$arch" = "riscv64" ]; then
>      testdir=riscv
>      arch_libdir=riscv
>      : "${uart_early_addr:=0x10000000}"
> +    if [ "$target" != "qemu" ] && [ "$target" != "kvmtool" ]; then
> +        echo "--target must be one of 'qemu' or 'kvmtool'!"
> +        usage
> +    fi
>  elif [ "$arch" = "s390x" ]; then
>      testdir=s390x
>  else
> @@ -519,7 +524,8 @@ EFI_DIRECT=$efi_direct
>  CONFIG_WERROR=$werror
>  GEN_SE_HEADER=$gen_se_header
>  EOF
> -if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
> +if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ] ||
> +   [ "$arch" = "riscv32" ] || [ "$arch" = "riscv64" ]; then
>      echo "TARGET=$target" >> config.mak
>  fi
>  
> diff --git a/riscv/efi/run b/riscv/efi/run
> index 5a72683a6ef5..b9b75440c659 100755
> --- a/riscv/efi/run
> +++ b/riscv/efi/run
> @@ -11,6 +11,12 @@ if [ ! -f config.mak ]; then
>  fi
>  source config.mak
>  source scripts/arch-run.bash
> +source scripts/vmm.bash
> +
> +if [[ $(vmm_get_target) == "kvmtool" ]]; then
> +	echo "kvmtool does not support EFI tests."
> +	exit 2
> +fi
>  
>  if [ -f RISCV_VIRT_CODE.fd ]; then
>  	DEFAULT_UEFI=RISCV_VIRT_CODE.fd
> diff --git a/riscv/run b/riscv/run
> index 0f000f0d82c6..3c242923412c 100755
> --- a/riscv/run
> +++ b/riscv/run
> @@ -10,35 +10,75 @@ if [ -z "$KUT_STANDALONE" ]; then
>  	source scripts/vmm.bash
>  fi
>  
> -# Allow user overrides of some config.mak variables
> -mach=$MACHINE_OVERRIDE
> -qemu_cpu=$TARGET_CPU_OVERRIDE
> -firmware=$FIRMWARE_OVERRIDE
> -
> -: "${mach:=virt}"
> -: "${qemu_cpu:=$TARGET_CPU}"
> -: "${qemu_cpu:=$DEFAULT_QEMU_CPU}"
> -: "${firmware:=$FIRMWARE}"
> -[ "$firmware" ] && firmware="-bios $firmware"
> -
> -set_qemu_accelerator || exit $?
> -[ "$ACCEL" = "kvm" ] && QEMU_ARCH=$HOST
> -acc="-accel $ACCEL$ACCEL_PROPS"
> -
> -qemu=$(search_qemu_binary) || exit $?
> -if [ "$mach" = 'virt' ] && ! $qemu -machine '?' | grep -q 'RISC-V VirtIO board'; then
> -	echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting."
> -	exit 2
> -fi
> -mach="-machine $mach"
> +vmm_check_supported
>  
> -command="$qemu -nodefaults -nographic -serial mon:stdio"
> -command+=" $mach $acc $firmware -cpu $qemu_cpu "
> -command="$(migration_cmd) $(timeout_cmd) $command"
> +function arch_run_qemu()
> +{
> +	# Allow user overrides of some config.mak variables
> +	mach=$MACHINE_OVERRIDE
> +	qemu_cpu=$TARGET_CPU_OVERRIDE
> +	firmware=$FIRMWARE_OVERRIDE
>  
> -if [ "$UEFI_SHELL_RUN" = "y" ]; then
> -	ENVIRON_DEFAULT=n run_test_status $command "$@"
> -else
> -	# We return the exit code via stdout, not via the QEMU return code
> -	run_test_status $command -kernel "$@"
> -fi
> +	: "${mach:=virt}"
> +	: "${qemu_cpu:=$TARGET_CPU}"
> +	: "${qemu_cpu:=$DEFAULT_QEMU_CPU}"
> +	: "${firmware:=$FIRMWARE}"
> +	[ "$firmware" ] && firmware="-bios $firmware"
> +
> +	set_qemu_accelerator || exit $?
> +	[ "$ACCEL" = "kvm" ] && QEMU_ARCH=$HOST
> +	acc="-accel $ACCEL$ACCEL_PROPS"
> +
> +	qemu=$(search_qemu_binary) || exit $?
> +	if [ "$mach" = 'virt' ] && ! $qemu -machine '?' | grep -q 'RISC-V VirtIO board'; then
> +		echo "$qemu doesn't support mach-virt ('-machine virt'). Exiting."
> +		exit 2
> +	fi
> +	mach="-machine $mach"
> +
> +	command="$qemu -nodefaults -nographic -serial mon:stdio"
> +	command+=" $mach $acc $firmware -cpu $qemu_cpu "
> +	command="$(migration_cmd) $(timeout_cmd) $command"
> +
> +	if [ "$UEFI_SHELL_RUN" = "y" ]; then
> +		ENVIRON_DEFAULT=n run_test_status $command "$@"
> +	else
> +		# We return the exit code via stdout, not via the QEMU return code
> +		run_test_status $command -kernel "$@"
> +	fi
> +}
> +
> +function arch_run_kvmtool()
> +{
> +	local command
> +
> +	kvmtool=$(search_kvmtool_binary) ||
> +		exit $?
> +
> +	if [ "$ACCEL" ] && [ "$ACCEL" != "kvm" ]; then
> +		echo "kvmtool does not support $ACCEL" >&2
> +		exit 2
> +	fi
> +
> +	if ! kvm_available; then
> +		echo "kvmtool requires KVM but not available on the host" >&2
> +		exit 2
> +	fi
> +
> +	command="$(timeout_cmd) $kvmtool run"
> +	if [ "$HOST" = "riscv64" ] && [ "$ARCH" = "riscv32" ]; then
> +		echo "Cannot run riscv32 on riscv64" >&2
> +		exit 2
> +	else
> +		run_test_status $command --kernel "$@"
> +	fi
> +}
> +
> +case $(vmm_get_target) in
> +qemu)
> +	arch_run_qemu "$@"
> +	;;
> +kvmtool)
> +	arch_run_kvmtool "$@"
> +	;;
> +esac

-- 
kvm-riscv mailing list
kvm-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kvm-riscv

  reply	other threads:[~2025-06-26 16:48 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25 15:48 [kvm-unit-tests PATCH v4 00/13] arm/arm64: Add kvmtool to the runner script Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 01/13] run_tests.sh: Document --probe-maxsmp argument Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 02/13] scripts: Document environment variables Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 03/13] scripts: Refuse to run the tests if not configured for qemu Alexandru Elisei
2025-06-26 15:25   ` Andrew Jones
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 04/13] scripts: Use an associative array for qemu argument names Alexandru Elisei
2025-06-26 15:29   ` Andrew Jones
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 05/13] scripts: Add 'kvmtool_params' to test definition Alexandru Elisei
2025-06-26 15:34   ` Andrew Jones
2025-06-26 16:41     ` Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 06/13] scripts: Add support for kvmtool Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 07/13] scripts: Add default arguments " Alexandru Elisei
2025-06-26 15:43   ` Andrew Jones
2025-07-11 11:32   ` Thomas Huth
2025-07-11 14:35     ` Andrew Jones
2025-07-11 14:37       ` Thomas Huth
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 08/13] scripts: Add KVMTOOL environment variable for kvmtool binary path Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 09/13] scripts: Detect kvmtool failure in premature_failure() Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 10/13] scripts: Do not probe for maximum number of VCPUs when using kvmtool Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 11/13] scripts/mkstandalone: Export $TARGET Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 12/13] scripts: Add 'disabled_if' test definition parameter for kvmtool to use Alexandru Elisei
2025-06-25 15:48 ` [kvm-unit-tests PATCH v4 13/13] scripts: Enable kvmtool Alexandru Elisei
2025-06-26 16:42 ` [kvm-unit-tests PATCH v4 00/13] arm/arm64: Add kvmtool to the runner script Andrew Jones
2025-06-26 16:48   ` Alexandru Elisei [this message]
2025-07-02 13:25 ` Andrew Jones
2025-07-04  8:41 ` Andrew Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aF15wzSHKxYZig3N@raptor \
    --to=alexandru.elisei@arm.com \
    --cc=andre.przywara@arm.com \
    --cc=andrew.jones@linux.dev \
    --cc=david@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=joey.gouly@arm.com \
    --cc=julien.thierry.kdev@gmail.com \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-s390@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lvivier@redhat.com \
    --cc=maz@kernel.org \
    --cc=nrb@linux.ibm.com \
    --cc=oliver.upton@linux.dev \
    --cc=pbonzini@redhat.com \
    --cc=shahuang@redhat.com \
    --cc=suzuki.poulose@arm.com \
    --cc=thuth@redhat.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).