summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariano Lopez <mariano.lopez@linux.intel.com>2017-01-13 14:33:55 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-01-19 22:47:22 +0000
commit81c3d4824af983029e9621fbdb377f4cf9aabb5a (patch)
tree10f593a4761760c24cad1b66cb645113af2f29f8
parentde17891185a3b593d8cde50991082f6fd6c209f9 (diff)
downloadpoky-81c3d4824af983029e9621fbdb377f4cf9aabb5a.tar.gz
oeqa/utils/qemurunner.py: Be sure to stop qemu-system
When runqemu fails, qemu-system process would keep running and won't be killed, setpgrp() was used when runqemu was a shell script but it seems it doesn't work always with python. This would kill qemu-system explicity and to avoid leaving it behind. (From OE-Core rev: 9d2b1aa1bcfb2f1933a8eeb9470b4174d5da2f0d) Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/classes/testimage.bbclass2
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py9
2 files changed, 11 insertions, 0 deletions
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 770ec801c2..7eb4038d21 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -171,6 +171,8 @@ def testimage_main(d):
171 bb.plain(msg) 171 bb.plain(msg)
172 else: 172 else:
173 bb.fatal("%s - FAILED - check the task log and the ssh log" % pn) 173 bb.fatal("%s - FAILED - check the task log and the ssh log" % pn)
174 except BlockingIOError as err:
175 bb.error('runqemu failed, shutting down...')
174 finally: 176 finally:
175 signal.signal(signal.SIGTERM, tc.origsigtermhandler) 177 signal.signal(signal.SIGTERM, tc.origsigtermhandler)
176 target.stop() 178 target.stop()
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 6927456b29..21bc35a32c 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -296,6 +296,7 @@ class QemuRunner:
296 296
297 def stop(self): 297 def stop(self):
298 self.stop_thread() 298 self.stop_thread()
299 self.stop_qemu_system()
299 if hasattr(self, "origchldhandler"): 300 if hasattr(self, "origchldhandler"):
300 signal.signal(signal.SIGCHLD, self.origchldhandler) 301 signal.signal(signal.SIGCHLD, self.origchldhandler)
301 if self.runqemu: 302 if self.runqemu:
@@ -320,6 +321,14 @@ class QemuRunner:
320 self.qemupid = None 321 self.qemupid = None
321 self.ip = None 322 self.ip = None
322 323
324 def stop_qemu_system(self):
325 if self.qemupid:
326 try:
327 # qemu-system behaves well and a SIGTERM is enough
328 os.kill(self.qemupid, signal.SIGTERM)
329 except ProcessLookupError as e:
330 logger.warn('qemu-system ended unexpectedly')
331
323 def stop_thread(self): 332 def stop_thread(self):
324 if self.thread and self.thread.is_alive(): 333 if self.thread and self.thread.is_alive():
325 self.thread.stop() 334 self.thread.stop()