summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-09 00:07:05 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-08-09 00:13:58 -0700
commit37e78463e58c374ba2ff933acfc4441cbb666c1f (patch)
treeaaade670d71ebbf3aade9d779c502067ea56b81a /meta
parent0968e3a68b0b06caeb827938ddf556f21bfce646 (diff)
downloadpoky-37e78463e58c374ba2ff933acfc4441cbb666c1f.tar.gz
oeqa/qemurunner: Improve runqemu log output debug
If runqemu fails, ensure the log output is shown as its invaluable to aid debugging. Its slightly convoluted since we need to ensure we don't block on reading the pipe which may still be executing hence the need for nonblocking IO. (From OE-Core rev: 0e0fa1461863ec586b4f028dfd7d641f091ea928) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oeqa/utils/qemurunner.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/meta/lib/oeqa/utils/qemurunner.py b/meta/lib/oeqa/utils/qemurunner.py
index 02ac89c142..9bb1f4bb2d 100644
--- a/meta/lib/oeqa/utils/qemurunner.py
+++ b/meta/lib/oeqa/utils/qemurunner.py
@@ -94,12 +94,19 @@ class QemuRunner:
94 if qemuparams: 94 if qemuparams:
95 self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"' 95 self.qemuparams = self.qemuparams[:-1] + " " + qemuparams + " " + '\"'
96 96
97 def getOutput(o):
98 import fcntl
99 fl = fcntl.fcntl(o, fcntl.F_GETFL)
100 fcntl.fcntl(o, fcntl.F_SETFL, fl | os.O_NONBLOCK)
101 return os.read(o.fileno(), 1000000)
102
97 launch_cmd = 'runqemu %s %s %s' % (self.machine, self.rootfs, self.qemuparams) 103 launch_cmd = 'runqemu %s %s %s' % (self.machine, self.rootfs, self.qemuparams)
98 # FIXME: We pass in stdin=subprocess.PIPE here to work around stty 104 # FIXME: We pass in stdin=subprocess.PIPE here to work around stty
99 # blocking at the end of the runqemu script when using this within 105 # blocking at the end of the runqemu script when using this within
100 # oe-selftest (this makes stty error out immediately). There ought 106 # oe-selftest (this makes stty error out immediately). There ought
101 # to be a proper fix but this will suffice for now. 107 # to be a proper fix but this will suffice for now.
102 self.runqemu = subprocess.Popen(launch_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, preexec_fn=os.setpgrp) 108 self.runqemu = subprocess.Popen(launch_cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, stdin=subprocess.PIPE, preexec_fn=os.setpgrp)
109 output = self.runqemu.stdout
103 110
104 logger.info("runqemu started, pid is %s" % self.runqemu.pid) 111 logger.info("runqemu started, pid is %s" % self.runqemu.pid)
105 logger.info("waiting at most %s seconds for qemu pid" % self.runqemutime) 112 logger.info("waiting at most %s seconds for qemu pid" % self.runqemutime)
@@ -109,9 +116,8 @@ class QemuRunner:
109 if self.runqemu.returncode: 116 if self.runqemu.returncode:
110 # No point waiting any longer 117 # No point waiting any longer
111 logger.info('runqemu exited with code %d' % self.runqemu.returncode) 118 logger.info('runqemu exited with code %d' % self.runqemu.returncode)
112 output = self.runqemu.stdout
113 self.stop() 119 self.stop()
114 logger.info("Output from runqemu:\n%s" % output.read()) 120 logger.info("Output from runqemu:\n%s" % getOutput(output))
115 return False 121 return False
116 time.sleep(1) 122 time.sleep(1)
117 123
@@ -128,7 +134,7 @@ class QemuRunner:
128 self.ip = ips[0] 134 self.ip = ips[0]
129 self.server_ip = ips[1] 135 self.server_ip = ips[1]
130 except IndexError, ValueError: 136 except IndexError, ValueError:
131 logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used: %s" % cmdline) 137 logger.info("Couldn't get ip from qemu process arguments! Here is the qemu command line used:\n%s\nand output from runqemu:\n%s" % (cmdline, getOutput(output)))
132 self.stop() 138 self.stop()
133 return False 139 return False
134 logger.info("Target IP: %s" % self.ip) 140 logger.info("Target IP: %s" % self.ip)
@@ -170,9 +176,8 @@ class QemuRunner:
170 return False 176 return False
171 else: 177 else:
172 logger.info("Qemu pid didn't appeared in %s seconds" % self.runqemutime) 178 logger.info("Qemu pid didn't appeared in %s seconds" % self.runqemutime)
173 output = self.runqemu.stdout
174 self.stop() 179 self.stop()
175 logger.info("Output from runqemu:\n%s" % output.read()) 180 logger.info("Output from runqemu:\n%s" % getOutput(output))
176 return False 181 return False
177 182
178 return self.is_alive() 183 return self.is_alive()