]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
oeqa/qemurunner: Handle rare shutdown race
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Fri, 26 Jan 2024 22:52:26 +0000 (22:52 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Tue, 30 Jan 2024 15:15:26 +0000 (15:15 +0000)
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.purdie@linuxfoundation.org>
meta/lib/oeqa/utils/qemurunner.py

index 7273bbc3dbf180b27c8959a5992dfe1c6ca5a73c..277cd328484eb9ff269d556a288f720e4102a17a 100644 (file)
@@ -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)