OSDN Git Service

tests/vm: Display remaining seconds to wait for a VM to start
authorPhilippe Mathieu-Daudé <f4bug@amsat.org>
Sat, 13 Oct 2018 00:40:29 +0000 (02:40 +0200)
committerFam Zheng <famz@redhat.com>
Fri, 26 Oct 2018 14:03:21 +0000 (22:03 +0800)
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20181013004034.6968-5-f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Fam Zheng <famz@redhat.com>
tests/vm/basevm.py

index 9415e7c..81a1cb0 100755 (executable)
@@ -177,11 +177,14 @@ class BaseVM(object):
 
     def wait_ssh(self, seconds=300):
         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
+            seconds = (endtime - datetime.datetime.now()).total_seconds()
+            logging.debug("%ds before timeout", seconds)
             time.sleep(1)
         if not guest_up:
             raise Exception("Timeout while waiting for guest ssh")