From a2d45f685b55977283e430d9bc080fe8a9f48742 Mon Sep 17 00:00:00 2001
From: Nikos Skalkotos <skalkoto@grnet.gr>
Date: Tue, 8 Jul 2014 16:22:11 +0300
Subject: [PATCH] windows: Show details if the VM dies unexpectedly

Display the return code and the stderr of the kvm process when the
customization VM dies unexpectendly
---
 image_creator/os_type/windows/vm.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/image_creator/os_type/windows/vm.py b/image_creator/os_type/windows/vm.py
index 5f2cc31..386974e 100644
--- a/image_creator/os_type/windows/vm.py
+++ b/image_creator/os_type/windows/vm.py
@@ -138,7 +138,8 @@ class VM(object):
         args.extend(['-monitor', 'stdio'])
 
         self.process = subprocess.Popen(args, stdin=subprocess.PIPE,
-                                        stdout=subprocess.PIPE)
+                                        stdout=subprocess.PIPE,
+                                        stderr=subprocess.PIPE)
 
     def stop(self, timeout=0, fatal=True):
         """Stop the VM"""
@@ -184,7 +185,9 @@ class VM(object):
                         if current == self._ntokens:
                             return True
             if not self.isalive():
-                raise FatalError("Windows VM died unexpectedly!")
+                (stdout, stderr, rc) = self.wait()
+                raise FatalError("Windows VM died unexpectedly!\n\n"
+                                 "(rc=%d)\n%s" % (rc, stderr))
 
         return False
 
-- 
GitLab