Skip to content

fix(cluster): run 32-bit x86 programs natively in an x86_64 Colima VM - #271

Merged
Mearman merged 1 commit into
mainfrom
fix/colima-native-i386
Nov 26, 2026
Merged

Mearman merged 1 commit into
mainfrom
fix/colima-native-i386

Conversation

@Mearman

@Mearman Mearman commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

A Colima VM that is x86_64 runs its own architecture's 32-bit programs under qemu. With binfmt on (Colima's default), every colima start runs binfmt --install 386,<foreign arch> (core.SetupBinfmt), so an x86_64 VM gets a qemu-i386 entry beside qemu-aarch64. binfmt_misc takes precedence over the kernel's loader, and Wine's 32-bit side never finishes wineboot --init under emulation. On an Intel Mac node with Colima 0.10.3 the VM carries /proc/sys/fs/binfmt_misc/qemu-i386: enabled, interpreter /usr/bin/qemu-i386, flags POCF. A Windows installer build (electron-builder's NSIS step under Wine) placed on that node hangs, and its process list shows /usr/bin/qemu-i386 /usr/lib/wine/wine ....

On a Colima host whose VM is x86_64, tasks/colima_binfmt.yml switches off only that entry:

  • in the running VM, writing 0 to the entry when it reads enabled. Nothing restarts: a 32-bit process already under qemu stays there, and every later one runs natively;
  • after every start, through an after-boot provision script added to the profile's colima.yaml. Colima runs it after its own binfmt setup and before the container runtime (colimaApp.Start), so k3s never starts with the handler on. The script is idempotent and does nothing when the entry is absent. Existing provision scripts are kept. A running VM reads the file only at its next start, and Colima rewrites it from its commented template then.

Colima's binfmt stays on, so the qemu-aarch64 handler is kept, which is the narrowest change. As far as I can tell nothing on an x86_64 node needs it (the image builder profile that cross-builds through QEMU is pinned to an arm64 node), but switching binfmt off wholesale would have taken it for no gain. An aarch64 VM is left alone, because 32-bit x86 is foreign there and its qemu-i386 handler is wanted. --check reports the switch and writes nothing.

Tests in tests/unit/test_runtime_autostart.py cover an x86_64 VM (switched off now, provision script added, other settings untouched), a second run (no change), existing provision scripts (kept), a handler already off or absent (not written), a check run (reported, nothing written), an aarch64 VM (untouched), and the provision script itself run against a present and an absent entry. The two main ones fail with the task file emptied.

How it takes effect: an inventory that pins this collection by tag takes it with the next release, a pin bump, ansible-galaxy collection install -r requirements.yml --force, and a run of its site playbook limited to the x86_64 Colima hosts, --check first.

With its binfmt setting on, Colima runs `binfmt --install 386,<foreign>`
at every start, so an x86_64 VM also gets a qemu-i386 handler for its
own architecture's 32-bit programs. binfmt_misc takes precedence over
the kernel's loader, so every 32-bit program in a pod on such a node
runs under qemu user emulation, where Wine's 32-bit side never finishes
creating a prefix and a Windows installer build hangs.

On a Colima host whose VM is x86_64 the role now switches off only the
qemu-i386 entry: at once in the running VM, which restarts nothing, and
after every start through an after-boot provision script it adds to the
profile's colima.yaml, which Colima runs after its own binfmt setup and
before the container runtime. Colima's binfmt setting stays on, so the
foreign-architecture handler is kept, and an aarch64 VM is left alone.
@Mearman
Mearman force-pushed the fix/colima-native-i386 branch from 351daff to d8c55d5 Compare November 26, 2026 01:21
@Mearman
Mearman marked this pull request as ready for review November 26, 2026 02:07
@Mearman
Mearman merged commit 1840071 into main Nov 26, 2026
55 checks passed
@Mearman
Mearman deleted the fix/colima-native-i386 branch November 26, 2026 08:39
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 3.6.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant