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]

Signed-off-by: Richard Purdie <richard.pur...@linuxfoundation.org>
---
 meta/lib/oeqa/utils/qemurunner.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/meta/lib/oeqa/utils/qemurunner.py 
b/meta/lib/oeqa/utils/qemurunner.py
index 7273bbc3dbf..277cd328484 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -630,8 +630,12 @@ class QemuRunner:
             # so it's possible that the file has been created but the content 
is empty
             pidfile_timeout = time.time() + 3
             while time.time() < pidfile_timeout:
-                with open(self.qemu_pidfile, 'r') as f:
-                    qemu_pid = f.read().strip()
+                try:
+                    with open(self.qemu_pidfile, 'r') as f:
+                        qemu_pid = f.read().strip()
+                except FileNotFoundError:
+                    # Can be used to detect shutdown so the pid file can 
disappear
+                    return False
                 # file created but not yet written contents
                 if not qemu_pid:
                     time.sleep(0.5)
-- 
2.40.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#194407): 
https://lists.openembedded.org/g/openembedded-core/message/194407
Mute This Topic: https://lists.openembedded.org/mt/103987213/21656
Group Owner: openembedded-core+ow...@lists.openembedded.org
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to