public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [kvm-unit-tests PATCH v2 0/4] A couple of small fixes
@ 2015-07-07  7:03 Alex Bennée
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 1/4] README: add some CONTRIBUTING notes Alex Bennée
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Alex Bennée @ 2015-07-07  7:03 UTC (permalink / raw)
  To: kvm; +Cc: drjones, Alex Bennée

I dropped the option parsing stuff which can be achieved by just
appending QEMU args to the end of the command line. I've also
addressed comments as suggested.

Alex Bennée (4):
  README: add some CONTRIBUTING notes
  configure: emit HOST=$host to config.mak
  arm/run: introduce usingkvm var and use it
  arm/run: clean-up setting of accel options

 README    | 26 ++++++++++++++++++++++++++
 arm/run   | 19 +++++++++++++++++--
 configure |  2 ++
 3 files changed, 45 insertions(+), 2 deletions(-)

-- 
2.4.5


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [kvm-unit-tests PATCH v2 1/4] README: add some CONTRIBUTING notes
  2015-07-07  7:03 [kvm-unit-tests PATCH v2 0/4] A couple of small fixes Alex Bennée
@ 2015-07-07  7:03 ` Alex Bennée
  2015-07-07 11:43   ` Andrew Jones
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 2/4] configure: emit HOST=$host to config.mak Alex Bennée
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Bennée @ 2015-07-07  7:03 UTC (permalink / raw)
  To: kvm; +Cc: drjones, Alex Bennée

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
v2
  - mention consistency
---
 README | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/README b/README
index e9869d1..9389a26 100644
--- a/README
+++ b/README
@@ -25,3 +25,29 @@ Directory structure:
 ./<ARCH>:	the sources of the tests and the created objects/images
 
 See <ARCH>/README for architecture specific documentation.
+
+CONTRIBUTING:
+=============
+
+Style
+-----
+
+Currently there is a mix of indentation styles so any changes to
+existing files should be consistent with the existing style. For new
+files:
+
+  - C: please use standard linux-with-tabs
+  - Shell: use TABs for indentation
+
+Patches
+-------
+
+Patches are welcome at the KVM mailing list <kvm@vger.kernel.org>.
+
+Please prefix messages with: [kvm-unit-tests PATCH]
+
+You can add the following to .git/config to do this automatically for you:
+
+[format]
+	subjectprefix = kvm-unit-tests PATCH
+
-- 
2.4.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [kvm-unit-tests PATCH v2 2/4] configure: emit HOST=$host to config.mak
  2015-07-07  7:03 [kvm-unit-tests PATCH v2 0/4] A couple of small fixes Alex Bennée
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 1/4] README: add some CONTRIBUTING notes Alex Bennée
@ 2015-07-07  7:03 ` Alex Bennée
  2015-07-07 11:43   ` Andrew Jones
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 3/4] arm/run: introduce usingkvm var and use it Alex Bennée
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 4/4] arm/run: clean-up setting of accel options Alex Bennée
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Bennée @ 2015-07-07  7:03 UTC (permalink / raw)
  To: kvm; +Cc: drjones, Alex Bennée

This is useful information for the run scripts to know, especially if
they want to drop to using TCG.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 configure | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/configure b/configure
index b2ad32a..078b70c 100755
--- a/configure
+++ b/configure
@@ -7,6 +7,7 @@ ld=ld
 objcopy=objcopy
 ar=ar
 arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'`
+host=$arch
 cross_prefix=
 
 usage() {
@@ -122,6 +123,7 @@ ln -s $asm lib/asm
 cat <<EOF > config.mak
 PREFIX=$prefix
 KERNELDIR=$(readlink -f $kerneldir)
+HOST=$host
 ARCH=$arch
 ARCH_NAME=$arch_name
 PROCESSOR=$processor
-- 
2.4.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [kvm-unit-tests PATCH v2 3/4] arm/run: introduce usingkvm var and use it
  2015-07-07  7:03 [kvm-unit-tests PATCH v2 0/4] A couple of small fixes Alex Bennée
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 1/4] README: add some CONTRIBUTING notes Alex Bennée
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 2/4] configure: emit HOST=$host to config.mak Alex Bennée
@ 2015-07-07  7:03 ` Alex Bennée
  2015-07-07 11:36   ` Andrew Jones
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 4/4] arm/run: clean-up setting of accel options Alex Bennée
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Bennée @ 2015-07-07  7:03 UTC (permalink / raw)
  To: kvm; +Cc: drjones, Alex Bennée

This makes the script a little cleaner by only checking for KVM support
in one place.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
 arm/run | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/arm/run b/arm/run
index 6b42a2e..493ce0d 100755
--- a/arm/run
+++ b/arm/run
@@ -8,6 +8,16 @@ fi
 source config.mak
 processor="$PROCESSOR"
 
