[gnome-continuous-yocto/gnomeostree-3.28-rocko: 4097/8267] oeqa/utils/qemurunner.py: Be sure to stop qemu-system



commit 81c3d4824af983029e9621fbdb377f4cf9aabb5a
Author: Mariano Lopez <mariano lopez linux intel com>
Date:   Fri Jan 13 14:33:55 2017 +0000

    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>

 meta/classes/testimage.bbclass    |    2 ++
 meta/lib/oeqa/utils/qemurunner.py |    9 +++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
---
diff --git a/meta/classes/testimage.bbclass b/meta/classes/testimage.bbclass
index 770ec80..7eb4038 100644
--- a/meta/classes/testimage.bbclass
+++ b/meta/classes/testimage.bbclass
@@ -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()
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 6927456..21bc35a 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -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()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]