All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/5] tests/vm: Improvements when KVM is not available
@ 2018-07-17  2:48 Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 1/5] tests/vm: Extract the kvm_available() handy function Philippe Mathieu-Daudé
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-07-17  2:48 UTC (permalink / raw)
  To: Alex Bennée, Fam Zheng; +Cc: Philippe Mathieu-Daudé, qemu-devel

Hi Fam,

Few patches I added while testing the VM tests without KVM access.
I doubt many people want to suffer using TCG for VM testing, but
it was handy to debug/support aarch64 VM tests.

Also this could be a useful TCG stress test...?

Regards,

Phil.

Philippe Mathieu-Daudé (5):
  tests/vm: Extract the kvm_available() handy function
  tests/vm: Use 'host' cpu when KVM is available, else default to 'max'
  tests/vm: Do not abuse parallelism when KVM is not available
  tests/vm: Display remaining seconds to wait for a VM to start
  tests/vm: When using TCG, wait longer for a VM to start

 tests/vm/basevm.py | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

-- 
2.18.0

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

* [Qemu-devel] [PATCH 1/5] tests/vm: Extract the kvm_available() handy function
  2018-07-17  2:48 [Qemu-devel] [PATCH 0/5] tests/vm: Improvements when KVM is not available Philippe Mathieu-Daudé
@ 2018-07-17  2:48 ` Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 2/5] tests/vm: Use 'host' cpu when KVM is available, else default to 'max' Philippe Mathieu-Daudé
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-07-17  2:48 UTC (permalink / raw)
  To: Alex Bennée, Fam Zheng; +Cc: Philippe Mathieu-Daudé, qemu-devel

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/vm/basevm.py | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 3643117816..04089cd545 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -33,6 +33,11 @@ SSH_KEY = open(os.path.join(os.path.dirname(__file__),
 SSH_PUB_KEY = open(os.path.join(os.path.dirname(__file__),
                    "..", "keys", "id_rsa.pub")).read()
 
+
+def kvm_available():
+    return os.access("/dev/kvm", os.R_OK | os.W_OK)
+
+
 class BaseVM(object):
     GUEST_USER = "qemu"
     GUEST_PASS = "qemupass"
@@ -72,7 +77,7 @@ class BaseVM(object):
             "-serial", "file:%s" % os.path.join(self._tmpdir, "serial.out")]
         if vcpus:
             self._args += ["-smp", str(vcpus)]
-        if os.access("/dev/kvm", os.R_OK | os.W_OK):
+        if kvm_available():
             self._args += ["-enable-kvm"]
         else:
             logging.info("KVM not available, not using -enable-kvm")
-- 
2.18.0

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

* [Qemu-devel] [PATCH 2/5] tests/vm: Use 'host' cpu when KVM is available, else default to 'max'
  2018-07-17  2:48 [Qemu-devel] [PATCH 0/5] tests/vm: Improvements when KVM is not available Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 1/5] tests/vm: Extract the kvm_available() handy function Philippe Mathieu-Daudé
@ 2018-07-17  2:48 ` Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 3/5] tests/vm: Do not abuse parallelism when KVM is not available Philippe Mathieu-Daudé
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-07-17  2:48 UTC (permalink / raw)
  To: Alex Bennée, Fam Zheng; +Cc: Philippe Mathieu-Daudé, qemu-devel

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/vm/basevm.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 04089cd545..1f4ad04c32 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -70,7 +70,6 @@ class BaseVM(object):
             self._stdout = self._devnull
         self._args = [ \
             "-nodefaults", "-m", "2G",
-            "-cpu", "host",
             "-netdev", "user,id=vnet,hostfwd=:127.0.0.1:0-:22",
             "-device", "virtio-net-pci,netdev=vnet",
             "-vnc", "127.0.0.1:0,to=20",
@@ -79,8 +78,10 @@ class BaseVM(object):
             self._args += ["-smp", str(vcpus)]
         if kvm_available():
             self._args += ["-enable-kvm"]
+            self._args += ["-cpu", "host"]
         else:
             logging.info("KVM not available, not using -enable-kvm")
+            self._args += ["-cpu", "max"]
         self._data_args = []
 
     def _download_with_cache(self, url, sha256sum=None):
-- 
2.18.0

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

* [Qemu-devel] [PATCH 3/5] tests/vm: Do not abuse parallelism when KVM is not available
  2018-07-17  2:48 [Qemu-devel] [PATCH 0/5] tests/vm: Improvements when KVM is not available Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 1/5] tests/vm: Extract the kvm_available() handy function Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 2/5] tests/vm: Use 'host' cpu when KVM is available, else default to 'max' Philippe Mathieu-Daudé
