qemurunner: add support for qmp cmds
RFC PATCH 1/1 qemurunner: add support for qmp cmds
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.
Current issues: getting the monitor_dump() to work correctly when a failure occurs. I saw this work once or twice, but now I seem to be stuck with not getting the monitor_dump() running in my debug environment. Probably something stupid.
[0] https://github.com/qemu/qemu/blob/master/docs/interop/qmp-spec.txt
--- meta/classes/testimage.bbclass | 6 +++ meta/lib/oeqa/core/target/qemu.py | 4 ++ meta/lib/oeqa/core/target/ssh.py | 12 ++++-- meta/lib/oeqa/targetcontrol.py | 5 +++ meta/lib/oeqa/utils/dump.py | 24 +++++++++++ meta/lib/oeqa/utils/qemurunner.py | 70 ++++++++++++++++++++++++++++++- 6 files changed, 117 insertions(+), 4 deletions(-)
meta/classes/testimage.bbclass +6 -0
@@ -127,6 +127,11 @@ testimage_dump_host () { netstat -an } +testimage_dump_monitor () { + '{"execute":"query-status"}\n' + '{"execute":"query-block"}\n' +} + python do_testimage() { testimage_main(d) }
@@ -319,6 +324,7 @@ def testimage_main(d): target_kwargs['powercontrol_extra_args'] = d.getVar("TEST_POWERCONTROL_EXTRA_ARGS") or "" target_kwargs['serialcontrol_cmd'] = d.getVar("TEST_SERIALCONTROL_CMD") or None target_kwargs['serialcontrol_extra_args'] = d.getVar("TEST_SERIALCONTROL_EXTRA_ARGS") or "" + target_kwargs['testimage_dump_monitor'] = d.getVar("testimage_dump_monitor") or "" target_kwargs['testimage_dump_target'] = d.getVar("testimage_dump_target") or "" def export_ssh_agent(d):
meta/lib/oeqa/core/target/qemu.py +4 -0
@@ -12,6 +12,7 @@ from collections import defaultdict from .ssh import OESSHTarget from oeqa.utils.qemurunner import QemuRunner +from oeqa.utils.dump import MonitorDumper from oeqa.utils.dump import TargetDumper supported_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic']
@@ -43,6 +44,9 @@ class OEQemuTarget(OESSHTarget): dump_host_cmds=dump_host_cmds, logger=logger, serial_ports=serial_ports, boot_patterns = boot_patterns, use_ovmf=ovmf) + dump_monitor_cmds = kwargs.get("testimage_dump_monitor") + self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner) + self.logger.debug("sgw2 monitor: %s" % self.monitor_dumper) dump_target_cmds = kwargs.get("testimage_dump_target") self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) self.target_dumper.create_dir("qemu")
meta/lib/oeqa/core/target/ssh.py +9 -3
@@ -54,13 +54,17 @@ class OESSHTarget(OETarget): """ Runs command in target using SSHProcess. """ - self.logger.debug("[Running]$ %s" % " ".join(command)) + self.logger.debug("sgw-[Running]$ %s" % " ".join(command)) starttime = time.time() status, output = SSHCall(command, self.logger, timeout) self.logger.debug("[Command returned '%d' after %.2f seconds]" "" % (status, time.time() - starttime)) + self.logger.debug('sgw-Monitor Calling Dump') + self.logger.debug("sgw4 monitor: %s" % self.monitor_dumper) + self.monitor_dumper.dump_monitor() + self.logger.debug('sgw-Monitor Calling Dump returned') if status and not ignore_status: raise AssertionError("Command '%s' returned non-zero exit " "status %d:\n%s" % (command, status, output))
@@ -87,9 +91,11 @@ class OESSHTarget(OETarget): processTimeout = self.timeout status, output = self._run(sshCmd, processTimeout, True) - self.logger.debug('Command: %s\nOutput: %s\n' % (command, output)) - if (status == 255) and (('No route to host') in output): + self.logger.debug('Command: %s\nStatus: %d Output: %s\n' % (command, status, output)) +# if (status == 255) and (('No route to host') in output): + if status == 255: self.target_dumper.dump_target() + self.monitor_dumper.dump_monitor() return (status, output) def copyTo(self, localSrc, remoteDst):
meta/lib/oeqa/targetcontrol.py +5 -0
@@ -17,6 +17,7 @@ from oeqa.utils.sshcontrol import SSHControl from oeqa.utils.qemurunner import QemuRunner from oeqa.utils.qemutinyrunner import QemuTinyRunner from oeqa.utils.dump import TargetDumper +from oeqa.utils.dump import MonitorDumper from oeqa.controllers.testtargetloader import TestTargetLoader from abc import ABCMeta, abstractmethod
@@ -108,6 +109,7 @@ class QemuTarget(BaseTarget): self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) dump_target_cmds = d.getVar("testimage_dump_target") dump_host_cmds = d.getVar("testimage_dump_host") + dump_monitor_cmds = d.getVar("testimage_dump_monitor") dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") if not dump_dir: dump_dir = os.path.join(d.getVar('LOG_DIR'), 'runtime-hostdump')
@@ -147,6 +149,9 @@ class QemuTarget(BaseTarget): serial_ports = len(d.getVar("SERIAL_CONSOLES").split())) self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) + self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner) + self.logger.debug("sgw monitor: %s" % self.monitor_dumper) + def deploy(self): bb.utils.mkdirhier(self.testdir)
meta/lib/oeqa/utils/dump.py +24 -0
@@ -96,3 +96,27 @@ 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=""): + print("Monitor Dumping: %s" % self.cmds) + print("Dump dir: %s" % dump_dir) + if dump_dir: + self.dump_dir = dump_dir + for cmd in self.cmds: + try: + print("dump_target: %s" % cmd) + output = self.runner.run_monitor(cmd) + print("result: %s" % (output)) + self._write_dump("qemu_monitor", output) + except: + print("Failed to dump montor data") + print("Failed CMD: %s" % (cmd)) +
meta/lib/oeqa/utils/qemurunner.py +69 -1
128 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH 1/1 qemurunner: add support for qmp cmds
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.
Current issues: getting the monitor_dump() to work correctly when a failure occurs. I saw this work once or twice, but now I seem to be stuck with not getting the monitor_dump() running in my debug environment. Probably something stupid.
[0] https://github.com/qemu/qemu/blob/master/docs/interop/qmp-spec.txt
--- meta/classes/testimage.bbclass | 6 +++ meta/lib/oeqa/core/target/qemu.py | 4 ++ meta/lib/oeqa/core/target/ssh.py | 12 ++++-- meta/lib/oeqa/targetcontrol.py | 5 +++ meta/lib/oeqa/utils/dump.py | 24 +++++++++++ meta/lib/oeqa/utils/qemurunner.py | 70 ++++++++++++++++++++++++++++++- 6 files changed, 117 insertions(+), 4 deletions(-)
meta/classes/testimage.bbclass +6 -0
@@ -127,6 +127,11 @@ testimage_dump_host () { netstat -an } +testimage_dump_monitor () { + '{"execute":"query-status"}\n' + '{"execute":"query-block"}\n' +} + python do_testimage() { testimage_main(d) }
@@ -319,6 +324,7 @@ def testimage_main(d): target_kwargs['powercontrol_extra_args'] = d.getVar("TEST_POWERCONTROL_EXTRA_ARGS") or "" target_kwargs['serialcontrol_cmd'] = d.getVar("TEST_SERIALCONTROL_CMD") or None target_kwargs['serialcontrol_extra_args'] = d.getVar("TEST_SERIALCONTROL_EXTRA_ARGS") or "" + target_kwargs['testimage_dump_monitor'] = d.getVar("testimage_dump_monitor") or "" target_kwargs['testimage_dump_target'] = d.getVar("testimage_dump_target") or "" def export_ssh_agent(d):
meta/lib/oeqa/core/target/qemu.py +4 -0
@@ -12,6 +12,7 @@ from collections import defaultdict from .ssh import OESSHTarget from oeqa.utils.qemurunner import QemuRunner +from oeqa.utils.dump import MonitorDumper from oeqa.utils.dump import TargetDumper supported_fstypes = ['ext3', 'ext4', 'cpio.gz', 'wic']
@@ -43,6 +44,9 @@ class OEQemuTarget(OESSHTarget): dump_host_cmds=dump_host_cmds, logger=logger, serial_ports=serial_ports, boot_patterns = boot_patterns, use_ovmf=ovmf) + dump_monitor_cmds = kwargs.get("testimage_dump_monitor") + self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner) + self.logger.debug("sgw2 monitor: %s" % self.monitor_dumper) dump_target_cmds = kwargs.get("testimage_dump_target") self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) self.target_dumper.create_dir("qemu")
meta/lib/oeqa/core/target/ssh.py +9 -3
@@ -54,13 +54,17 @@ class OESSHTarget(OETarget): """ Runs command in target using SSHProcess. """ - self.logger.debug("[Running]$ %s" % " ".join(command)) + self.logger.debug("sgw-[Running]$ %s" % " ".join(command)) starttime = time.time() status, output = SSHCall(command, self.logger, timeout) self.logger.debug("[Command returned '%d' after %.2f seconds]" "" % (status, time.time() - starttime)) + self.logger.debug('sgw-Monitor Calling Dump') + self.logger.debug("sgw4 monitor: %s" % self.monitor_dumper) + self.monitor_dumper.dump_monitor() + self.logger.debug('sgw-Monitor Calling Dump returned') if status and not ignore_status: raise AssertionError("Command '%s' returned non-zero exit " "status %d:\n%s" % (command, status, output))
@@ -87,9 +91,11 @@ class OESSHTarget(OETarget): processTimeout = self.timeout status, output = self._run(sshCmd, processTimeout, True) - self.logger.debug('Command: %s\nOutput: %s\n' % (command, output)) - if (status == 255) and (('No route to host') in output): + self.logger.debug('Command: %s\nStatus: %d Output: %s\n' % (command, status, output)) +# if (status == 255) and (('No route to host') in output): + if status == 255: self.target_dumper.dump_target() + self.monitor_dumper.dump_monitor() return (status, output) def copyTo(self, localSrc, remoteDst):
meta/lib/oeqa/targetcontrol.py +5 -0
@@ -17,6 +17,7 @@ from oeqa.utils.sshcontrol import SSHControl from oeqa.utils.qemurunner import QemuRunner from oeqa.utils.qemutinyrunner import QemuTinyRunner from oeqa.utils.dump import TargetDumper +from oeqa.utils.dump import MonitorDumper from oeqa.controllers.testtargetloader import TestTargetLoader from abc import ABCMeta, abstractmethod
@@ -108,6 +109,7 @@ class QemuTarget(BaseTarget): self.qemulog = os.path.join(self.testdir, "qemu_boot_log.%s" % self.datetime) dump_target_cmds = d.getVar("testimage_dump_target") dump_host_cmds = d.getVar("testimage_dump_host") + dump_monitor_cmds = d.getVar("testimage_dump_monitor") dump_dir = d.getVar("TESTIMAGE_DUMP_DIR") if not dump_dir: dump_dir = os.path.join(d.getVar('LOG_DIR'), 'runtime-hostdump')
@@ -147,6 +149,9 @@ class QemuTarget(BaseTarget): serial_ports = len(d.getVar("SERIAL_CONSOLES").split())) self.target_dumper = TargetDumper(dump_target_cmds, dump_dir, self.runner) + self.monitor_dumper = MonitorDumper(dump_monitor_cmds, dump_dir, self.runner) + self.logger.debug("sgw monitor: %s" % self.monitor_dumper) + def deploy(self): bb.utils.mkdirhier(self.testdir)
meta/lib/oeqa/utils/dump.py +24 -0
@@ -96,3 +96,27 @@ 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=""): + print("Monitor Dumping: %s" % self.cmds) + print("Dump dir: %s" % dump_dir) + if dump_dir: + self.dump_dir = dump_dir + for cmd in self.cmds: + try: + print("dump_target: %s" % cmd) + output = self.runner.run_monitor(cmd) + print("result: %s" % (output)) + self._write_dump("qemu_monitor", output) + except: + print("Failed to dump montor data") + print("Failed CMD: %s" % (cmd)) +
meta/lib/oeqa/utils/qemurunner.py +69 -1
128 lines not on this page · raw message
Signature · 1 line
2.25.1