diff options
author | Saul Wold <Saul.Wold@windriver.com> | 2021-04-26 07:45:10 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-04-27 15:11:47 +0100 |
commit | 3acbec85b00d693d2d731bc2b09cc40be1cc68e9 (patch) | |
tree | 3b86b76cc4932ff2d9fbde194f70057a5e99079f /meta/lib/oeqa/utils/dump.py | |
parent | 2c86aba6f0eeb1fc747de2f518d1ec982398c54a (diff) | |
download | poky-3acbec85b00d693d2d731bc2b09cc40be1cc68e9.tar.gz |
qemurunner: Add support for qmp commands
This adds support for the Qemu Machine Protocol [0] extending
the current dump process for Host and Target. The commands are
added in the testimage.bbclass.
Currently, we setup qemu to stall until qmp gets connected and
sends the initialization and continue commands, this works
correctly. If the UNIX Socket does not exist, we wait an timeout
to ensure to socket file is created.
With this version, the monitor_dumper is created in OEQemuTarget
but then set in OESSHTarget as that's where we get the SSH failure
happens. Python's @property is used to create a setter/getter type
of setup in OESSHTarget to get overridden by OEQemuTarget.
By default the data is currently dumped to files for each command in
TMPDIR/log/runtime-hostdump/<date>_qmp/unknown_<seq>_qemu_monitor as
this is the naming convenstion in the dump.py code.
We use the qmp.py from qemu, which needs to get installed in the
recipe-sysroot-native of the target image.
[0] https://github.com/qemu/qemu/blob/master/docs/interop/qmp-spec.txt
(From OE-Core rev: 42af4cd2df72fc8ed9deb3fde4312909842fcf91)
Signed-off-by: Saul Wold <saul.wold@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oeqa/utils/dump.py')
-rw-r--r-- | meta/lib/oeqa/utils/dump.py | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/meta/lib/oeqa/utils/dump.py b/meta/lib/oeqa/utils/dump.py index 09a44329e0..843e19fe8a 100644 --- a/meta/lib/oeqa/utils/dump.py +++ b/meta/lib/oeqa/utils/dump.py | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | import os | 5 | import os |
6 | import sys | 6 | import sys |
7 | import json | ||
7 | import errno | 8 | import errno |
8 | import datetime | 9 | import datetime |
9 | import itertools | 10 | import itertools |
@@ -51,6 +52,8 @@ class BaseDumper(object): | |||
51 | prefix = "host" | 52 | prefix = "host" |
52 | elif isinstance(self, TargetDumper): | 53 | elif isinstance(self, TargetDumper): |
53 | prefix = "target" | 54 | prefix = "target" |
55 | elif isinstance(self, MonitorDumper): | ||
56 | prefix = "qmp" | ||
54 | else: | 57 | else: |
55 | prefix = "unknown" | 58 | prefix = "unknown" |
56 | for i in itertools.count(): | 59 | for i in itertools.count(): |
@@ -58,9 +61,12 @@ class BaseDumper(object): | |||
58 | fullname = os.path.join(self.dump_dir, filename) | 61 | fullname = os.path.join(self.dump_dir, filename) |
59 | if not os.path.exists(fullname): | 62 | if not os.path.exists(fullname): |
60 | break | 63 | break |
61 | with open(fullname, 'w') as dump_file: | 64 | if isinstance(self, MonitorDumper): |
62 | dump_file.write(output) | 65 | with open(fullname, 'w') as json_file: |
63 | 66 | json.dump(output, json_file, indent=4) | |
67 | else: | ||
68 | with open(fullname, 'w') as dump_file: | ||
69 | dump_file.write(output) | ||
64 | 70 | ||
65 | class HostDumper(BaseDumper): | 71 | class HostDumper(BaseDumper): |
66 | """ Class to get dumps from the host running the tests """ | 72 | """ Class to get dumps from the host running the tests """ |
@@ -96,3 +102,23 @@ class TargetDumper(BaseDumper): | |||
96 | except: | 102 | except: |
97 | print("Tried to dump info from target but " | 103 | print("Tried to dump info from target but " |
98 | "serial console failed") | 104 | "serial console failed") |
105 | print("Failed CMD: %s" % (cmd)) | ||
106 | |||
107 | class MonitorDumper(BaseDumper): | ||
108 | """ Class to get dumps via the Qemu Monitor, it only works with QemuRunner """ | ||
109 | |||
110 | def __init__(self, cmds, parent_dir, runner): | ||
111 | super(MonitorDumper, self).__init__(cmds, parent_dir) | ||
112 | self.runner = runner | ||
113 | |||
114 | def dump_monitor(self, dump_dir=""): | ||
115 | if self.runner is None: | ||
116 | return | ||
117 | if dump_dir: | ||
118 | self.dump_dir = dump_dir | ||
119 | for cmd in self.cmds: | ||
120 | try: | ||
121 | output = self.runner.run_monitor(cmd) | ||
122 | self._write_dump(cmd, output) | ||
123 | except: | ||
124 | print("Failed to dump QMP CMD: %s" % (cmd)) | ||