@ 2018-07-17  2:48 ` Philippe Mathieu-Daudé
  2018-07-17 13:37   ` Fam Zheng
  2018-07-17  2:48 ` [Qemu-devel] [RFC PATCH 4/5] tests/vm: Display remaining seconds to wait for a VM to start Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [RFC PATCH 5/5] tests/vm: When using TCG, wait longer " Philippe Mathieu-Daudé
  4 siblings, 1 reply; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-07-17  2:48 UTC (permalink / raw)
  To: Alex Bennée, Fam Zheng; +Cc: Philippe Mathieu-Daudé, qemu-devel

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/vm/basevm.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 1f4ad04c32..715e433142 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -233,7 +233,7 @@ def main(vmcls):
             return 1
         logging.basicConfig(level=(logging.DEBUG if args.debug
                                    else logging.WARN))
-        vm = vmcls(debug=args.debug, vcpus=args.jobs)
+        vm = vmcls(debug=args.debug, vcpus=args.jobs if kvm_available() else 0)
         if args.build_image:
             if os.path.exists(args.image) and not args.force:
                 sys.stderr.writelines(["Image file exists: %s\n" % args.image,
@@ -244,7 +244,7 @@ def main(vmcls):
             vm.add_source_dir(args.build_qemu)
             cmd = [vm.BUILD_SCRIPT.format(
                    configure_opts = " ".join(argv),
-                   jobs=args.jobs)]
+                   jobs=args.jobs if kvm_available() else 1)]
         else:
             cmd = argv
         vm.boot(args.image + ",snapshot=on")
-- 
2.18.0

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

* [Qemu-devel] [RFC PATCH 4/5] tests/vm: Display remaining seconds to wait for a VM to start
  2018-07-17  2:48 [Qemu-devel] [PATCH 0/5] tests/vm: Improvements when KVM is not available Philippe Mathieu-Daudé
                   ` (2 preceding siblings ...)
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 3/5] tests/vm: Do not abuse parallelism when KVM is not available Philippe Mathieu-Daudé
@ 2018-07-17  2:48 ` Philippe Mathieu-Daudé
  2018-07-17  2:48 ` [Qemu-devel] [RFC PATCH 5/5] tests/vm: When using TCG, wait longer " Philippe Mathieu-Daudé
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-07-17  2:48 UTC (permalink / raw)
  To: Alex Bennée, Fam Zheng; +Cc: Philippe Mathieu-Daudé, qemu-devel

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
 tests/vm/basevm.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 715e433142..7575c36f0b 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -183,12 +183,15 @@ class BaseVM(object):
 
     def wait_ssh(self, seconds=120):
         starttime = datetime.datetime.now()
+        endtime = starttime + datetime.timedelta(seconds=seconds)
         guest_up = False
-        while (datetime.datetime.now() - starttime).total_seconds() < seconds:
+        while datetime.datetime.now() < endtime:
             if self.ssh("exit 0") == 0:
                 guest_up = True
                 break
             time.sleep(1)
+            seconds = (endtime - datetime.datetime.now()).total_seconds()
+            logging.debug("%ds before timeout", seconds)
         if not guest_up:
             raise Exception("Timeout while waiting for guest ssh")
 
-- 
2.18.0

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

* [Qemu-devel] [RFC PATCH 5/5] tests/vm: When using TCG, wait longer for a VM to start
  2018-07-17  2:48 [Qemu-devel] [PATCH 0/5] tests/vm: Improvements when KVM is not available Philippe Mathieu-Daudé
                   ` (3 preceding siblings ...)
  2018-07-17  2:48 ` [Qemu-devel] [RFC PATCH 4/5] tests/vm: Display remaining seconds to wait for a VM to start Philippe Mathieu-Daudé
