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 5/5] arch/run: unify accelerator detection
Date: Wed, 28 Jun 2017 22:08:57 +0200 [thread overview]
Message-ID: <20170628200857.1718-6-rkrcmar@redhat.com> (raw)
In-Reply-To: <20170628200857.1718-1-rkrcmar@redhat.com>
Use the same mechanism as search_qemu_binary().
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
arm/run | 20 +-------------------
powerpc/run | 18 +-----------------
s390x/run | 18 +-----------------
scripts/arch-run.bash | 22 ++++++++++++++++++++++
4 files changed, 25 insertions(+), 53 deletions(-)
diff --git a/arm/run b/arm/run
index d7d778fe1645..f2e71eca022d 100755
--- a/arm/run
+++ b/arm/run
@@ -10,26 +10,8 @@ if [ -z "$STANDALONE" ]; then
fi
processor="$PROCESSOR"
-if [ -c /dev/kvm ]; then
- if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then
- kvm_available=yes
- elif [ "$HOST" = "aarch64" ]; then
- kvm_available=yes
- fi
-fi
-
-if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
- echo "KVM is needed, but not available on this host"
+ACCEL=$(get_accel '([ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]) || [ "$HOST" = "aarch64" ]') ||
exit 2
-fi
-
-if [ -z "$ACCEL" ]; then
- if [ "$kvm_available" = "yes" ]; then
- ACCEL="kvm"
- else
- ACCEL="tcg"
- fi
-fi
qemu=$(search_qemu_binary) ||
exit 2
diff --git a/powerpc/run b/powerpc/run
index e43c9fd8063c..55b987c5efc5 100755
--- a/powerpc/run
+++ b/powerpc/run
@@ -9,24 +9,8 @@ if [ -z "$STANDALONE" ]; then
source scripts/arch-run.bash
fi
-if [ -c /dev/kvm ]; then
- if [ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]; then
- kvm_available=yes
- fi
-fi
-
-if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
- echo "KVM is needed, but not available on this host"
+ACCEL=$(get_accel '[ "$HOST" = "ppc64" ] && [ "$ARCH" = "ppc64" ]') ||
exit 2
-fi
-
-if [ -z "$ACCEL" ]; then
- if [ "$kvm_available" = "yes" ]; then
- ACCEL="kvm"
- else
- ACCEL="tcg"
- fi
-fi
qemu=$(search_qemu_binary) ||
exit 2
diff --git a/s390x/run b/s390x/run
index ce8d45c2c8fd..67d6e88ea7e4 100755
--- a/s390x/run
+++ b/s390x/run
@@ -9,24 +9,8 @@ if [ -z "$STANDALONE" ]; then
source scripts/arch-run.bash
fi
-if [ -c /dev/kvm ]; then
- if [ "$HOST" = "s390x" ] && [ "$ARCH" = "s390x" ]; then
- kvm_available=yes
- fi
-fi
-
-if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
- echo "KVM is needed, but not available on this host"
+ACCEL=$(get_accel '[ "$HOST" = "s390x" ] && [ "$ARCH" = "s390x" ]') ||
exit 2
-fi
-
-if [ -z "$ACCEL" ]; then
- if [ "$kvm_available" = "yes" ]; then
- ACCEL="kvm"
- else
- ACCEL="tcg"
- fi
-fi
qemu=$(search_qemu_binary) ||
exit 2
diff --git a/scripts/arch-run.bash b/scripts/arch-run.bash
index 994c1aa9c0cd..a696652c61b1 100644
--- a/scripts/arch-run.bash
+++ b/scripts/arch-run.bash
@@ -272,3 +272,25 @@ trap_exit_push ()
local old_exit=$(trap -p EXIT | sed "s/^[^']*'//;s/'[^']*$//")
trap -- "$1; $old_exit" EXIT
}
+
+get_accel ()
+{
+ local kvm_available
+
+ if [ -c /dev/kvm ] && eval "$@"; then
+ kvm_available=yes
+ fi
+
+ if [ "$ACCEL" = "kvm" ] && [ "$kvm_available" != "yes" ]; then
+ echo "KVM is needed, but not available on this host" >&2
+ return 2
+ fi
+
+ if [ "$ACCEL" ]; then
+ echo $ACCEL
+ elif [ "$kvm_available" = "yes" ]; then
+ echo kvm
+ else
+ echo tcg
+ fi
+}
--
2.13.2
next prev parent 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 ` [kvm-unit-tests PATCH 1/5] arch/run: simplify copy-paste of the command line Radim Krčmář
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 ` Radim Krčmář [this message]
2017-06-28 20:48 ` [kvm-unit-tests PATCH 5/5] arch/run: unify accelerator detection 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-6-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.