Skip to contentSkip to conversation

qemurunner: Handle qemu start failure correctly

PATCH New Richard Purdie 1 participant 1 message Sep 26, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qemurunner: Handle qemu start failure correctly

If qemu didn't start correctly, we may not have registered the child signal. This results in a nasty traceback which confuses the underlying issue. Cleanup this code and make the handler cleanup conditional.

meta/lib/oeqa/utils/qemurunner.py +2 -2
index 41b4401..c2c1779 100644
@@ -258,8 +258,9 @@ class QemuRunner:
 
     def stop(self):
         self.stop_thread()
-        if self.runqemu:
+        if self.origchldhandler:
             signal.signal(signal.SIGCHLD, self.origchldhandler)
+        if self.runqemu:
             os.kill(self.monitorpid, signal.SIGKILL)
             logger.info("Output from runqemu:\n%s" % self.getOutput(self.runqemu.stdout))
             logger.info("Sending SIGTERM to runqemu")
@@ -280,7 +281,6 @@ class QemuRunner:
             self.server_socket = None
         self.qemupid = None
         self.ip = None
-        signal.signal(signal.SIGCHLD, self.origchldhandler)
 
     def stop_thread(self):
         if self.thread and self.thread.is_alive():