+# Default to using KVM if available and on the right ARM host
+usingkvm=0
+if [ -c /dev/kvm ]; then
+	if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then
+		usingkvm=1
+	elif [ "$HOST" = "aarch64" ]; then
+		usingkvm=1
+	fi
+fi
+
 qemu="${QEMU:-qemu-system-$ARCH_NAME}"
 qpath=$(which $qemu 2>/dev/null)
 
@@ -39,7 +49,7 @@ chr_testdev='-device virtio-serial-device'
 chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
 
 # arm64 must use '-cpu host' with kvm
-if [ "$(arch)" = "aarch64" ] && [ "$ARCH" = "arm64" ] && [ -c /dev/kvm ]; then
+if [ $usingkvm = 1 ] && [ "$ARCH" = "arm64" ]; then
 	processor="host"
 fi
 
-- 
2.4.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [kvm-unit-tests PATCH v2 4/4] arm/run: clean-up setting of accel options
  2015-07-07  7:03 [kvm-unit-tests PATCH v2 0/4] A couple of small fixes Alex Bennée
                   ` (2 preceding siblings ...)
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 3/4] arm/run: introduce usingkvm var and use it Alex Bennée
@ 2015-07-07  7:03 ` Alex Bennée
  2015-07-07 11:40   ` Andrew Jones
  3 siblings, 1 reply; 9+ messages in thread
From: Alex Bennée @ 2015-07-07  7:03 UTC (permalink / raw)
  To: kvm; +Cc: drjones, Alex Bennée

It would be nice to use --no-kvm but that flags a warning on pure-TCG
builds. We echo the fact we are using TCG for the benefit of interactive
use.

Signed-off-by: Alex Bennée <alex.bennee@linaro.org>

---
v2
  - rm redundant M= statement
---
 arm/run | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arm/run b/arm/run
index 493ce0d..7266004 100755
--- a/arm/run
+++ b/arm/run
@@ -32,6 +32,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then
 fi
 
 M='-machine virt'
+if [ $usingkvm = 1 ]; then
+	M+=",accel=kvm"
+else
+	echo "Running with TCG"
+	M+=',accel=tcg'
+fi
 
 if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then
 	echo "$qpath doesn't support virtio-console for chr-testdev. Exiting."
@@ -44,7 +50,6 @@ if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \
 	exit 2
 fi
 
-M='-machine virt,accel=kvm:tcg'
 chr_testdev='-device virtio-serial-device'
 chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
 
-- 
2.4.5


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [kvm-unit-tests PATCH v2 3/4] arm/run: introduce usingkvm var and use it
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 3/4] arm/run: introduce usingkvm var and use it Alex Bennée
@ 2015-07-07 11:36   ` Andrew Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Jones @ 2015-07-07 11:36 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm

On Tue, Jul 07, 2015 at 08:03:32AM +0100, Alex Bennée wrote:
> This makes the script a little cleaner by only checking for KVM support
> in one place.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  arm/run | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/arm/run b/arm/run
> index 6b42a2e..493ce0d 100755
> --- a/arm/run
> +++ b/arm/run
> @@ -8,6 +8,16 @@ fi
>  source config.mak
>  processor="$PROCESSOR"
>  
> +# Default to using KVM if available and on the right ARM host
> +usingkvm=0

I actually prefer

usingkvm=no # or to just not declare it at all, or to do just usingkvm=

if [ should-use-kvm ]; then
	usingkvm=yes
fi

if [ "$usingkvm" = "yes" ]; then
...
fi

The reason is because '=' is a string comparison operator, so
you're using the string "0" and the string "1", but without
quotes. To use integers 0 and 1, the operator '-eq' is necessary.

Sorry, I should have mentioned that yesterday.

Thanks,
drew

