All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Radim Krčmář" <rkrcmar@redhat.com>
To: kvm@vger.kernel.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Drew Jones <drjones@redhat.com>,
	Laurent Vivier <lvivier@redhat.com>,
	Thomas Huth <thuth@redhat.com>,
	David Hildenbrand <david@redhat.com>
Subject: [kvm-unit-tests PATCH 1/5] arch/run: simplify copy-paste of the command line
Date: Wed, 28 Jun 2017 22:08:53 +0200	[thread overview]
Message-ID: <20170628200857.1718-2-rkrcmar@redhat.com> (raw)
In-Reply-To: <20170628200857.1718-1-rkrcmar@redhat.com>

The major annoyance coming from errata was "-initrd `mktemp`" that had
to be removed before running the copy-pasted command line.
Move "-initrd ..." part at the end of the line and hide it behind "#" if
the initird file is a temporary one.

This patch also brings s390 to use the same code as other architectures
and eliminates code duplication.

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
Adding the arch/run command line might also be worth it
(i.e. adding echo $0 $@ to arch/run).
---
 arm/run               |  5 +----
 powerpc/run           |  5 +----
 s390x/run             |  2 --
 scripts/arch-run.bash | 18 ++++++++++++++++--
 x86/run               |  5 +----
 5 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/arm/run b/arm/run
index 1b1602c74970..8d8918a461dc 100755
--- a/arm/run
+++ b/arm/run
@@ -71,12 +71,9 @@ if $qemu $M -device '?' 2>&1 | grep pci-testdev > /dev/null; then
 	pci_testdev="-device pci-testdev"
 fi
 
-initrd_create
-
 M+=",accel=$ACCEL"
 command="$qemu -nodefaults $M -cpu $processor $chr_testdev $pci_testdev"
-command+=" -display none -serial stdio $INITRD -kernel"
+command+=" -display none -serial stdio -kernel"
 command="$(timeout_cmd) $command"
-echo $command "$@"
 
 run_qemu $command "$@"
diff --git a/powerpc/run b/powerpc/run
index 7ccf1a36ff49..3fd5a91aeffb 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -35,14 +35,11 @@ if ! $qemu -machine '?' 2>&1 | grep 'pseries' > /dev/null; then
 	exit 2
 fi
 
-initrd_create
-
 M='-machine pseries'
 M+=",accel=$ACCEL"
 command="$qemu -nodefaults $M -bios $FIRMWARE"
-command+=" -display none -serial stdio $INITRD -kernel"
+command+=" -display none -serial stdio -kernel"
 command="$(migration_cmd) $(timeout_cmd) $command"
-echo $command "$@"
 
 # powerpc tests currently exit with rtas-poweroff, which exits with 0.
 # run_qemu treats that as a failure exit and returns 1, so we need
diff --git a/s390x/run b/s390x/run
index cf333de9ccce..89210f4fb6b6 100755
--- a/s390x/run
+++ b/s390x/run
@@ -34,10 +34,8 @@ M='-machine s390-ccw-virtio'
 M+=",accel=$ACCEL"
 command="$qemu -nodefaults -nographic $M"
 command+=" -chardev stdio,id=con0 -device sclpconsole,chardev=con0"
-[ -f "$ENV" ] && command+=" -initrd $ENV"
 command+=" -kernel"
 command="$(timeout_cmd) $command"
