Skip to contentSkip to conversation

qemurunner: Ensure pid location is deterministic

PATCH New Richard Purdie 1 participant 2 messages Jul 12, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 qemurunner: Ensure pid location is deterministic

The pid location could vary due to changes in cwd as only a filename is specified, not a full path. This in theory could be resulting in some of our autobuilder failures. Whilst its difficult to know if this is causing a problem, Using a full path removes any question of such an issue.

---
 meta/lib/oeqa/utils/qemurunner.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
meta/lib/oeqa/utils/qemurunner.py +4 -2
index 992fff9370a..486d2bb8932 100644
@@ -32,7 +32,7 @@ re_control_char = re.compile('[%s]' % re.escape("".join(control_chars)))
 class QemuRunner:
 
     def __init__(self, machine, rootfs, display, tmpdir, deploy_dir_image, logfile, boottime, dump_dir, dump_host_cmds,
-                 use_kvm, logger, use_slirp=False, serial_ports=2, boot_patterns = defaultdict(str), use_ovmf=False):
+                 use_kvm, logger, use_slirp=False, serial_ports=2, boot_patterns = defaultdict(str), use_ovmf=False, workdir=None):
 
         # Popen object for runqemu
         self.runqemu = None
@@ -63,7 +63,9 @@ class QemuRunner:
         self.boot_patterns = boot_patterns
 
         self.runqemutime = 120
-        self.qemu_pidfile = 'pidfile_'+str(os.getpid())
+        if not workdir:
+            workdir = os.getcwd()
+        self.qemu_pidfile = workdir + '/pidfile_' + str(os.getpid())
         self.host_dumper = HostDumper(dump_host_cmds, dump_dir)
         self.monitorpipe = None
 
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/2 qemurunner: Add extra debug info when qemu fails to start

When qemu fails to start we're struggling to work out why. Add more debug info which can at least confirm/rule out various things.

This code is only on the error handling path and more info shoudl help us debug issues.

---
 meta/lib/oeqa/utils/qemurunner.py | 9 +++++++++
 1 file changed, 9 insertions(+)
meta/lib/oeqa/utils/qemurunner.py +9 -0
index 486d2bb8932..41c6bb33d62 100644
@@ -254,6 +254,15 @@ class QemuRunner:
         if not self.is_alive():
             self.logger.error("Qemu pid didn't appear in %s seconds (%s)" %
                               (self.runqemutime, time.strftime("%D %H:%M:%S")))
+
+            qemu_pid = None
+            if os.path.isfile(self.qemu_pidfile):
+                with open(self.qemu_pidfile, 'r') as f:
+                    qemu_pid = f.read().strip()
+
+            self.logger.error("Status information, poll status: %s, pidfile exists: %s, pidfile contents %s, proc pid exists %s"
+                % (self.runqemu.poll(), os.path.isfile(self.qemu_pidfile), str(qemu_pid), os.path.exists("/proc/" + qemu_pid)))
+
             # Dump all processes to help us to figure out what is going on...
             ps = subprocess.Popen(['ps', 'axww', '-o', 'pid,ppid,command '], stdout=subprocess.PIPE).communicate()[0]
             processes = ps.decode("utf-8")
Signature · 1 line
2.25.1