diff options
author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-07-27 14:04:00 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-07-27 23:29:14 +0100 |
commit | a6eb5ec327bacb592eaa116a566a55ba509b7aa5 (patch) | |
tree | 5125b06eb41e76b37cd8c51b9a96024b2c767dfc | |
parent | 7f9b42a90f1653ded23115b1119df94f9ebd3d2a (diff) | |
download | poky-a6eb5ec327bacb592eaa116a566a55ba509b7aa5.tar.gz |
oeqa/utils/qemurunner: fix error handling if runqemu exits with an error
* Don't wait for QEMU to start if it's never going to (because runqemu
exited with an error)
* Don't error out if killing the process fails with "no such process"
(we don't care if it's already dead)
(From OE-Core rev: 1789b89de6c4642464abadd9f8a4746385e6b4a7)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 11186d6b26..71da21c779 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -12,6 +12,7 @@ import signal | |||
12 | import re | 12 | import re |
13 | import socket | 13 | import socket |
14 | import select | 14 | import select |
15 | import errno | ||
15 | 16 | ||
16 | import logging | 17 | import logging |
17 | logger = logging.getLogger("BitBake.QemuRunner") | 18 | logger = logging.getLogger("BitBake.QemuRunner") |
@@ -104,6 +105,14 @@ class QemuRunner: | |||
104 | logger.info("waiting at most %s seconds for qemu pid" % self.runqemutime) | 105 | logger.info("waiting at most %s seconds for qemu pid" % self.runqemutime) |
105 | endtime = time.time() + self.runqemutime | 106 | endtime = time.time() + self.runqemutime |
106 | while not self.is_alive() and time.time() < endtime: | 107 | while not self.is_alive() and time.time() < endtime: |
108 | if self.runqemu.poll(): | ||
109 | if self.runqemu.returncode: | ||
110 | # No point waiting any longer | ||
111 | logger.info('runqemu exited with code %d' % self.runqemu.returncode) | ||
112 | output = self.runqemu.stdout | ||
113 | self.stop() | ||
114 | logger.info("Output from runqemu:\n%s" % output.read()) | ||
115 | return False | ||
107 | time.sleep(1) | 116 | time.sleep(1) |
108 | 117 | ||
109 | if self.is_alive(): | 118 | if self.is_alive(): |
@@ -169,7 +178,11 @@ class QemuRunner: | |||
169 | 178 | ||
170 | if self.runqemu: | 179 | if self.runqemu: |
171 | logger.info("Sending SIGTERM to runqemu") | 180 | logger.info("Sending SIGTERM to runqemu") |
172 | os.killpg(self.runqemu.pid, signal.SIGTERM) | 181 | try: |
182 | os.killpg(self.runqemu.pid, signal.SIGTERM) | ||
183 | except OSError as e: | ||
184 | if e.errno != errno.ESRCH: | ||
185 | raise | ||
173 | endtime = time.time() + self.runqemutime | 186 | endtime = time.time() + self.runqemutime |
174 | while self.runqemu.poll() is None and time.time() < endtime: | 187 | while self.runqemu.poll() is None and time.time() < endtime: |
175 | time.sleep(1) | 188 | time.sleep(1) |