Skip to content

net: fix missing network address when emulating a foreign arch - #1638

Merged
abiosoft merged 1 commit into
abiosoft:mainfrom
anandghegde:fix-network-address-foreign-arch
Sep 15, 2026
Merged

abiosoft merged 1 commit into
abiosoft:mainfrom
anandghegde:fix-network-address-foreign-arch

Conversation

@anandghegde

@anandghegde anandghegde commented Sep 14, 2026

Copy link
Copy Markdown
Contributor

Fixes #1304
Fixes #1556

Problem

On Apple Silicon, colima start --arch x86_64 --network-address starts fine but the VM never gets a reachable address: colima ls has an empty ADDRESS column and colima ls -j has no address field. The same happens with --vm-type vz --vz-rosetta --arch x86_64 (#1556). @djzort's comment in #1336 shows the pattern clearly: with the default vm type there is no "preparing network" step and no address, while adding -t qemu prompts for the sudo password, prepares the network and the address shows up.

Cause

vz and krunkit can't run a foreign architecture, so newConf quietly falls back to QEMU when the guest arch differs from the host. QEMU needs vmnet to attach col0.

startDaemon, however, decides whether vmnet is needed from the configured vmType. With the default vz it concludes vmnet isn't needed, drops Network.Address, and never starts the vmnet daemon. newConf then takes the QEMU/vmnet branch, finds vmnet not enabled in the context, and skips col0 without a warning.

Fix

Pull the "which VM type will Lima actually use" logic out of newConf into limaVMType(conf), and use it from both newConf and the vmnet decision in startDaemon (usesVmnet(conf)). There is no behaviour change for same-arch vz/krunkit/qemu setups.

Testing

  • New Test_usesVmnet and Test_limaVMType in environment/vm/lima. They are host-independent: the "foreign" arch is whichever one the runner isn't.
  • Test_usesVmnet/vz_foreign_arch_falls_back_to_qemu fails against the old condition (usesVmnet() = false, want true) and passes with the fix.
  • go test ./..., go vet, GOOS=linux go vet ./environment/vm/lima/ and golangci-lint run (0 issues) all pass on macOS 26 / arm64.
  • I haven't done a full x86_64 boot with the fix: that needs qemu plus sudo for the socket_vmnet install, which I can't do on this machine. The colima list shows no IP address #1336 comment above is the field confirmation that the QEMU + vmnet path yields an address.

Side note, not changed here: colima status still says "macOS Virtualization.Framework" for these instances because DriverLabel also reads the configured vmType. I can follow up if you'd like that fixed too.

AI disclosure: implemented with Claude Code (Claude Opus 5). I reviewed the change and ran the tests above.

@abiosoft abiosoft left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only human commits are allowed.
Also, kindly sign your commit(s).

@anandghegde
anandghegde force-pushed the fix-network-address-foreign-arch branch from 047e5bc to 06b27c7 Compare September 14, 2026 11:50
@anandghegde

Copy link
Copy Markdown
Contributor Author

@abiosoft Commit is not signed

@abiosoft

Copy link
Copy Markdown
Owner

Kindly remove claude as a co-author of your commit. Only human committers are allowed.

@anandghegde
anandghegde force-pushed the fix-network-address-foreign-arch branch from 06b27c7 to 1410c61 Compare September 15, 2026 16:38
@anandghegde

Copy link
Copy Markdown
Contributor Author

Done — dropped the co-author trailer and force-pushed. Commit is otherwise unchanged and still signed 👍

@abiosoft

Copy link
Copy Markdown
Owner

Lastly, can you kindly rebase, just to ascertain there would be no conflicts.

vz and krunkit cannot run a foreign architecture, so newConf falls back
to QEMU for e.g. `--arch x86_64` on Apple Silicon. startDaemon decided
whether vmnet is needed from the configured vmType instead, so with the
default `vz` the vmnet daemon was never started, col0 was never attached
and `--network-address` silently produced no address.

Derive the effective VM type in one place and use it for both.

Signed-off-by: Anand Hegde <anandghegde@gmail.com>
@anandghegde

Copy link
Copy Markdown
Contributor Author

Rebased onto latest main (f450fa7) — no conflicts, build and go test ./... pass, and the commit is still signed.

@anandghegde
anandghegde force-pushed the fix-network-address-foreign-arch branch from 1410c61 to 03e7aaf Compare September 15, 2026 18:17
@abiosoft
abiosoft merged commit 50c1e73 into abiosoft:main Sep 15, 2026
17 checks passed
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.

colima ls shows no network address if rosetta used "colima ls -j" does not contain "address" field when running in "--arch x86_64" mode

2 participants