diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-04-24 13:23:27 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-04-26 14:00:51 +0100 |
commit | 2e11d97b6c95e89aa1f9d3603a966c94c442469e (patch) | |
tree | 624eab95034f0490a3aea095b5f0c0e5c1392058 /meta/lib/oeqa | |
parent | ccb009e9a728ed73f2bf5079e970868b9d7197cc (diff) | |
download | poky-2e11d97b6c95e89aa1f9d3603a966c94c442469e.tar.gz |
oeqa/qemurunner: Clean up failure handling
If you fail to setup the tap devices, runqemu will error quickly
however stdout/stderr are not shown to the user, instead a SystemExit
traceback is shown. This could explain some long since unexplained
failures on the autobuilder.
Rework the error handling so SystemExit isn't used and the
standard log failure messages can be shown. The code could
likely ultimatley need some restructuring to work effectively.
(From OE-Core rev: 57ccf1e3bb320bd28a2d106c98f4706434c3075a)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa')
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 7d9b36f811..4b74337652 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -36,6 +36,7 @@ class QemuRunner: | |||
36 | 36 | ||
37 | # Popen object for runqemu | 37 | # Popen object for runqemu |
38 | self.runqemu = None | 38 | self.runqemu = None |
39 | self.runqemu_exited = False | ||
39 | # pid of the qemu process that runqemu will start | 40 | # pid of the qemu process that runqemu will start |
40 | self.qemupid = None | 41 | self.qemupid = None |
41 | # target ip - from the command line or runqemu output | 42 | # target ip - from the command line or runqemu output |
@@ -125,7 +126,6 @@ class QemuRunner: | |||
125 | self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout)) | 126 | self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout)) |
126 | self.stop() | 127 | self.stop() |
127 | self._dump_host() | 128 | self._dump_host() |
128 | raise SystemExit | ||
129 | 129 | ||
130 | def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True): | 130 | def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True): |
131 | env = os.environ.copy() | 131 | env = os.environ.copy() |
@@ -235,6 +235,8 @@ class QemuRunner: | |||
235 | endtime = time.time() + self.runqemutime | 235 | endtime = time.time() + self.runqemutime |
236 | while not self.is_alive() and time.time() < endtime: | 236 | while not self.is_alive() and time.time() < endtime: |
237 | if self.runqemu.poll(): | 237 | if self.runqemu.poll(): |
238 | if self.runqemu_exited: | ||
239 | return False | ||
238 | if self.runqemu.returncode: | 240 | if self.runqemu.returncode: |
239 | # No point waiting any longer | 241 | # No point waiting any longer |
240 | self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) | 242 | self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) |
@@ -244,6 +246,9 @@ class QemuRunner: | |||
244 | return False | 246 | return False |
245 | time.sleep(0.5) | 247 | time.sleep(0.5) |
246 | 248 | ||
249 | if self.runqemu_exited: | ||
250 | return False | ||
251 | |||
247 | if not self.is_alive(): | 252 | if not self.is_alive(): |
248 | self.logger.error("Qemu pid didn't appear in %s seconds (%s)" % | 253 | self.logger.error("Qemu pid didn't appear in %s seconds (%s)" % |
249 | (self.runqemutime, time.strftime("%D %H:%M:%S"))) | 254 | (self.runqemutime, time.strftime("%D %H:%M:%S"))) |
@@ -419,7 +424,7 @@ class QemuRunner: | |||
419 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) | 424 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) |
420 | self.runqemu.stdin.close() | 425 | self.runqemu.stdin.close() |
421 | self.runqemu.stdout.close() | 426 | self.runqemu.stdout.close() |
422 | self.runqemu = None | 427 | self.runqemu_exited = True |
423 | 428 | ||
424 | if hasattr(self, 'server_socket') and self.server_socket: | 429 | if hasattr(self, 'server_socket') and self.server_socket: |
425 | self.server_socket.close() | 430 | self.server_socket.close() |
@@ -460,7 +465,7 @@ class QemuRunner: | |||
460 | return False | 465 | return False |
461 | 466 | ||
462 | def is_alive(self): | 467 | def is_alive(self): |
463 | if not self.runqemu or self.runqemu.poll() is not None: | 468 | if not self.runqemu or self.runqemu.poll() is not None or self.runqemu_exited: |
464 | return False | 469 | return False |
465 | if os.path.isfile(self.qemu_pidfile): | 470 | if os.path.isfile(self.qemu_pidfile): |
466 | # when handling pidfile, qemu creates the file, stat it, lock it and then write to it | 471 | # when handling pidfile, qemu creates the file, stat it, lock it and then write to it |