summaryrefslogtreecommitdiffstats
path: root/meta/lib/oeqa/utils
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-05 19:15:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-05-15 17:18:21 +0100
commit6ad4febbcdb3e0024c888367f2af48a5222292f5 (patch)
treeb08fb3eb05ec073aa1482659add3969568e02471 /meta/lib/oeqa/utils
parent6f1d6448c5b2711f04e6b3798aef10b39669bcac (diff)
downloadpoky-6ad4febbcdb3e0024c888367f2af48a5222292f5.tar.gz
oeqa/qemurunner: Improve logging thread exit handling for qemu shutdown test
Rather than totally disabling the logging, inform it we're about to exit so we can log messages over the exit cleanly too. This aids debugging. It also avoids a race where the logging handler could still error whilst shutting down. Also remove a race window by notificing the handler of the shutdown first, before triggering it. This removes a race window I watched in local testing. (From OE-Core rev: 7f931dce4484a2740b419b2d25830fc453748a0c) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 0e19f31a1005f94105e1cef252abfffcef2aafad) Signed-off-by: Anuj Mittal <anuj.mittal@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 278904ba0b..84f7c5e76d 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -471,6 +471,10 @@ class QemuRunner:
471 self.thread.stop() 471 self.thread.stop()
472 self.thread.join() 472 self.thread.join()
473 473
474 def allowexit(self):
475 if self.thread:
476 self.thread.allowexit()
477
474 def restart(self, qemuparams = None): 478 def restart(self, qemuparams = None):
475 self.logger.warning("Restarting qemu process") 479 self.logger.warning("Restarting qemu process")
476 if self.runqemu.poll() is None: 480 if self.runqemu.poll() is None:
@@ -564,6 +568,7 @@ class LoggingThread(threading.Thread):
564 self.logger = logger 568 self.logger = logger
565 self.readsock = None 569 self.readsock = None
566 self.running = False 570 self.running = False
571 self.canexit = False
567 572
568 self.errorevents = select.POLLERR | select.POLLHUP | select.POLLNVAL 573 self.errorevents = select.POLLERR | select.POLLHUP | select.POLLNVAL
569 self.readevents = select.POLLIN | select.POLLPRI 574 self.readevents = select.POLLIN | select.POLLPRI
@@ -597,6 +602,9 @@ class LoggingThread(threading.Thread):
597 self.close_ignore_error(self.writepipe) 602 self.close_ignore_error(self.writepipe)
598 self.running = False 603 self.running = False
599 604
605 def allowexit(self):
606 self.canexit = True
607
600 def eventloop(self): 608 def eventloop(self):
601 poll = select.poll() 609 poll = select.poll()
602 event_read_mask = self.errorevents | self.readevents 610 event_read_mask = self.errorevents | self.readevents
@@ -653,7 +661,9 @@ class LoggingThread(threading.Thread):
653 # happened. But for this code it counts as an 661 # happened. But for this code it counts as an
654 # error since the connection shouldn't go away 662 # error since the connection shouldn't go away
655 # until qemu exits. 663 # until qemu exits.
656 raise Exception("Console connection closed unexpectedly") 664 if not self.canexit:
665 raise Exception("Console connection closed unexpectedly")
666 return ''
657 667
658 return data 668 return data
659 669