qemurunner: print tail qemu log in case bootlog is empty

There are cases where the 'while loop' waiting for login prompt fails
and the bootlog variable does not get populated, thus use the the new
qemurunner member (self.msg) which stores all output coming from the qemu
process.

[YOCTO #12113]

(From OE-Core rev: 39ffa0f3779305c5e8ef86fe4572e961c5912021)

(From OE-Core rev: 40f9f0358184660f23ac7b5fc3e477e2c54e21bc)

Signed-off-by: Leonardo Sandoval <leonardo.sandoval.gonzalez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Leonardo Sandoval 2017-09-22 16:05:41 -07:00 committed by Richard Purdie
parent dd79b50980
commit 9e036b011e
1 changed files with 6 additions and 1 deletions

View File

@ -51,6 +51,7 @@ class QemuRunner:
self.logged = False self.logged = False
self.thread = None self.thread = None
self.use_kvm = use_kvm self.use_kvm = use_kvm
self.msg = ''
self.runqemutime = 120 self.runqemutime = 120
self.qemu_pidfile = 'pidfile_'+str(os.getpid()) self.qemu_pidfile = 'pidfile_'+str(os.getpid())
@ -79,6 +80,7 @@ class QemuRunner:
# because is possible to have control characters # because is possible to have control characters
msg = msg.decode("utf-8", errors='ignore') msg = msg.decode("utf-8", errors='ignore')
msg = re_control_char.sub('', msg) msg = re_control_char.sub('', msg)
self.msg += msg
with codecs.open(self.logfile, "a", encoding="utf-8") as f: with codecs.open(self.logfile, "a", encoding="utf-8") as f:
f.write("%s" % msg) f.write("%s" % msg)
@ -306,9 +308,12 @@ class QemuRunner:
sock.close() sock.close()
stopread = True stopread = True
if not reachedlogin: if not reachedlogin:
self.logger.info("Target didn't reached login boot in %d seconds" % self.boottime) self.logger.info("Target didn't reached login boot in %d seconds" % self.boottime)
lines = "\n".join(bootlog.splitlines()[-25:]) tail = lambda l: "\n".join(l.splitlines()[-25:])
# in case bootlog is empty, use tail qemu log store at self.msg
lines = tail(bootlog if bootlog else self.msg)
self.logger.info("Last 25 lines of text:\n%s" % lines) self.logger.info("Last 25 lines of text:\n%s" % lines)
self.logger.info("Check full boot log: %s" % self.logfile) self.logger.info("Check full boot log: %s" % self.logfile)
self._dump_host() self._dump_host()