• Bug#1104459: autopkgtest-virt-qemu: cannot pass "-append" in "--qemu-op

    From Isaac True@21:1/5 to All on Wed Apr 30 16:50:02 2025
    Package: autopkgtest
    Version: 5.28
    Severity: normal
    X-Debbugs-Cc: isaac@is.having.coffee

    I want to pass additional kernel command line arguments to QEMU using the "-append" argument (the image is being booted with "-kernel" and "-initrd", so I cannot pass additional arguments using the bootloader), using the "--qemu-option" argument. E.g:

    autopkgtest bash -- qemu --qemu-options "-append 'root=/dev/vda init=/sbin/init plus additional parameters' -kernel /boot/vmlinuz -initrd /boot/initrd.img" --boot none image.img

    This should result in the command line option "-append 'root=/dev/vda init=/sbin/init plus additional parameters'" being added to QEMU.

    However, the value passed to "--qemu-option" is cut up into individual arguments using the Python function split() ("qemu_options=args.qemu_options.split()" in autopkgtest-virt-qemu). This causes the quoted section to be ignored and split up into
    additional arguments (irrelevant output removed):

    autopkgtest-virt-qemu: DBG: full qemu command-line: ['qemu-system-aarch64', ... '-append', "'root=/dev/vda", 'init=/sbin/init', 'plus', 'additional', "parameters'", '-kernel', '/boot/vmlinuz', '-initrd', '/boot/initrd.img']

    Each individual element of the "-append" argument is interpreted as an individual argument which is then additionally passed to qemu-system, as opposed to just being a single argument.

    The output should look more like this:

    autopkgtest-virt-qemu: DBG: full qemu command-line: ['qemu-system-aarch64', ... '-append', 'root=/dev/vda init=/sbin/init plus additional parameters', '-kernel', '/boot/vmlinuz', '-initrd', '/boot/initrd.img']


    -- System Information:
    Debian Release: 12.10
    APT prefers stable-updates
    APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'stable')
    Architecture: amd64 (x86_64)

    Kernel: Linux 6.12.12+bpo-amd64 (SMP w/28 CPU threads; PREEMPT)
    Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
    Locale: LANG=en_NZ.UTF-8, LC_CTYPE=en_NZ.UTF-8 (charmap=UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: systemd (via /run/systemd/system)
    LSM: AppArmor: enabled

    Versions of packages autopkgtest depends on:
    ii apt-utils 2.6.1
    ii libdpkg-perl 1.21.22
    ii procps 2:4.0.2-3
    ii python3 3.11.2-1+b1
    ii python3-debian 0.1.49

    Versions of packages autopkgtest recommends:
    ii autodep8 0.28
    ii fakeroot 1.31-1.2

    Versions of packages autopkgtest suggests:
    ii docker.io 20.10.24+dfsg1-1+deb12u1
    pn fakemachine <none>
    pn lxc <none>
    pn lxd <none>
    ii ovmf 2022.11-6+deb12u2
    pn ovmf-ia32 <none>
    pn podman <none>
    ii python3-distro-info 1.5+deb12u1
    ii qemu-efi-aarch64 2022.11-6+deb12u2
    ii qemu-efi-arm 2022.11-6+deb12u2
    ii qemu-system 1:7.2+dfsg-7+deb12u12
    ii qemu-utils 1:7.2+dfsg-7+deb12u12
    ii schroot 1.6.13-3+b2
    ii util-linux 2.38.1-5+deb12u3
    ii vmdb2 0.27+really.0.26-1+deb12u1
    ii zerofree 1.1.1-1

    -- no debconf information

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Simon McVittie@21:1/5 to Isaac True on Thu May 1 16:40:01 2025
    Control: retitle -1 autopkgtest-virt-qemu: no way to pass qemu options that contain whitespace
    Control: severity -1 wishlist

    On Wed, 30 Apr 2025 at 16:40:59 +0200, Isaac True wrote:
    the value passed to "--qemu-option" is cut up into individual arguments using the Python function split() ("qemu_options=args.qemu_options.split()" in autopkgtest-virt-qemu). This causes the quoted section to be ignored

    This appears to be working as designed, although the design does not accommodate your use-case. None of the documentation mentions anything
    about ability to use quoting or escaping in --qemu-option, and the
    --help specifies that it's whitespace-separated:

    --qemu-options QEMU_OPTIONS
    Pass through (whitespace-separated) arguments to
    QEMU command.

    (The man page does not currently include that clarification.)

    If we changed this to some more elaborate parser that interprets quotes or backslash escapes (such as shlex.split()), that would change the meaning
    of existing a-v-qemu command-lines, breaking backward compatibility,
    which seems like a bad idea. A new option (--qemu-options-shlex?) could
    have that behaviour, though.

    Or, a-v-qemu could gain explicit --kernel, --initrd, --append options
    which would turn your use-case into something like:

    autopkgtest ... -- qemu --append="init=... and so on" --kernel="..." --initrd="..." maindisk.qcow2

    (Or both.)

    A workaround could be to have a script with something like

    #!/bin/sh
    exec qemu-system-aarch64 -append "init=... and so on" -kernel "..." -initrd "..." "$@"

    and pass the name of that script as the --qemu-command, which is likely
    to be more ergonomic anyway if this is something that you are running repeatedly.

    smcv

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Isaac True@21:1/5 to All on Fri May 2 09:40:01 2025
    This is an OpenPGP/MIME signed message (RFC 4880 and 3156) -----------------------4754ed1a48484472c9a6905587c272e2 Content-Transfer-Encoding: quoted-printable
    Content-Type: text/plain;charset=utf-8

    A workaround could be to have a script

    Thanks Simon, this is a great idea and I'll try it out.


    Or, a-v-qemu could gain explicit --kernel, --initrd, --append options


    This seems like the best and most straight-forward option for the long term in my relatively uninformed opinion. I would be happy to create a patch that adds at least `--append`.
    -----------------------4754ed1a48484472c9a6905587c272e2--

    -----BEGIN PGP SIGNATURE-----
    Version: ProtonMail

    wrsEARYKAG0FgmgUdT0JkBBWDdA23FKzRRQAAAAAABwAIHNhbHRAbm90YXRp b25zLm9wZW5wZ3Bqcy5vcmcr8aobqV3jIX6J4mcRrmNJq5s2+NPeWyENl4Ij aqM3+xYhBPGrY/kUG+Mts4mBZRBWDdA23FKzAADx+QD/UQ5qZ0DuUJm7aVYB rwdPMSKGsiJMdxd4DPilsosVaBQBAPSK6Jo4PIZILDBbET0tzd/fuHVaRqfg
    0EU7AMNuiJYB
    =8s1r
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)