Monitor VM ps when waiting for windows booting
authorNikos Skalkotos <skalkoto@grnet.gr>
Wed, 24 Jul 2013 10:01:57 +0000 (13:01 +0300)
committerNikos Skalkotos <skalkoto@grnet.gr>
Tue, 30 Jul 2013 13:43:59 +0000 (16:43 +0300)
When waiting for windows to boot, also check that the Windows VM
process is up.

image_creator/os_type/windows.py

index 5732d6b..54e4797 100644 (file)
@@ -318,11 +318,8 @@ class Windows(OSBase):
             self.out.success("started (console on vnc display: %d)." % display)
 
             self.out.output("Waiting for OS to boot ...", False)
             self.out.success("started (console on vnc display: %d)." % display)
 
             self.out.output("Waiting for OS to boot ...", False)
-            if not self._wait_on_file(monitor, token):
-                raise FatalError("Windows booting timed out.")
-            else:
-                time.sleep(10)  # Just to be sure everything is up
-                self.out.success('done')
+            self._wait_vm_boot(vm, monitor, token)
+            self.out.success('done')
 
             self.out.output("Disabling automatic logon ...", False)
             self._disable_autologon()
 
             self.out.output("Disabling automatic logon ...", False)
             self._disable_autologon()
@@ -425,8 +422,8 @@ class Windows(OSBase):
         """Shuts down the windows VM"""
         self._guest_exec(r'shutdown /s /t 5')
 
         """Shuts down the windows VM"""
         self._guest_exec(r'shutdown /s /t 5')
 
-    def _wait_on_file(self, fname, msg):
-        """Wait until a message appears on a file"""
+    def _wait_vm_boot(self, vm, fname, msg):
+        """Wait until a message appears on a file or the vm process dies"""
 
         for i in range(BOOT_TIMEOUT):
             time.sleep(1)
 
         for i in range(BOOT_TIMEOUT):
             time.sleep(1)
@@ -434,7 +431,9 @@ class Windows(OSBase):
                 for line in f:
                     if line.startswith(msg):
                         return True
                 for line in f:
                     if line.startswith(msg):
                         return True
-        return False
+            if not vm.process.alive:
+                raise FatalError("Windows VM died unexpectedly!")
+        raise FatalError("Windows booting timed out!")
 
     def _disable_autologon(self):
         """Disable automatic logon on the windows image"""
 
     def _disable_autologon(self):
         """Disable automatic logon on the windows image"""