summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py21
1 files changed, 14 insertions, 7 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index c16227fc38..68684aeb8a 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -425,13 +425,20 @@ class QemuRunner:
425 if not self.runqemu or self.runqemu.poll() is not None: 425 if not self.runqemu or self.runqemu.poll() is not None:
426 return False 426 return False
427 if os.path.isfile(self.qemu_pidfile): 427 if os.path.isfile(self.qemu_pidfile):
428 f = open(self.qemu_pidfile, 'r') 428 # when handling pidfile, qemu creates the file, stat it, lock it and then write to it
429 qemu_pid = f.read() 429 # so it's possible that the file has been created but the content is empty
430 f.close() 430 pidfile_timeout = time.time() + 3
431 qemupid = int(qemu_pid) 431 while time.time() < pidfile_timeout:
432 if os.path.exists("/proc/" + str(qemupid)): 432 with open(self.qemu_pidfile, 'r') as f:
433 self.qemupid = qemupid 433 qemu_pid = f.read().strip()
434 return True 434 # file created but not yet written contents
435 if not qemu_pid:
436 time.sleep(0.5)
437 continue
438 else:
439 if os.path.exists("/proc/" + qemu_pid):
440 self.qemupid = int(qemu_pid)
441 return True
435 return False 442 return False
436 443
437 def run_serial(self, command, raw=False, timeout=60): 444 def run_serial(self, command, raw=False, timeout=60):