diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-26 22:52:26 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-30 15:15:54 +0000 |
commit | 5573fb12ebc10778c37840af220796347966ec2f (patch) | |
tree | 13d2ceece6e3958b33704c0284439b9c6333bd74 /meta/lib/oeqa/utils/qemurunner.py | |
parent | 0f61386628df828c5b1a440a414759e3e60f86a2 (diff) | |
download | poky-5573fb12ebc10778c37840af220796347966ec2f.tar.gz |
oeqa/qemurunner: Handle rare shutdown race
The pid file can disappear when qemu is shutting down leading to a
file not found race before it is read.
Tweak the code to handle this and fix a rare but annoying race error
case.
[YOCTO #15036]
(From OE-Core rev: 8c07aac9d55f92fe5fbe3cab9f006efecf266328)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/qemurunner.py')
-rw-r--r-- | meta/lib/oeqa/utils/qemurunner.py | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py index 7273bbc3db..277cd32848 100644 --- a/meta/lib/oeqa/utils/qemurunner.py +++ b/meta/lib/oeqa/utils/qemurunner.py | |||
@@ -630,8 +630,12 @@ class QemuRunner: | |||
630 | # so it's possible that the file has been created but the content is empty | 630 | # so it's possible that the file has been created but the content is empty |
631 | pidfile_timeout = time.time() + 3 | 631 | pidfile_timeout = time.time() + 3 |
632 | while time.time() < pidfile_timeout: | 632 | while time.time() < pidfile_timeout: |
633 | with open(self.qemu_pidfile, 'r') as f: | 633 | try: |
634 | qemu_pid = f.read().strip() | 634 | with open(self.qemu_pidfile, 'r') as f: |
635 | qemu_pid = f.read().strip() | ||
636 | except FileNotFoundError: | ||
637 | # Can be used to detect shutdown so the pid file can disappear | ||
638 | return False | ||
635 | # file created but not yet written contents | 639 | # file created but not yet written contents |
636 | if not qemu_pid: | 640 | if not qemu_pid: |
637 | time.sleep(0.5) | 641 | time.sleep(0.5) |