Skip to content

feat: Add ARGS_FILE to pass QEMU arguments exactly - #2234

Open
anvilsong wants to merge 1 commit into
dockur:masterfrom
anvilsong:args-exact-pass
Open

anvilsong wants to merge 1 commit into
dockur:masterfrom
anvilsong:args-exact-pass

Conversation

@anvilsong

Copy link
Copy Markdown

Defect

src/entry.sh (lines 59, 63, 66 on master 1e99833) launches QEMU with:

exec "${cmd[@]}" ${ARGS:+ $ARGS} >"$pipe" 2>&1

Because $ARGS is unquoted it is word-split on whitespace, and quotes inside it are not removed, so a QEMU argument containing a space cannot be passed (e.g. -device foo,bar="a b"). Minimal repro (same expansion, printing argv):

cmd=(printf 'argv: [%s]\n')
ARGS='-device foo,bar="a b" -name "my vm"'
"${cmd[@]}" ${ARGS:+ $ARGS}

Output:

argv: [-device]
argv: [foo,bar="a]
argv: [b"]
argv: [-name]
argv: ["my]
argv: [vm"]

Fix

Add an optional ARGS_FILE variable: a file with one QEMU argument per line, appended verbatim to the cmd array (empty lines skipped). ARGS/ARGUMENTS behave as before, so nothing existing changes. Documented in docs/environment.md.

Testing

  • shellcheck (0.11.0, with the flags from .github/workflows/check.yml) is clean on src/entry.sh.
  • Ran the new block standalone with a file containing -device, foo,bar="a b", an empty line, -name, my vm: argv is -device, foo,bar="a b", -name, my vm.
  • Not tested: full Docker build / real QEMU boot.

🤖 Generated with Claude Code

The unquoted ${ARGS:+ $ARGS} expansion word-splits on whitespace and
never removes quotes, so an argument containing a space cannot be
passed. Read extra arguments from ARGS_FILE (one per line) into the
command array instead, which preserves each argument verbatim.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@kroese

kroese commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Yes, this is a known issue. But luckily it never caused much problems for users since it is pretty rare to have QEMU parameters to have spaces for most usecases.

In any case it needs to be fixed in qemus/qemu (the base image) and not in dockur/windows. And also Im not so keen on just adding a second ARGUMENTS variable to just to workaround it. If it is fixed properly in the base image (by generating the argument list based on an array instead of a string), then the normal ARGUMENTS could just support spaces. The reason why I did not implement it yet, is because it requires changes in a lot of places and since the problem affects so little users I was not sure if it was worth the effort.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants