colima icon indicating copy to clipboard operation
colima copied to clipboard

Colima should notify user that vmtype=VZ and arch=x86_64 options should not be used together

Open maneesh29s opened this issue 1 year ago • 5 comments

Discussed in https://github.com/abiosoft/colima/discussions/1150

Lima does not allow x86_64 aarchitecture on VZ engine.

-> % limactl start --arch x86_64 --vm-type vz
FATA[0001] the YAML is invalid, saved the buffer as "lima.REJECTED.yaml": field `arch` must be "aarch64" for VZ; got "x86_64"

But when colima is started with --arch=x86_64 --vm-type=vz options, it does not issue any warning or error. Instead it silently falls back to using qemu engine on x86_64 architecture. The qemu-x86_64 is extremely slow as it does not use Rosetta on mac.

To improve user experience, colima should either

  1. Issue a warning that since lima doesn't allow --arch=x86_64 --vm-type=vz combination, it is falling back qemu-x86_64
  2. Throw an error saying --arch=x86_64 --vm-type=vz options should not be used together, and do not start the VM.

maneesh29s avatar Oct 03 '24 03:10 maneesh29s

If colima does not allow to start the VM with --arch=x86_64 --vm-type=vz, then that will immediately solve another issue also discussed in #1150: The colima status prints "running using macOS Virtualization.Framework" even though it is clearly using qemu-x86_64.

This is because in colima's Config.DriverLabel function, the condition only checks if the VMtype is VZ. VMType is set to VZ as it is passed from the command line option --vm-type vz. But as mentioned before colima falls back to qemu engine when --arch x86_64 is also passed as option. So the condition in Config.DriverLabel also needs to check if architecture is not x86_64. Instead, I feel its better to just avoid this whole extra effort.

maneesh29s avatar Oct 03 '24 07:10 maneesh29s

But it should work according to https://developer.apple.com/documentation/virtualization/running-intel-binaries-in-linux-vms-with-rosetta and looks like https://github.com/crc-org/crc already implemented it

66Ton99 avatar Jan 29 '25 01:01 66Ton99

At first I was confused by colima silently ignoring both --vm-type=vz and --vz-rosetta when --arch=x86_64.

Then I just did colima start --vz-rosetta --mount-type virtiofs but the VM is aarch64 and docker pulls arm64 images.

However, if you specify docker [build/run] --platform linux/amd64 ... it will actually work and run very fast!

If you only care about x86_64 images then export DOCKER_DEFAULT_PLATFORM=linux/amd64 and use docker as normal.

It's probably best to have a separate VM and docker context for each platform to keep the container tags straight. Unfortunately I can't find a way to set a default build/run platform for a context that is different from the underlying VM platform.

jcphill avatar Feb 21 '25 05:02 jcphill

@jcphill you can build Multi-Arch images by build --platform linux/amd64,linux/arm64,linux/arm/v7 but dockerfile must support it. https://www.docker.com/blog/multi-arch-images/

66Ton99 avatar Feb 21 '25 07:02 66Ton99

@jcphill you can build Multi-Arch images by build --platform linux/amd64,linux/arm64,linux/arm/v7 but dockerfile must support it. https://www.docker.com/blog/multi-arch-images/

Thanks, I have multi-arch working based on the instructions at https://nacisimsek.com/posts/20240421-multiarch-build/ but docker buildx build --platform linux/amd64 ... is half the speed of docker build --platform linux/amd64 ... for some reason.

jcphill avatar Feb 21 '25 16:02 jcphill