]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa/utils/qemurunner.py: Be sure to stop qemu-system
authorMariano Lopez <mariano.lopez@linux.intel.com>
Fri, 13 Jan 2017 14:33:55 +0000 (14:33 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 19 Jan 2017 22:45:46 +0000 (22:45 +0000)
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.

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/testimage.bbclass
meta/lib/oeqa/utils/qemurunner.py

index 770ec801c2b5a5ced554a1ded00642f7648a8fc8..7eb4038d216470a3da06b65cd868b4c80454dd19 100644 (file)
@@ -171,6 +171,8 @@ def testimage_main(d):
             bb.plain(msg)
         else:
             bb.fatal("%s - FAILED - check the task log and the ssh log" % pn)
+    except BlockingIOError as err:
+        bb.error('runqemu failed, shutting down...')
     finally:
         signal.signal(signal.SIGTERM, tc.origsigtermhandler)
         target.stop()
index 6927456b2924a3c6e7a4bc8321e74c7124c7bfb1..21bc35a32c6fe8b280430192089425ae0479ee95 100644 (file)
@@ -296,6 +296,7 @@ class QemuRunner:
 
     def stop(self):
         self.stop_thread()
+        self.stop_qemu_system()
         if hasattr(self, "origchldhandler"):
             signal.signal(signal.SIGCHLD, self.origchldhandler)
         if self.runqemu:
@@ -320,6 +321,14 @@ class QemuRunner:
         self.qemupid = None
         self.ip = None
 
+    def stop_qemu_system(self):
+        if self.qemupid:
+            try:
+                # qemu-system behaves well and a SIGTERM is enough
+                os.kill(self.qemupid, signal.SIGTERM)
+            except ProcessLookupError as e:
+                logger.warn('qemu-system ended unexpectedly')
+
     def stop_thread(self):
         if self.thread and self.thread.is_alive():
             self.thread.stop()