Skip to contentSkip to conversation

qemurunner.py: print output from runqemu/qemu-system in stop()

PATCH New Alexander Kanavin 1 participant 2 messages Aug 26, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 qemurunner.py: print output from runqemu/qemu-system in stop()

This is done when starting up qemu has failed, but is not done when qemu started ok, but fails later in QMP communication.

Output from runqemu does contain valuable information to find out why, so rather than fix all the QMP fails to include it, let's just print it in stop().

---
 meta/lib/oeqa/utils/qemurunner.py | 2 ++
 1 file changed, 2 insertions(+)
meta/lib/oeqa/utils/qemurunner.py +2 -0
index 5c9d2b24a3..204ad8b918 100644
@@ -535,6 +535,8 @@ class QemuRunner:
             if self.runqemu.poll() is None:
                 self.logger.debug("Sending SIGKILL to runqemu")
                 os.killpg(os.getpgid(self.runqemu.pid), signal.SIGKILL)
+            if not self.runqemu.stdout.closed:
+                self.logger.info("Output from runqemu:\n%s" % self.getOutput(self.runqemu.stdout))
             self.runqemu.stdin.close()
             self.runqemu.stdout.close()
             self.runqemu_exited = True
Signature · 1 line
2.31.1
#1 lore raw

PATCH 2/2 qemurunner.py: handle getOutput() having nothing to read

---
 meta/lib/oeqa/utils/qemurunner.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/lib/oeqa/utils/qemurunner.py +4 -1
index 204ad8b918..d55248c497 100644
@@ -123,7 +123,10 @@ class QemuRunner:
         import fcntl
         fl = fcntl.fcntl(o, fcntl.F_GETFL)
         fcntl.fcntl(o, fcntl.F_SETFL, fl | os.O_NONBLOCK)
-        return os.read(o.fileno(), 1000000).decode("utf-8")
+        try:
+            return os.read(o.fileno(), 1000000).decode("utf-8")
+        except BlockingIOError:
+            return ""
 
 
     def handleSIGCHLD(self, signum, frame):
Signature · 1 line
2.31.1