diff options
Diffstat (limited to 'meta')
-rw-r--r-- | meta/lib/oeqa/core/target/qemu.py | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/meta/lib/oeqa/core/target/qemu.py b/meta/lib/oeqa/core/target/qemu.py index 4a5df4a9a8..79fd724f7d 100644 --- a/meta/lib/oeqa/core/target/qemu.py +++ b/meta/lib/oeqa/core/target/qemu.py | |||
@@ -8,6 +8,8 @@ import os | |||
8 | import sys | 8 | import sys |
9 | import signal | 9 | import signal |
10 | import time | 10 | import time |
11 | import glob | ||
12 | import subprocess | ||
11 | from collections import defaultdict | 13 | from collections import defaultdict |
12 | 14 | ||
13 | from .ssh import OESSHTarget | 15 | from .ssh import OESSHTarget |
@@ -36,6 +38,8 @@ class OEQemuTarget(OESSHTarget): | |||
36 | self.ovmf = ovmf | 38 | self.ovmf = ovmf |
37 | self.use_slirp = slirp | 39 | self.use_slirp = slirp |
38 | self.boot_patterns = boot_patterns | 40 | self.boot_patterns = boot_patterns |
41 | self.dump_dir = dump_dir | ||
42 | self.bootlog = bootlog | ||
39 | 43 | ||
40 | self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir, | 44 | self.runner = QemuRunner(machine=machine, rootfs=rootfs, tmpdir=tmpdir, |
41 | deploy_dir_image=dir_image, display=display, | 45 | deploy_dir_image=dir_image, display=display, |
@@ -74,7 +78,28 @@ class OEQemuTarget(OESSHTarget): | |||
74 | self.server_ip = self.runner.server_ip | 78 | self.server_ip = self.runner.server_ip |
75 | else: | 79 | else: |
76 | self.stop() | 80 | self.stop() |
77 | raise RuntimeError("FAILED to start qemu - check the task log and the boot log") | 81 | # Display the first 20 lines of top and |
82 | # last 20 lines of the bootlog when the | ||
83 | # target is not being booted up. | ||
84 | topfile = glob.glob(self.dump_dir + "/*_qemu/host_*_top") | ||
85 | msg = "\n\n===== start: snippet =====\n\n" | ||
86 | for f in topfile: | ||
87 | msg += "file: %s\n\n" % f | ||
88 | with open(f) as tf: | ||
89 | for x in range(20): | ||
90 | msg += next(tf) | ||
91 | msg += "\n\n===== end: snippet =====\n\n" | ||
92 | blcmd = ["tail", "-20", self.bootlog] | ||
93 | msg += "===== start: snippet =====\n\n" | ||
94 | try: | ||
95 | out = subprocess.check_output(blcmd, stderr=subprocess.STDOUT, timeout=1).decode('utf-8') | ||
96 | msg += "file: %s\n\n" % self.bootlog | ||
97 | msg += out | ||
98 | except (subprocess.CalledProcessError, subprocess.TimeoutExpired, FileNotFoundError) as err: | ||
99 | msg += "Error running command: %s\n%s\n" % (blcmd, err) | ||
100 | msg += "\n\n===== end: snippet =====\n" | ||
101 | |||
102 | raise RuntimeError("FAILED to start qemu - check the task log and the boot log %s" % (msg)) | ||
78 | 103 | ||
79 | def stop(self): | 104 | def stop(self): |
80 | self.runner.stop() | 105 | self.runner.stop() |