python/qemu: dump a developer friendly version of cmdline to logs

Now we have the arguments nicely split up we can make _console_args a
function call and present a slightly different version to the logs to
save developers manually hacking the command line up.

Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20260619155657.944220-4-alex.bennee@linaro.org>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
This commit is contained in:
Alex Bennée
2026-06-19 16:56:52 +01:00
parent 1c09090b48
commit f0e0f43879

View File

@@ -308,12 +308,15 @@ class QEMUMachine:
'chardev=mon,mode=control'])
return args
@property
def _console_args(self) -> List[str]:
def _console_args(self, interactive: bool = False) -> List[str]:
args: List[str] = []
# redirect pre_console_index serials to null
for _ in range(self._console_index):
args.extend(['-serial', 'null'])
if self._console_set:
if interactive:
args.extend(['-serial', 'mon:stdio'])
elif self._console_set:
assert self._cons_sock_pair is not None
fd = self._cons_sock_pair[0].fileno()
chardev = f"socket,id=console,fd={fd}"
@@ -376,7 +379,7 @@ class QEMUMachine:
self._wrapper,
[self._binary],
self._harness_args,
self._console_args,
self._console_args(),
self._base_args,
self._args
))
@@ -485,6 +488,14 @@ class QEMUMachine:
"""
self._pre_launch()
LOG.debug('VM launch command: %r', ' '.join(self._qemu_full_args))
# Log a simplified, developer-runnable command:
# Exclude harness-managed infrastructure args (harness_args)
# and wrapper.
debug_cmd = [self._binary]
debug_cmd.extend(self._console_args(interactive=True))
debug_cmd.extend(self._base_args)
debug_cmd.extend(self._args)
LOG.debug('Developer-runnable command: %r', ' '.join(debug_cmd))
# Cleaning up of this subprocess is guaranteed by _do_shutdown.
# pylint: disable=consider-using-with