On 10/12/26 19:03, Alex Bennée wrote:
When passing kernel arguments to QEMU with --append we need to take
care that things are properly escaped. It's easier if we get the run
script to do it for us that constructed the nested escaped --qargs.

Reviewed-by: Marc-André Lureau <[email protected]>
Message-ID: <[email protected]>
Signed-off-by: Alex Bennée <[email protected]>
---
  tests/guest-debug/run-test.py | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/tests/guest-debug/run-test.py b/tests/guest-debug/run-test.py
index 838c1c26971..4aa24939b7d 100755
--- a/tests/guest-debug/run-test.py
+++ b/tests/guest-debug/run-test.py
@@ -25,6 +25,7 @@ def get_args():
                          required=True)
      parser.add_argument("--qargs", help="Qemu arguments for test")
      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",
                          required=True)
      parser.add_argument("--test", help="GDB test script")
@@ -82,6 +83,8 @@ def log(output, msg):
              suspend = ' -S'
          cmd = f'{args.qemu} {args.qargs} {args.binary}' \
              f'{suspend} -gdb unix:path={socket_name},server=on'
+        if args.kargs:
+            cmd += f" --append '{args.kargs}'"

Wouldn't it be better to use shlex.quote()?
It would handle kargs containing single quotes correctly.

Reply via email to