summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-04-24 13:23:27 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-05-07 13:03:30 +0100
commite820c86fb9ddfadea0c27f29e14b985ee3178320 (patch)
treef3cdf0c7d45a6c871e8a14c17d02d6d5b595a0f9 /meta/lib
parent9b335fa867805f612154ae92c5a1e727d3fb29ca (diff)
downloadpoky-e820c86fb9ddfadea0c27f29e14b985ee3178320.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) 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>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 7ae309845a..cd95d33bdc 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
@@ -124,7 +125,6 @@ class QemuRunner:
124 self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout)) 125 self.logger.error('Output from runqemu:\n%s' % self.getOutput(self.runqemu.stdout))
125 self.stop() 126 self.stop()
126 self._dump_host() 127 self._dump_host()
127 raise SystemExit
128 128
129 def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True): 129 def start(self, qemuparams = None, get_ip = True, extra_bootparams = None, runqemuparams='', launch_cmd=None, discard_writes=True):
130 env = os.environ.copy() 130 env = os.environ.copy()
@@ -232,6 +232,8 @@ class QemuRunner:
232 endtime = time.time() + self.runqemutime 232 endtime = time.time() + self.runqemutime
233 while not self.is_alive() and time.time() < endtime: 233 while not self.is_alive() and time.time() < endtime:
234 if self.runqemu.poll(): 234 if self.runqemu.poll():
235 if self.runqemu_exited:
236 return False
235 if self.runqemu.returncode: 237 if self.runqemu.returncode:
236 # No point waiting any longer 238 # No point waiting any longer
237 self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode) 239 self.logger.warning('runqemu exited with code %d' % self.runqemu.returncode)
@@ -241,6 +243,9 @@ class QemuRunner:
241 return False 243 return False
242 time.sleep(0.5) 244 time.sleep(0.5)
243 245
246 if self.runqemu_exited:
247 return False
248
244 if not self.is_alive(): 249 if not self.is_alive():
245 self.logger.error("Qemu pid didn't appear in %s seconds (%s)" % 250 self.logger.error("Qemu pid didn't appear in %s seconds (%s)" %
246 (self.runqemutime, time.strftime("%D %H:%M:%S"))) 251 (self.runqemutime, time.strftime("%D %H:%M:%S")))
@@ -416,7 +421,7 @@ class QemuRunner:
416 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL) 421 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL)
417 self.runqemu.stdin.close() 422 self.runqemu.stdin.close()
418 self.runqemu.stdout.close() 423 self.runqemu.stdout.close()
419 self.runqemu = None 424 self.runqemu_exited = True
420 425
421 if hasattr(self, 'server_socket') and self.server_socket: 426 if hasattr(self, 'server_socket') and self.server_socket:
422 self.server_socket.close() 427 self.server_socket.close()
@@ -457,7 +462,7 @@ class QemuRunner:
457 return False 462 return False
458 463
459 def is_alive(self): 464 def is_alive(self):
460 if not self.runqemu or self.runqemu.poll() is not None: 465 if not self.runqemu or self.runqemu.poll() is not None or self.runqemu_exited:
461 return False 466 return False
462 if os.path.isfile(self.qemu_pidfile): 467 if os.path.isfile(self.qemu_pidfile):
463 # when handling pidfile, qemu creates the file, stat it, lock it and then write to it 468 # when handling pidfile, qemu creates the file, stat it, lock it and then write to it