Replace use of vm.wait_for_start() with wait_for is_alive. Also remove
vm.wait_for_start() since it's not actually used anywhere else.

Signed-off-by: Chris Evich <[email protected]>
---
 client/virt/libvirt_vm.py |   36 +++++-------------------------------
 1 files changed, 5 insertions(+), 31 deletions(-)

diff --git a/client/virt/libvirt_vm.py b/client/virt/libvirt_vm.py
index 908f12a..a48809d 100644
--- a/client/virt/libvirt_vm.py
+++ b/client/virt/libvirt_vm.py
@@ -1195,42 +1195,16 @@ class VM(virt_vm.BaseVM):
         return virsh_screenshot(self.name, filename, self.connect_uri)
 
 
-    def wait_for_start(self, count=60):
-        """
-        Return True on successful domain start.
-
-        Wait for a domain to start, libvirt does not block on domain
-        start so we need to watch for successful completion.
-
-        @param name: VM name
-        @param name: Optional timeout value
-        """
-        timeout = count
-        while count > 0:
-            # check every 5 seconds
-            if count % 5 == 0:
-                if virsh_is_alive(self.name, self.connect_uri):
-                    session = self.wait_for_login(timeout=60)
-                    session.close()
-                    logging.debug("Start took %d seconds", timeout - count)
-                    return True
-            count -= 1
-            time.sleep(1)
-            logging.debug("Waiting for guest to start %d", count)
-        return False
-
-
     def start(self):
         """
         Starts this VM.
         """
         if virsh_start(self.name, self.connect_uri):
-            if self.wait_for_start():
-                logging.debug("Started VM %s", self.name)
-                return True
-            else:
-                logging.error("VM %s failed to start", self.name)
-                return False
+            # virsh returns immediatly if start command successful
+            # but don't assume guest actually started
+            return virt_utils.wait_for(func=self.is_alive, timeout=10,
+                                text=("waiting for domain %s to start" %
+                                      self.name))
         else:
             logging.error("VM %s failed to start", self.name)
             return False
-- 
1.7.1

_______________________________________________
Autotest mailing list
[email protected]
http://test.kernel.org/cgi-bin/mailman/listinfo/autotest

Reply via email to