diff mbox series

[kvm-unit-tests,1/2] arch-run: Allow $QEMU to include parameters

Message ID 20200213143300.32141-2-drjones@redhat.com (mailing list archive)
State New, archived
Headers show
Series runtime: Allow additional VMM parameters to be provided | expand

Commit Message

Andrew Jones Feb. 13, 2020, 2:32 p.m. UTC
Now it's possible to run all tests using run_tests.sh with a
QEMU specified by the $QEMU environment variable that also
includes additional parameters. E.g. QEMU="/path/to/qemu -icount 8"

Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Alex Bennée <alex.bennee@linaro.org>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Thomas Huth <thuth@redhat.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Janosch Frank <frankja@linux.ibm.com>
Signed-off-by: Andrew Jones <drjones@redhat.com>
---
 scripts/arch-run.bash | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

Comments

Paolo Bonzini Feb. 14, 2020, 10:31 a.m. UTC | #1
On 13/02/20 15:32, Andrew Jones wrote:
> +	if [ -n "$QEMU" ]; then
> +		set -- $QEMU
> +		if ! "$1" --help 2>/dev/null | grep -q 'QEMU'; then
> +			echo "\$QEMU environment variable not set to a QEMU binary." >&2
> +			return 2
> +		fi
> +		qemu=$(command -v "$1")
> +		shift
> +		echo "$qemu $@"

I think $* is more appropriate here.  Something like "foo $@ bar" has a
weird effect:

	$ set -x
	$ set a b c

	$ echo "foo $@ bar"
	+ echo 'foo a' b 'c bar'
	foo a b c bar

	$ echo "foo $* bar"
	+ echo 'foo a b c bar'
	foo a b c bar

Otherwise, this is a good idea.

Thanks,

Paolo

> +		return
> +	fi
> +
Andrew Jones Feb. 14, 2020, 10:51 a.m. UTC | #2
On Fri, Feb 14, 2020 at 11:31:04AM +0100, Paolo Bonzini wrote:
> On 13/02/20 15:32, Andrew Jones wrote:
> > +	if [ -n "$QEMU" ]; then
> > +		set -- $QEMU
> > +		if ! "$1" --help 2>/dev/null | grep -q 'QEMU'; then
> > +			echo "\$QEMU environment variable not set to a QEMU binary." >&2
> > +			return 2
> > +		fi
> > +		qemu=$(command -v "$1")
> > +		shift
> > +		echo "$qemu $@"
> 
> I think $* is more appropriate here.  Something like "foo $@ bar" has a
> weird effect:

Will fix for v2.

> 
> 	$ set -x
> 	$ set a b c
> 
> 	$ echo "foo $@ bar"
> 	+ echo 'foo a' b 'c bar'
> 	foo a b c bar
> 
> 	$ echo "foo $* bar"
> 	+ echo 'foo a b c bar'
> 	foo a b c bar
> 
> Otherwise, this is a good idea.

Thanks,
drew

> 
> Thanks,
> 
> Paolo
> 
> > +		return
> > +	fi
> > +
>
diff mbox series

Patch

diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index d3ca19d49952..ebe4d3cb2a09 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -172,8 +172,20 @@  search_qemu_binary ()
 	local save_path=$PATH
 	local qemucmd qemu
 
+	if [ -n "$QEMU" ]; then
+		set -- $QEMU
+		if ! "$1" --help 2>/dev/null | grep -q 'QEMU'; then
+			echo "\$QEMU environment variable not set to a QEMU binary." >&2
+			return 2
+		fi
+		qemu=$(command -v "$1")
+		shift
+		echo "$qemu $@"
+		return
+	fi
+
 	export PATH=$PATH:/usr/libexec
-	for qemucmd in ${QEMU:-qemu-system-$ARCH_NAME qemu-kvm}; do
+	for qemucmd in qemu-system-$ARCH_NAME qemu-kvm; do
 		if $qemucmd --help 2>/dev/null | grep -q 'QEMU'; then
 			qemu="$qemucmd"
 			break