On 10/28/26 11:29 PM, Philippe Mathieu-Daudé wrote:
On 28/10/26 21:36, Pierrick Bouvier wrote:
On 10/28/2026 11:25 AM, Philippe Mathieu-Daudé wrote:
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é <[email protected]>
---
   tests/guest-debug/run-test.py | 9 +++++++--
   1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index 9fdf05b55d31..e6911300e8d0 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -87,9 +87,14 @@ def format_cmd(cmd):
if "system" in args.qemu:
           # for system mode we assume qargs has set-up for binary if
-        # indeed we have set one.
+        # indeed we have set one, either ending with an option taking
+        # it (e.g. -kernel) or using the @BINARY@ placeholder.
           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"])

A bit implicit, but good for me.

Indeed; I updated the script help output:

-- >8 --
diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index e6911300e8d0..74844a64d42b 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")
---


Looks great.

Reviewed-by: Pierrick Bouvier <[email protected]>
Thanks!


Reply via email to