mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
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>
This commit is contained in:
committed by
Richard Purdie
parent
2c86aba6f0
commit
3acbec85b0
@@ -4,6 +4,7 @@
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
import errno
|
||||
import datetime
|
||||
import itertools
|
||||
@@ -51,6 +52,8 @@ class BaseDumper(object):
|
||||
prefix = "host"
|
||||
elif isinstance(self, TargetDumper):
|
||||
prefix = "target"
|
||||
elif isinstance(self, MonitorDumper):
|
||||
prefix = "qmp"
|
||||
else:
|
||||
prefix = "unknown"
|
||||
for i in itertools.count():
|
||||
@@ -58,9 +61,12 @@ class BaseDumper(object):
|
||||
fullname = os.path.join(self.dump_dir, filename)
|
||||
if not os.path.exists(fullname):
|
||||
break
|
||||
with open(fullname, 'w') as dump_file:
|
||||
dump_file.write(output)
|
||||
|
||||
if isinstance(self, MonitorDumper):
|
||||
with open(fullname, 'w') as json_file:
|
||||
json.dump(output, json_file, indent=4)
|
||||
else:
|
||||
with open(fullname, 'w') as dump_file:
|
||||
dump_file.write(output)
|
||||
|
||||
class HostDumper(BaseDumper):
|
||||
""" Class to get dumps from the host running the tests """
|
||||
@@ -96,3 +102,23 @@ class TargetDumper(BaseDumper):
|
||||
except:
|
||||
print("Tried to dump info from target but "
|
||||
"serial console failed")
|
||||
print("Failed CMD: %s" % (cmd))
|
||||
|
||||
class MonitorDumper(BaseDumper):
|
||||
""" Class to get dumps via the Qemu Monitor, it only works with QemuRunner """
|
||||
|
||||
def __init__(self, cmds, parent_dir, runner):
|
||||
super(MonitorDumper, self).__init__(cmds, parent_dir)
|
||||
self.runner = runner
|
||||
|
||||
def dump_monitor(self, dump_dir=""):
|
||||
if self.runner is None:
|
||||
return
|
||||
if dump_dir:
|
||||
self.dump_dir = dump_dir
|
||||
for cmd in self.cmds:
|
||||
try:
|
||||
output = self.runner.run_monitor(cmd)
|
||||
self._write_dump(cmd, output)
|
||||
except:
|
||||
print("Failed to dump QMP CMD: %s" % (cmd))
|
||||
|
||||
Reference in New Issue
Block a user