#1104459 autopkgtest-virt-qemu: cannot pass "-append" in "--qemu-options"

#1104459#5
Date:
2025-04-30 14:40:59 UTC
From:
To:
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']

#1104459#10
Date:
2025-05-01 14:28:45 UTC
From:
To:
Control: retitle -1 autopkgtest-virt-qemu: no way to pass qemu options that contain whitespace
Control: severity -1 wishlist

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:

#1104459#19
Date:
2025-05-02 07:33:42 UTC
From:
To:
Thanks Simon, this is a great idea and I'll try it out.


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`.