test suite reviews and discussions
 help / color / mirror / Atom feed
* [dts] [PATCH v1] framework/qemu_kvm: check multiple times for network ready
@ 2018-01-10 20:17 Marvin Liu
  0 siblings, 0 replies; only message in thread
From: Marvin Liu @ 2018-01-10 20:17 UTC (permalink / raw)
  To: dts; +Cc: Marvin Liu

Control network start time will also be calculated into total startup
time. Will check multiple times for network status in case network not
ready in few sceonds.

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index a75bf78..ec33669 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -1377,9 +1377,25 @@ class QEMUKvm(VirtBase):
         wait for 120 seconds for vm net ready
         10.0.2.* is the default ip address allocated by qemu
         """
-        ret = self.control_command("network")
-        # network has been ready, just return
-        if ret == "Success":
+        cur_time = time.time()
+        time_diff = cur_time - self.start_time
+        try_times = 0
+        network_ready = False
+        while (time_diff < self.START_TIMEOUT):
+            if self.control_command("network") == "Success":
+                network_ready = True
+                break
+
+            # update time consume
+            cur_time = time.time()
+            time_diff = cur_time - self.start_time
+
+            self.host_logger.warning("[%s] on [%s] network not ready, retry %d times!!!" % (self.vm_name, self.host_dut.crb['My IP'], try_times + 1))
+            time.sleep(self.OPERATION_TIMEOUT)
+            try_times += 1
+            continue
+
+        if network_ready:
             return True
         else:
             raise StartVMFailedException('Virtual machine control net not ready!!!')
-- 
1.9.3

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-01-11  3:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-01-10 20:17 [dts] [PATCH v1] framework/qemu_kvm: check multiple times for network ready Marvin Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).