[kvm-unit-tests PATCH v2 06/18] scripts: Merge the qemu parameter -smp into $qemu_opts
Andrew Jones
andrew.jones at linux.dev
Tue Jan 21 08:12:47 PST 2025
On Mon, Jan 20, 2025 at 04:43:04PM +0000, Alexandru Elisei wrote:
> kvmtool has a different command line parameter to specify the number of
> VCPUs (-c/--cpus). To make it easier to accommodate it, merge the qemu
> specific parameter -smp into $qemu_opts when passing it to the
> $RUNTIME_arch_run script.
>
> This is safe to do because the $RUNTIME_arch_run script, on all
> architectures, passes the parameters right back to run_qemu() et co, and
> do not treat individual parameters separately.
>
> Signed-off-by: Alexandru Elisei <alexandru.elisei at arm.com>
> ---
> scripts/runtime.bash | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/runtime.bash b/scripts/runtime.bash
> index e5d661684ceb..a89f2d10ab78 100644
> --- a/scripts/runtime.bash
> +++ b/scripts/runtime.bash
> @@ -34,7 +34,8 @@ premature_failure()
> get_cmdline()
> {
> local kernel=$1
> - echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel -smp $smp $qemu_opts"
> +
> + echo "TESTNAME=$testname TIMEOUT=$timeout MACHINE=$machine ACCEL=$accel $RUNTIME_arch_run $kernel $qemu_opts"
> }
>
> skip_nodefault()
> @@ -87,6 +88,8 @@ function run()
> local accel="$9"
> local timeout="${10:-$TIMEOUT}" # unittests.cfg overrides the default
>
> + qemu_opts="-smp $smp $qemu_opts"
> +
> if [ "${CONFIG_EFI}" == "y" ]; then
> kernel=${kernel/%.flat/.efi}
> fi
> --
> 2.47.1
>
This seems fine, but I still think we want qemu_opts to be opts and we can
parameterize the option names. So we could have a table of option names
that we use in places like this
declare -A vmm_opts
vmm_opts[qemu,nr_cpus]='-smp'
vmm_opts[qemu,another_option]='foo'
vmm_opts[kvmtool,nr_cpus]='-c'
vmm_opts[kvmtool,another_option]='bar'
# $vmm gets set to whatever vmm we're using, e.g. vmm=qemu
opts="${vmm_opts[$vmm,nr_cpus]} $smp $opts"
Thanks,
drew
More information about the kvm-riscv
mailing list