From: Andrew Jones <andrew.jones@linux.dev>
To: Alexandru Elisei <alexandru.elisei@arm.com>
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 04/13] scripts: Use an associative array for qemu argument names
Date: Thu, 26 Jun 2025 17:29:21 +0200 [thread overview]
Message-ID: <20250626-5cba2905b81b7a5b3a016bfa@orel> (raw)
In-Reply-To: <20250625154813.27254-5-alexandru.elisei@arm.com>
On Wed, Jun 25, 2025 at 04:48:04PM +0100, Alexandru Elisei wrote:
> Move away from hardcoded qemu arguments and use instead an associative
> array to get the needed arguments. This paves the way for adding kvmtool
> support to the scripts, which has a different syntax for the same VM
> configuration parameters.
>
> Suggested-by: Andrew Jones <andrew.jones@linux.dev>
> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
> ---
>
> Changes v3->v4:
>
> * Renamed vmm_opts to vmm_optname.
> * Dropped entries for 'kernel' and 'initrd' in vmm_optname because they weren't
> used in this patch.
> * Use vmm_optname_nr_cpus() and vmm_optname_args() instead of directly indexing
> into vmm_optname.
> * Dropped the check for empty $test_args in scripts/runtime.bash::run() by
> having $test_args already contain --append if not empty in
> scripts/common.bash::for_each_unittest().
>
> scripts/common.bash | 11 ++++++++---
> scripts/runtime.bash | 7 +------
> scripts/vmm.bash | 15 +++++++++++++++
> 3 files changed, 24 insertions(+), 9 deletions(-)
>
> diff --git a/scripts/common.bash b/scripts/common.bash
> index 9deb87d4050d..ae127bd4e208 100644
> --- a/scripts/common.bash
> +++ b/scripts/common.bash
> @@ -1,4 +1,5 @@
> source config.mak
> +source scripts/vmm.bash
>
> function for_each_unittest()
> {
> @@ -26,8 +27,12 @@ function for_each_unittest()
> $(arch_cmd) "$cmd" "$testname" "$groups" "$smp" "$kernel" "$test_args" "$opts" "$arch" "$machine" "$check" "$accel" "$timeout"
> fi
> testname=$rematch
> - smp=1
> + smp="$(vmm_optname_nr_cpus) 1"
> kernel=""
> + # Intentionally don't use -append if test_args is empty
> + # because qemu interprets the first word after
> + # -append as a kernel parameter instead of a command
> + # line option.
> test_args=""
> opts=""
> groups=""
> @@ -39,9 +44,9 @@ function for_each_unittest()
> elif [[ $line =~ ^file\ *=\ *(.*)$ ]]; then
> kernel=$TEST_DIR/${BASH_REMATCH[1]}
> elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
> - smp=${BASH_REMATCH[1]}
> + smp="$(vmm_optname_nr_cpus) ${BASH_REMATCH[1]}"
> elif [[ $line =~ ^test_args\ *=\ *(.*)$ ]]; then
> - test_args=${BASH_REMATCH[1]}
> + test_args="$(vmm_optname_args) ${BASH_REMATCH[1]}"
> elif [[ $line =~ ^(extra_params|qemu_params)\ *=\ *'"""'(.*)$ ]]; then
> opts=${BASH_REMATCH[2]}$'\n'
> while read -r -u $fd; do
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index bc17b89f4ff5..86d8a2cd8528 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -34,7 +34,7 @@ premature_failure()
> get_cmdline()
> {
> local kernel=$1
> - echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $opts"
> + echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel $smp $test_args $opts"
> }
>
> skip_nodefault()
> @@ -88,11 +88,6 @@ function run()
> local accel="${10}"
> local timeout="${11:-$TIMEOUT}" # unittests.cfg overrides the default
>
> - # If $test_args is empty, qemu will interpret the first option after -append
> - # as a test argument instead of a qemu option, so make sure that doesn't
> - # happen.
> - [ -n "$test_args" ] && opts="-append $test_args $opts"
> -
> if [ "${CONFIG_EFI}" == "y" ]; then
> kernel=${kernel/%.flat/.efi}
> fi
> diff --git a/scripts/vmm.bash b/scripts/vmm.bash
> index 8365c1424a3f..7629b2b9146e 100644
> --- a/scripts/vmm.bash
> +++ b/scripts/vmm.bash
> @@ -1,3 +1,18 @@
> +declare -A vmm_optname=(
> + [qemu,args]='-append'
> + [qemu,nr_cpus]='-smp'
> +)
> +
> +function vmm_optname_args()
> +{
> + echo ${vmm_optname[$(vmm_get_target),args]}
> +}
> +
> +function vmm_optname_nr_cpus()
> +{
> + echo ${vmm_optname[$(vmm_get_target),nr_cpus]}
> +}
> +
> function vmm_get_target()
> {
> if [[ -z "$TARGET" ]]; then
> --
> 2.50.0
>
Reviewed-by: Andrew Jones <andrew.jones@linux.dev>
next prev parent reply other threads:[~2025-06-26 15:29 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 [this message]
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
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=20250626-5cba2905b81b7a5b3a016bfa@orel \
--to=andrew.jones@linux.dev \
--cc=alexandru.elisei@arm.com \
--cc=andre.przywara@arm.com \
--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