@ 2018-07-17  2:48 ` Philippe Mathieu-Daudé
  4 siblings, 0 replies; 7+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-07-17  2:48 UTC (permalink / raw)
  To: Alex Bennée, Fam Zheng; +Cc: Philippe Mathieu-Daudé, qemu-devel

Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
4 is random (but more than 1).
---
 tests/vm/basevm.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
index 7575c36f0b..50785a64df 100755
--- a/tests/vm/basevm.py
+++ b/tests/vm/basevm.py
@@ -182,6 +182,8 @@ class BaseVM(object):
                             usernet_info)
 
     def wait_ssh(self, seconds=120):
+        if not kvm_available():
+            seconds *= 4
         starttime = datetime.datetime.now()
         endtime = starttime + datetime.timedelta(seconds=seconds)
         guest_up = False
-- 
2.18.0

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

* Re: [Qemu-devel] [PATCH 3/5] tests/vm: Do not abuse parallelism when KVM is not available
  2018-07-17  2:48 ` [Qemu-devel] [PATCH 3/5] tests/vm: Do not abuse parallelism when KVM is not available Philippe Mathieu-Daudé
@ 2018-07-17 13:37   ` Fam Zheng
  0 siblings, 0 replies; 7+ messages in thread
From: Fam Zheng @ 2018-07-17 13:37 UTC (permalink / raw)
  To: Philippe Mathieu-Daudé; +Cc: Alex Bennée, qemu-devel

On Mon, 07/16 23:48, Philippe Mathieu-Daudé wrote:
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
>  tests/vm/basevm.py | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/vm/basevm.py b/tests/vm/basevm.py
> index 1f4ad04c32..715e433142 100755
> --- a/tests/vm/basevm.py
> +++ b/tests/vm/basevm.py
> @@ -233,7 +233,7 @@ def main(vmcls):
>              return 1
>          logging.basicConfig(level=(logging.DEBUG if args.debug
>                                     else logging.WARN))
> -        vm = vmcls(debug=args.debug, vcpus=args.jobs)
> +        vm = vmcls(debug=args.debug, vcpus=args.jobs if kvm_available() else 0)
>          if args.build_image:
>              if os.path.exists(args.image) and not args.force:
>                  sys.stderr.writelines(["Image file exists: %s\n" % args.image,
> @@ -244,7 +244,7 @@ def main(vmcls):
>              vm.add_source_dir(args.build_qemu)
>              cmd = [vm.BUILD_SCRIPT.format(
>                     configure_opts = " ".join(argv),
> -                   jobs=args.jobs)]
> +                   jobs=args.jobs if kvm_available() else 1)]
>          else:
>              cmd = argv
>          vm.boot(args.image + ",snapshot=on")
> -- 
> 2.18.0
> 

Could you instead change this line

    parser.add_option("--jobs", type=int, default=multiprocessing.cpu_count() / 2,
                      help="number of virtual CPUs")

to use kvm_available()? With another helper function to contain the line width,
probably:

    ..., default=get_default_jobs(), help=...

and

    def get_default_jobs():
        if kvm_available():
            return ...
        else:
            return ...

Fam

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

end of thread, other threads:[~2018-07-17 13:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17  2:48 [Qemu-devel] [PATCH 0/5] tests/vm: Improvements when KVM is not available Philippe Mathieu-Daudé
2018-07-17  2:48 ` [Qemu-devel] [PATCH 1/5] tests/vm: Extract the kvm_available() handy function Philippe Mathieu-Daudé
2018-07-17  2:48 ` [Qemu-devel] [PATCH 2/5] tests/vm: Use 'host' cpu when KVM is available, else default to 'max' Philippe Mathieu-Daudé
2018-07-17  2:48 ` [Qemu-devel] [PATCH 3/5] tests/vm: Do not abuse parallelism when KVM is not available Philippe Mathieu-Daudé
2018-07-17 13:37   ` Fam Zheng
2018-07-17  2:48 ` [Qemu-devel] [RFC PATCH 4/5] tests/vm: Display remaining seconds to wait for a VM to start Philippe Mathieu-Daudé
2018-07-17  2:48 ` [Qemu-devel] [RFC PATCH 5/5] tests/vm: When using TCG, wait longer " Philippe Mathieu-Daudé

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.