From 520d991d0269df91e59d2b839080d58a11c26a51 Mon Sep 17 00:00:00 2001 From: Nikos Skalkotos Date: Wed, 24 Jul 2013 13:01:57 +0300 Subject: [PATCH] Monitor VM ps when waiting for windows booting When waiting for windows to boot, also check that the Windows VM process is up. --- image_creator/os_type/windows.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/image_creator/os_type/windows.py b/image_creator/os_type/windows.py index 5732d6b..54e4797 100644 --- a/image_creator/os_type/windows.py +++ b/image_creator/os_type/windows.py @@ -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) - 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() @@ -425,8 +422,8 @@ class Windows(OSBase): """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) @@ -434,7 +431,9 @@ class Windows(OSBase): 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""" -- 1.7.10.4