diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-04-24 13:23:27 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2020-06-02 13:32:49 +0100 |
commit | 6dc7ae4ff932642955f54d1c3e63f4729f504b68 (patch) | |
tree | fc61bc01c9292fd39d2a78855661f826c0a4a9f2 /meta/lib/oeqa | |
parent | c77dade37c92bb3a25686a6759a231881bb96477 (diff) | |
download | poky-6dc7ae4ff932642955f54d1c3e63f4729f504b68.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: 83b8e66b66aa9848ed9c8761a21cb47c6443d0c6)
(From OE-Core rev: 19120fce4f55f6a2903812ed9461273a85cb3544)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit e820c86fb9ddfadea0c27f29e14b985ee3178320)
Signed-off-by: Anuj Mittal <anuj.mittal@intel.com>
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 0d63e44ea7..3db177b001 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -35,6 +35,7 @@ class QemuRunner: | |||
35 | 35 | ||
36 | # Popen object for runqemu | 36 | # Popen object for runqemu |
37 | self.runqemu = None | 37 | self.runqemu = None |
38 | self.runqemu_exited = False | ||
38 | # pid of the qemu process that runqemu will start | 39 | # pid of the qemu process that runqemu will start |
39 | self.qemupid = None | 40 | self.qemupid = None |
40 | # target ip - from the command line or runqemu output | 41 | # target ip - from the command line or runqemu output |
@@ -102,7 +103,6 @@ class QemuRunner: | |||
102 | self.logger.debug("Output from runqemu:\n%s" % self.getOutput(self.runqemu.stdout)) | 103 | self.logger.debug("Output from runqemu:\n%s" % self.getOutput(self.runqemu.stdout)) |
103 | self.stop() | 104 | self.stop() |
104 | self._dump_host() | 105 | self._dump_host() |
105 | raise SystemExit | ||
106 | 106 | ||
107 | def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True): | 107 | def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True): |
108 | env = os.environ.copy() | 108 | env = os.environ.copy() |
@@ -206,6 +206,8 @@ class QemuRunner: | |||
206 | endtime = time.time() + self.runqemutime | 206 | endtime = time.time() + self.runqemutime |
207 | while not self.is_alive() and time.time() < endtime: | 207 | while not self.is_alive() and time.time() < endtime: |
208 | if self.runqemu.poll(): | 208 | if self.runqemu.poll(): |
209 | if self.runqemu_exited: | ||
210 | return False | ||
209 | if self.runqemu.returncode: | 211 | if self.runqemu.returncode: |
210 | # No point waiting any longer | 212 | # No point waiting any longer |
211 | self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) | 213 | self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) |
@@ -215,6 +217,9 @@ class QemuRunner: | |||
215 | return False | 217 | return False |
216 | time.sleep(0.5) | 218 | time.sleep(0.5) |
217 | 219 | ||
220 | if self.runqemu_exited: | ||
221 | return False | ||
222 | |||
218 | if not self.is_alive(): | 223 | if not self.is_alive(): |
219 | self.logger.error("Qemu pid didn't appear in %s seconds (%s)" % | 224 | self.logger.error("Qemu pid didn't appear in %s seconds (%s)" % |
220 | (self.runqemutime, time.strftime("%D %H:%M:%S"))) | 225 | (self.runqemutime, time.strftime("%D %H:%M:%S"))) |
@@ -385,7 +390,7 @@ class QemuRunner: | |||
385 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) | 390 | os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) |
386 | self.runqemu.stdin.close() | 391 | self.runqemu.stdin.close() |
387 | self.runqemu.stdout.close() | 392 | self.runqemu.stdout.close() |
388 | self.runqemu = None | 393 | self.runqemu_exited = True |
389 | 394 | ||
390 | if hasattr(self, 'server_socket') and self.server_socket: | 395 | if hasattr(self, 'server_socket') and self.server_socket: |
391 | self.server_socket.close() | 396 | self.server_socket.close() |
@@ -425,7 +430,7 @@ class QemuRunner: | |||
425 | return False | 430 | return False |
426 | 431 | ||
427 | def is_alive(self): | 432 | def is_alive(self): |
428 | if not self.runqemu or self.runqemu.poll() is not None: | 433 | if not self.runqemu or self.runqemu.poll() is not None or self.runqemu_exited: |
429 | return False | 434 | return False |
430 | if os.path.isfile(self.qemu_pidfile): | 435 | if os.path.isfile(self.qemu_pidfile): |
431 | # when handling pidfile, qemu creates the file, stat it, lock it and then write to it | 436 | # when handling pidfile, qemu creates the file, stat it, lock it and then write to it |