lima-vm / lima-vm/lima

vz: Can't start virtual machine using vz on macbook M1 (`[hostagent] received error from the guest: "signal: segmentation fault" `)

Open
#1,715 3 comments 0 reactions 0 assignees View on GitHub
component/vz
Dominant language
Go
Stars
21.9k
Forks
957
Avg merge
2d 6h
Merged PRs (30d)
53

Description

### Description

### Version

```
host: macbook M1 8GB Ventura 13.4
lima: [7de95ca](https://github.com/lima-vm/lima/commit/7de95caf068bf0d7c60bfb6d235747de8ce86e80)
```

## Issue
I can run everything fine using qemu, but vz has always been an hit an miss for me. It randomly goes into a state were the vm is not reachable, and trying to start it again does not work even after delete.

From this version I'm getting a more concrete error/warning:
```
┌─[.lima][]
└─▪ limactl start docker-main-vz
INFO[0000] Using the existing instance "docker-main-vz"
INFO[0000] [hostagent] Starting VZ (hint: to watch the boot progress, see "/Users/luca/.lima/docker-main-vz/serial*.log")
INFO[0000] [hostagent] new connection from to
INFO[0000] SSH Local Port: 55552
INFO[0000] [hostagent] Waiting for the essential requirement 1 of 3: "ssh"
INFO[0000] [hostagent] [VZ] - vm state change: running
INFO[0010] [hostagent] Waiting for the essential requirement 1 of 3: "ssh"
INFO[0011] [hostagent] The essential requirement 1 of 3 is satisfied
INFO[0011] [hostagent] Waiting for the essential requirement 2 of 3: "user session is ready for ssh"
INFO[0022] [hostagent] Waiting for the essential requirement 2 of 3: "user session is ready for ssh"
INFO[0026] [hostagent] The essential requirement 2 of 3 is satisfied
INFO[0026] [hostagent] Waiting for the essential requirement 3 of 3: "the guest agent to be running"
INFO[0026] [hostagent] The essential requirement 3 of 3 is satisfied
INFO[0026] [hostagent] Waiting for the optional requirement 1 of 1: "user probe 1/1"
INFO[0026] [hostagent] Forwarding "/var/run/docker.sock" (guest) to "/Users/luca/.lima/docker-main-vz/sock/docker.sock" (host)
INFO[0026] [hostagent] Forwarding "/run/lima-guestagent.sock" (guest) to "/Users/luca/.lima/docker-main-vz/ga.sock" (host)
INFO[0026] [hostagent] Not forwarding TCP 127.0.0.53:53
INFO[0026] [hostagent] Not forwarding TCP 0.0.0.0:22
INFO[0026] [hostagent] Not forwarding TCP [::]:22
WARN[0071] [hostagent] received error from the guest: "signal: segmentation fault"
WARN[0074] [hostagent] received error from the guest: "signal: segmentation fault"
WARN[0077] [hostagent] received error from the guest: "signal: segmentation fault"
```

However, in my experience these errors are not always reproducible even on my machine.

## Template

The template I'm using is the following (I'm using lima instead of docker-desktop, so I need most of the features from that like port forwarding and volumes mounting), I've mainly copied it from the docs:

```
vmType: "vz"

images:
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img"
arch: "x86_64"
- location: "https://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-arm64.img"
arch: "aarch64"

mountType: "virtiofs"
mounts:
- location: "~"
writable: true
- location: "/tmp/lima"
writable: true

containerd:
system: false
user: false
provision:
- mode: system
script: |
#!/bin/sh
sed -i 's/host.lima.internal.*/host.lima.internal host.docker.internal/' /etc/hosts
- mode: system
script: |
#!/bin/bash
set -eux -o pipefail
command -v docker >/dev/null 2>&1 && exit 0
if [ ! -e /etc/systemd/system/docker.socket.d/override.conf ]; then
mkdir -p /etc/systemd/system/docker.socket.d
cat <<-EOF >/etc/systemd/system/docker.socket.d/override.conf
[Socket]
SocketUser=${LIMA_CIDATA_USER}
EOF
fi
export DEBIAN_FRONTEND=noninteractive
curl -fsSL https://get.docker.com | sh
probes:
- script: |
#!/bin/bash
set -eux -o pipefail
if ! timeout 30s bash -c "until command -v docker >/dev/null 2>&1; do sleep 3; done"; then
echo >&2 "docker is not installed yet"
exit 1
fi
if ! timeout 30s bash -c "until pgrep dockerd; do sleep 3; done"; then
echo >&2 "dockerd is not running"
exit 1
fi
hint: See "/var/log/cloud-init-output.log". in the guest

hostResolver:
hosts:
host.docker.internal: host.lima.internal

portForwards:
- guestSocket: "/var/run/docker.sock"
hostSocket: "{{.Dir}}/sock/docker.sock"
- guestPortRange: [1, 65535]
hostIP: "0.0.0.0"

message: |
To run `docker` on the host (assumes docker-cli is installed), run the following commands:
------
docker context create lima-{{.Name}} --docker "host=unix://{{.Dir}}/sock/docker.sock"
docker context use lima-{{.Name}}
docker run hello-world
```

The main reason I would prefer vz over qemu is that my macbook becomes unbearably hot while running containers in qemu. This is unrelated to this issue, and I've not found a solution so far. This does not happen with vz (it's really like day and night in terms of temperature).

I can run more experiments or attach more logs if needed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.