-echo $command "$@"
 
 # We return the exit code via stdout, not via the QEMU return code
 lines=$(run_qemu $command "$@")
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 7c6c79ad3a9d..8ad37e4ebf97 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -28,9 +28,14 @@ run_qemu ()
 {
 	local stdout errors ret sig
 
+	echo -n $@
+	initrd_create &&
+		echo -n " #"
+	echo " $INITRD"
+
 	# stdout to {stdout}, stderr to $errors and stderr
 	exec {stdout}>&1
-	errors=$("${@}" </dev/null 2> >(tee /dev/stderr) > /dev/fd/$stdout)
+	errors=$("${@}" $INITRD </dev/null 2> >(tee /dev/stderr) > /dev/fd/$stdout)
 	ret=$?
 	exec {stdout}>&-
 
@@ -158,14 +163,20 @@ search_qemu_binary ()
 
 initrd_create ()
 {
+	local ret
+
 	env_add_errata
+	ret=$?
+
 	unset INITRD
 	[ -f "$ENV" ] && INITRD="-initrd $ENV"
+
+	return $ret
 }
 
 env_add_errata ()
 {
-	local line errata
+	local line errata ret=1
 
 	if [ -f "$ENV" ] && grep -q '^ERRATA_' <(env); then
 		for line in $(grep '^ERRATA_' "$ENV"); do
@@ -183,7 +194,10 @@ env_add_errata ()
 		trap_exit_push 'rm -f $ENV; [ "$ENV_OLD" ] && export ENV="$ENV_OLD" || unset ENV; unset ENV_OLD'
 		[ -f "$ENV_OLD" ] && grep -v '^ERRATA_' "$ENV_OLD" > $ENV
 		grep '^ERRATA_' <(env) >> $ENV
+		ret=0
 	fi
+
+	return $ret
 }
 
 env_generate_errata ()
diff --git a/x86/run b/x86/run
index 88f5ff771140..a06a7c0f80c8 100755
--- a/x86/run
+++ b/x86/run
@@ -33,11 +33,8 @@ else
 	pc_testdev="-device testdev,chardev=testlog -chardev file,id=testlog,path=msr.out"
 fi
 
-initrd_create
-
 command="${qemu} -nodefaults -enable-kvm $pc_testdev -vnc none -serial stdio $pci_testdev $hyperv_testdev"
-command+=" $INITRD -kernel"
+command+=" -kernel"
 command="$(timeout_cmd) $command"
-echo ${command} "$@"
 
 run_qemu ${command} "$@"
-- 
2.13.2

  reply	other threads:[~2017-06-28 20:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-28 20:08 [kvm-unit-tests PATCH 0/5] Minor fixes while getting rid of code duplication Radim Krčmář
2017-06-28 20:08 ` Radim Krčmář [this message]
2017-06-28 20:08 ` [kvm-unit-tests PATCH 2/5] run_tests: add summary to powerpc and s390 Radim Krčmář
2017-06-29  5:30   ` Thomas Huth
2017-06-29 12:53     ` Radim Krčmář
2017-06-28 20:08 ` [kvm-unit-tests PATCH 3/5] s390+powerpc/run: improve output handling Radim Krčmář
2017-06-28 20:08 ` [kvm-unit-tests PATCH 4/5] scripts/arch-run: fix qemu binary search failure path Radim Krčmář
2017-06-28 20:46   ` Paolo Bonzini
2017-06-29 12:32     ` Radim Krčmář
2017-06-28 20:08 ` [kvm-unit-tests PATCH 5/5] arch/run: unify accelerator detection Radim Krčmář
2017-06-28 20:48   ` Paolo Bonzini
2017-06-29 12:45     ` Radim Krčmář
2017-06-29 13:46       ` Radim Krčmář
2017-06-29 13:49         ` Paolo Bonzini
2017-06-29 14:28   ` [kvm-unit-tests PATCH v2 " Radim Krčmář
2017-06-29 14:32   ` [kvm-unit-tests PATCH v2 6/5] x86/run: support accelerator controls Radim Krčmář
2017-06-30 10:42     ` Paolo Bonzini
2017-06-29 11:41 ` [kvm-unit-tests PATCH 0/5] Minor fixes while getting rid of code duplication 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=20170628200857.1718-2-rkrcmar@redhat.com \
    --to=rkrcmar@redhat.com \
    --cc=david@redhat.com \
    --cc=drjones@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.