> +if [ -c /dev/kvm ]; then
> +	if [ "$HOST" = "arm" ] && [ "$ARCH" = "arm" ]; then
> +		usingkvm=1
> +	elif [ "$HOST" = "aarch64" ]; then
> +		usingkvm=1
> +	fi
> +fi
> +
>  qemu="${QEMU:-qemu-system-$ARCH_NAME}"
>  qpath=$(which $qemu 2>/dev/null)
>  
> @@ -39,7 +49,7 @@ chr_testdev='-device virtio-serial-device'
>  chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
>  
>  # arm64 must use '-cpu host' with kvm
> -if [ "$(arch)" = "aarch64" ] && [ "$ARCH" = "arm64" ] && [ -c /dev/kvm ]; then
> +if [ $usingkvm = 1 ] && [ "$ARCH" = "arm64" ]; then
>  	processor="host"
>  fi
>  
> -- 
> 2.4.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [kvm-unit-tests PATCH v2 4/4] arm/run: clean-up setting of accel options
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 4/4] arm/run: clean-up setting of accel options Alex Bennée
@ 2015-07-07 11:40   ` Andrew Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Jones @ 2015-07-07 11:40 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm

On Tue, Jul 07, 2015 at 08:03:33AM +0100, Alex Bennée wrote:
> It would be nice to use --no-kvm but that flags a warning on pure-TCG
> builds. We echo the fact we are using TCG for the benefit of interactive
> use.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> 
> ---
> v2
>   - rm redundant M= statement
> ---
>  arm/run | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arm/run b/arm/run
> index 493ce0d..7266004 100755
> --- a/arm/run
> +++ b/arm/run
> @@ -32,6 +32,12 @@ if ! $qemu -machine '?' 2>&1 | grep 'ARM Virtual Machine' > /dev/null; then
>  fi
>  
>  M='-machine virt'
> +if [ $usingkvm = 1 ]; then

The "1" string here again

> +	M+=",accel=kvm"
> +else
> +	echo "Running with TCG"
> +	M+=',accel=tcg'
> +fi
>  
>  if ! $qemu $M -device '?' 2>&1 | grep virtconsole > /dev/null; then
>  	echo "$qpath doesn't support virtio-console for chr-testdev. Exiting."
> @@ -44,7 +50,6 @@ if $qemu $M -chardev testdev,id=id -initrd . 2>&1 \
>  	exit 2
>  fi
>  
> -M='-machine virt,accel=kvm:tcg'
>  chr_testdev='-device virtio-serial-device'
>  chr_testdev+=' -device virtconsole,chardev=ctd -chardev testdev,id=ctd'
>  
> -- 
> 2.4.5
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [kvm-unit-tests PATCH v2 1/4] README: add some CONTRIBUTING notes
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 1/4] README: add some CONTRIBUTING notes Alex Bennée
@ 2015-07-07 11:43   ` Andrew Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Jones @ 2015-07-07 11:43 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm

On Tue, Jul 07, 2015 at 08:03:30AM +0100, Alex Bennée wrote:
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> 
> ---
> v2
>   - mention consistency
> ---
>  README | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
> 
> diff --git a/README b/README
> index e9869d1..9389a26 100644
> --- a/README
> +++ b/README
> @@ -25,3 +25,29 @@ Directory structure:
>  ./<ARCH>:	the sources of the tests and the created objects/images
>  
>  See <ARCH>/README for architecture specific documentation.
> +
> +CONTRIBUTING:
> +=============
> +
> +Style
> +-----
> +
> +Currently there is a mix of indentation styles so any changes to
> +existing files should be consistent with the existing style. For new
> +files:
> +
> +  - C: please use standard linux-with-tabs
> +  - Shell: use TABs for indentation
> +
> +Patches
> +-------
> +
> +Patches are welcome at the KVM mailing list <kvm@vger.kernel.org>.
> +
> +Please prefix messages with: [kvm-unit-tests PATCH]
> +
> +You can add the following to .git/config to do this automatically for you:
> +
> +[format]
> +	subjectprefix = kvm-unit-tests PATCH
> +
> -- 
> 2.4.5

Reviewed-by: Andrew Jones <drjones@redhat.com>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [kvm-unit-tests PATCH v2 2/4] configure: emit HOST=$host to config.mak
  2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 2/4] configure: emit HOST=$host to config.mak Alex Bennée
@ 2015-07-07 11:43   ` Andrew Jones
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Jones @ 2015-07-07 11:43 UTC (permalink / raw)
  To: Alex Bennée; +Cc: kvm

On Tue, Jul 07, 2015 at 08:03:31AM +0100, Alex Bennée wrote:
> This is useful information for the run scripts to know, especially if
> they want to drop to using TCG.
> 
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
>  configure | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/configure b/configure
> index b2ad32a..078b70c 100755
> --- a/configure
> +++ b/configure
> @@ -7,6 +7,7 @@ ld=ld
>  objcopy=objcopy
>  ar=ar
>  arch=`uname -m | sed -e s/i.86/i386/ | sed -e 's/arm.*/arm/'`
> +host=$arch
>  cross_prefix=
>  
>  usage() {
> @@ -122,6 +123,7 @@ ln -s $asm lib/asm
>  cat <<EOF > config.mak
>  PREFIX=$prefix
>  KERNELDIR=$(readlink -f $kerneldir)
> +HOST=$host
>  ARCH=$arch
>  ARCH_NAME=$arch_name
>  PROCESSOR=$processor
> -- 
> 2.4.5

Reviewed-by: Andrew Jones <drjones@redhat.com>
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2015-07-07 11:43 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-07  7:03 [kvm-unit-tests PATCH v2 0/4] A couple of small fixes Alex Bennée
2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 1/4] README: add some CONTRIBUTING notes Alex Bennée
2015-07-07 11:43   ` Andrew Jones
2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 2/4] configure: emit HOST=$host to config.mak Alex Bennée
2015-07-07 11:43   ` Andrew Jones
2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 3/4] arm/run: introduce usingkvm var and use it Alex Bennée
2015-07-07 11:36   ` Andrew Jones
2015-07-07  7:03 ` [kvm-unit-tests PATCH v2 4/4] arm/run: clean-up setting of accel options Alex Bennée
2015-07-07 11:40   ` Andrew Jones

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox