Skip to content

Commit

Permalink
qemudriver: export get_qemu_base_args method
Browse files Browse the repository at this point in the history
For debugging, it can be useful to start an interactive session for the
user to access the DUT console. This is possible with real targets
through labgrid-client -s STATE console, but no equivalent exists yet
for targets using QEMUDriver. Resolving that may be a bigger
undertaking, so for now, let's provide a class method
get_qemu_base_args, that returns the list of arguments sans QMP parts.

Users can then initialize labgrid as usual and call the function to
get the command line and start Qemu for interactive use without having
to duplicate the labgrid environment parsing as in [1].

[1]: https://github.com/barebox/barebox/blob/v2023.05.0/test/emulate.pl#L226

Signed-off-by: Ahmad Fatoum <[email protected]>
  • Loading branch information
a3f committed Jun 19, 2023
1 parent 758cfaf commit 318e778
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions labgrid/driver/qemudriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ def get_qemu_version(self, qemu_bin):

return (int(m.group('major')), int(m.group('minor')), int(m.group('micro')))

def on_activate(self):
self._tempdir = tempfile.mkdtemp(prefix="labgrid-qemu-tmp-")
sockpath = f"{self._tempdir}/serialrw"
self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self._socket.bind(sockpath)
self._socket.listen(0)
def get_qemu_base_args(self):
"""Returns the base command line used for Qemu without the options
related to QMP. These options can be used to start an interactive
Qemu manually for debugging tests
"""
cmd = []

qemu_bin = self.target.env.config.get_tool(self.qemu_bin)
if qemu_bin is None:
Expand Down Expand Up @@ -222,7 +222,16 @@ def on_activate(self):
cmd.append("-append")
cmd.append(" ".join(boot_args))

self._cmd = cmd
return cmd

def on_activate(self):
self._tempdir = tempfile.mkdtemp(prefix="labgrid-qemu-tmp-")
sockpath = f"{self._tempdir}/serialrw"
self._socket = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self._socket.bind(sockpath)
self._socket.listen(0)

self._cmd = self.get_qemu_base_args()

self._cmd.append("-S")
self._cmd.append("-qmp")
Expand Down

0 comments on commit 318e778

Please sign in to comment.