Commit bcccbdb9c6 for qemu.org
commit bcccbdb9c6eecf437b8fa769a2d9e9b3d15b0291
Author: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Date: Wed Oct 28 20:25:31 2026 +0100
tests/guest-debug: Allow placing the binary within system QEMU args
In system mode the binary is appended to the QEMU arguments, which
must end with an option taking it, such as -kernel. Machines without
-kernel, like 'none', load it with the generic loader device, where
the path is part of an option value.
Replace @BINARY@ in the arguments by the binary path if present,
otherwise keep appending it.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Message-ID: <20261028192538.31600-4-philmd@oss.qualcomm.com>
diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index 9fdf05b55d..74844a64d4 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -23,7 +23,12 @@ def get_args():
parser = argparse.ArgumentParser(description="A gdbstub test runner")
parser.add_argument("--qemu", help="Qemu binary for test",
required=True)
- parser.add_argument("--qargs", help="Qemu arguments for test")
+ parser.add_argument("--qargs",
+ help="Qemu arguments for test. In system mode, "
+ "@BINARY@ is replaced by the --binary path; "
+ "without it the path is appended last "
+ "(so qargs must end with an option taking "
+ "it, e.g. -kernel)")
parser.add_argument("--pargs", help="Program arguments for test")
parser.add_argument("--kargs", help="Kernel args to --append")
parser.add_argument("--binary", help="Binary to debug")
@@ -86,10 +91,17 @@ def format_cmd(cmd):
qemu_cmd.extend(shlex.split(args.qargs))
if "system" in args.qemu:
- # for system mode we assume qargs has set-up for binary if
- # indeed we have set one.
+ # In system mode the binary is passed to QEMU one of two ways:
+ # - qargs contains @BINARY@ (e.g. "-device loader,file=@BINARY@"):
+ # substitute the binary path there;
+ # - otherwise qargs must end with an option taking a filename
+ # (e.g. -kernel): append the binary path.
if args.binary:
- qemu_cmd.append(args.binary)
+ if any("@BINARY@" in arg for arg in qemu_cmd):
+ qemu_cmd = [arg.replace("@BINARY@", args.binary)
+ for arg in qemu_cmd]
+ else:
+ qemu_cmd.append(args.binary)
if not args.no_suspend:
qemu_cmd.append("-S")
qemu_cmd.extend(["-gdb", f"unix:path={socket_name},server=on"])