Re: [kvm-unit-tests PATCH v2 5/5] run_tests: allow passing of options to QEMU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jan 17, 2017 at 03:54:24PM +0000, Alex Bennée wrote:
> This allows additional options to be passed to QEMU. It follows the
> convention of passing parameters after a -- to the child process. In
> my case I'm using it to toggle MTTCG on an off:
> 
>   ./run_tests.sh -- --accel tcg,thread=multi
> 
> Signed-off-by: Alex Bennée <alex.bennee@xxxxxxxxxx>
> 
> ---
> v1
>   - changes from -o to --
>   - fixed whitespace damage
> v2
>   - ensure extra opts have precendence over extra_params in config
> ---
>  README.md           |  6 ++++++
>  run_tests.sh        | 13 ++++++++++---
>  scripts/common.bash |  7 ++++---
>  3 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/README.md b/README.md
> index 153ae5e..99806f5 100644
> --- a/README.md
> +++ b/README.md
> @@ -60,6 +60,12 @@ To modify or disable the timeouts (see man timeout(1)):
>      TIMEOUT=$DURATION ./run_tests.sh
>      TIMEOUT=0 ./run_tests.sh
>  
> +Any arguments past the end-of-arguments marker (--) is passed on down
> +to the QEMU invocation. This can of course be combined with the other
> +modifiers:
> +
> +    ACCEL=tcg ./run_tests.sh -v -- --accel tcg,thread=multi

Just one '-' on accel. Also, why both 'ACCEL=tcg' and '-accel tcg'?
Does it not work otherwise for some reason?

> +
>  # Contributing
>  
>  ## Directory structure
> diff --git a/run_tests.sh b/run_tests.sh
> index 09cd057..a3f6f8f 100755
> --- a/run_tests.sh
> +++ b/run_tests.sh
> @@ -13,8 +13,7 @@ function usage()
>  {
>  cat <<EOF
>  
> -Usage: $0 [-g group] [-h] [-v]
> -Usage: $0 [-g group] [-h] [-v] [-j NUM-TASKS]
> +Usage: $0 [-g group] [-h] [-v] [-j NUM-TASKS] [-- QEMU options]
>  
>      -g: Only execute tests in the given group
>      -h: Output this help text
> @@ -24,6 +23,8 @@ Usage: $0 [-g group] [-h] [-v] [-j NUM-TASKS]
>  Set the environment variable QEMU=/path/to/qemu-system-ARCH to
>  specify the appropriate qemu binary for ARCH-run.
>  
> +All options specified after -- are passed on to QEMU.
> +
>  EOF
>  }
>  
> @@ -55,6 +56,12 @@ while getopts "g:hj:v" opt; do
>      esac
>  done
>  
> +# Any options left for QEMU?
> +shift $((OPTIND-1))
> +if [ "$#" -gt  0 ]; then
> +    extra_opts="$@"
> +fi

I'm not sure we need to address Paolo's concern with spaces in
options (maybe), but I'd prefer we avoid pointless conditions
like this one. The less bash lines we introduce the better...

As I said before, the equivalent is simply

 shift $((OPTIND-1))
 extra_opts="$@"

> +
>  # RUNTIME_log_file will be configured later
>  RUNTIME_log_stderr () { cat >> $RUNTIME_log_file; }
>  RUNTIME_log_stdout () {
> @@ -93,7 +100,7 @@ mkdir $unittest_log_dir || exit 2
>  echo "BUILD_HEAD=$(cat build-head)" > $unittest_log_dir/SUMMARY
>  
>  trap "wait; exit 130" SIGINT
> -for_each_unittest $config run_task
> +for_each_unittest $config run_task "$extra_opts"
>  
>  # wait until all tasks finish
>  wait
> diff --git a/scripts/common.bash b/scripts/common.bash
> index ee9143c..ab33ef1 100644
> --- a/scripts/common.bash
> +++ b/scripts/common.bash
> @@ -3,10 +3,11 @@ function for_each_unittest()
>  {
>  	local unittests="$1"
>  	local cmd="$2"
> +	local extra_opts=$3
>  	local testname
>  	local smp
>  	local kernel
> -	local opts
> +	local opts=$extra_opts
>  	local groups
>  	local arch
>  	local check
> @@ -21,7 +22,7 @@ function for_each_unittest()
>  			testname=${BASH_REMATCH[1]}
>  			smp=1
>  			kernel=""
> -			opts=""
> +			opts=$extra_opts
>  			groups=""
>  			arch=""
>  			check=""
> @@ -32,7 +33,7 @@ function for_each_unittest()
>  		elif [[ $line =~ ^smp\ *=\ *(.*)$ ]]; then
>  			smp=${BASH_REMATCH[1]}
>  		elif [[ $line =~ ^extra_params\ *=\ *(.*)$ ]]; then
> -			opts=${BASH_REMATCH[1]}
> +			opts="${BASH_REMATCH[1]} $opts"
>  		elif [[ $line =~ ^groups\ *=\ *(.*)$ ]]; then
>  			groups=${BASH_REMATCH[1]}
>  		elif [[ $line =~ ^arch\ *=\ *(.*)$ ]]; then
> -- 
> 2.11.0
>

drew 
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux