Skip to content

Commit 5f6dae6

Browse files
authored
Merge pull request #734 from AkihiroSuda/qemu-6.2.0_1
Recommend QEMU 6.2.0_1 on M1 macOS
2 parents ff72c3a + a37a4bf commit 5f6dae6

14 files changed

+58
-75
lines changed

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,16 @@ brew install lima
110110

111111
#### Install QEMU
112112

113-
Install recent version of QEMU. v6.2.0 or later is recommended.
113+
Install recent version of QEMU.
114+
115+
On M1 macOS, [Homebrew's QEMU `6.2.0_1`](https://github.com/Homebrew/homebrew-core/pull/96743) or later is recommended.
116+
117+
If you are not using Homebrew, make sure to include the following commits to boot recent Linux guests:
118+
- https://github.com/qemu/qemu/commit/ad99f64f `hvf: arm: Use macros for sysreg shift/masking`
119+
- https://github.com/qemu/qemu/commit/7f6c295c `hvf: arm: Handle unknown ID registers as RES0`
120+
121+
These commits are planned to be included in the upstream QEMU 7.0.0 (ETA: April 2022).
122+
See https://github.com/Homebrew/homebrew-core/pull/96743 for the further information.
114123

115124
#### Install Lima
116125

@@ -402,8 +411,12 @@ On Linux hosts, you might have to set sysctl value `net.ipv4.ip_unprivileged_por
402411

403412
#### stuck on "Waiting for the essential requirement 1 of X: "ssh"
404413

405-
libslirp v4.6.0 used by QEMU is known to be [broken](https://gitlab.freedesktop.org/slirp/libslirp/-/issues/48).
406-
If you have libslirp v4.6.0 in `/usr/local/Cellar/libslirp`, you have to upgrade it to v4.6.1 or later (`brew upgrade`).
414+
On M1 macOS, QEMU needs to be [Homebrew's QEMU `6.2.0_1`](https://github.com/Homebrew/homebrew-core/pull/96743) or later to run recent Linux guests.
415+
Run `brew upgrade` to upgrade QEMU.
416+
417+
If you are not using Homebrew, see the "Manual installation steps" in the [Installation](#installation) section.
418+
419+
See also `serial.log` in `~/.lima/<INSTANCE>` for debugging.
407420

408421
#### "permission denied" for `limactl cp` command
409422

examples/buildkit.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ message: |
1212
-------
1313
images:
1414
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
15-
# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
1615
- location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img"
1716
arch: "x86_64"
1817
digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223"

examples/default.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ arch: null
1414
# 🔵 This file: Ubuntu 21.10 Impish Indri images
1515
images:
1616
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
17-
# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
1817
- location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img"
1918
arch: "x86_64"
2019
digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223"

examples/docker.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# This example requires Lima v0.8.0 or later
1010
images:
1111
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
12-
# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
1312
- location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img"
1413
arch: "x86_64"
1514
digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223"

examples/faasd.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
# Image is set to focal (20.04 LTS) for long-term stability
2121
images:
2222
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
23-
# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
2423
- location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img"
2524
arch: "x86_64"
2625
digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe"

examples/k3s.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
images:
1717
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
18-
# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
1918
- location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img"
2019
arch: "x86_64"
2120
digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223"

examples/k8s.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# Image is set to focal (20.04 LTS) for long-term stability
1717
images:
1818
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
19-
# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
2019
- location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img"
2120
arch: "x86_64"
2221
digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe"

examples/nomad.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# Image is set to focal (20.04 LTS) for long-term stability
1313
images:
1414
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
15-
# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
1615
- location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img"
1716
arch: "x86_64"
1817
digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe"

examples/podman.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# This example requires Lima v0.8.0 or later
1414
images:
1515
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
16-
# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
1716
- location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img"
1817
arch: "x86_64"
1918
digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223"

examples/ubuntu-lts.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
# This example requires Lima v0.7.0 or later.
44
images:
55
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
6-
# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
76
- location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img"
87
arch: "x86_64"
98
digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe"

examples/ubuntu.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# This example requires Lima v0.7.0 or later.
22
images:
33
# Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months.
4-
# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
54
- location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img"
65
arch: "x86_64"
76
digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223"

examples/vmnet.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
# This example requires Lima v0.7.0 or later.
33
# Older versions of Lima were using a different syntax for supporting vmnet.framework.
44
images:
5-
# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712
65
- location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img"
76
arch: "x86_64"
87
digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223"

pkg/qemu/qemu.go

+42
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,47 @@ func inspectFeatures(exe string) (*features, error) {
201201
return &f, nil
202202
}
203203

204+
// showDarwinARM64HVFQEMU620Warning shows a warning on M1 macOS when QEMU is older than 6.2.0_1.
205+
//
206+
// See:
207+
// - https://gitlab.com/qemu-project/qemu/-/issues/899
208+
// - https://github.com/Homebrew/homebrew-core/pull/96743
209+
// - https://github.com/lima-vm/lima/issues/712
210+
func showDarwinARM64HVFQEMU620Warning(exe, accel string, features *features) {
211+
if runtime.GOOS != "darwin" {
212+
return
213+
}
214+
if runtime.GOARCH != "arm64" {
215+
return
216+
}
217+
if accel != "hvf" {
218+
return
219+
}
220+
if strings.Contains(string(features.MachineHelp), "virt-7.0") {
221+
// QEMU 7.0.0 or later
222+
return
223+
}
224+
if exeFull, err := exec.LookPath(exe); err == nil {
225+
if exeResolved, err2 := filepath.EvalSymlinks(exeFull); err2 == nil {
226+
if strings.Contains(exeResolved, "Cellar/qemu/6.2.0_") {
227+
// Homebrew's QEMU 6.2.0_1 or later
228+
return
229+
}
230+
}
231+
}
232+
w := "This version of QEMU might not be able to boot recent Linux guests on M1 macOS hosts."
233+
if _, err := exec.LookPath("brew"); err == nil {
234+
w += "Run `brew upgrade` and make sure your QEMU version is 6.2.0_1 or later."
235+
} else {
236+
w += `Reinstall QEMU with the following commits (included in QEMU 7.0.0):
237+
- https://github.com/qemu/qemu/commit/ad99f64f "hvf: arm: Use macros for sysreg shift/masking"
238+
- https://github.com/qemu/qemu/commit/7f6c295c "hvf: arm: Handle unknown ID registers as RES0"
239+
`
240+
w += "See https://github.com/Homebrew/homebrew-core/pull/96743 for the further information."
241+
}
242+
logrus.Warn(w)
243+
}
244+
204245
func Cmdline(cfg Config) (string, []string, error) {
205246
y := cfg.LimaYAML
206247
exe, args, err := getExe(*y.Arch)
@@ -218,6 +259,7 @@ func Cmdline(cfg Config) (string, []string, error) {
218259
if !strings.Contains(string(features.AccelHelp), accel) {
219260
return "", nil, fmt.Errorf("accelerator %q is not supported by %s", accel, exe)
220261
}
262+
showDarwinARM64HVFQEMU620Warning(exe, accel, features)
221263

222264
cpu := y.CPUType[*y.Arch]
223265
args = appendArgsIfNoConflict(args, "-cpu", cpu)

pkg/start/start.go

-61
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
"os"
1010
"os/exec"
1111
"path/filepath"
12-
"runtime"
13-
"strings"
1412
"text/template"
1513
"time"
1614

@@ -150,8 +148,6 @@ func Start(ctx context.Context, inst *store.Instance) error {
150148
return err
151149
}
152150

153-
showUbuntuMarch2022Warning(inst) // remove when Ubuntu fixes https://github.com/lima-vm/lima/issues/712
154-
155151
watchErrCh := make(chan error)
156152
go func() {
157153
watchErrCh <- watchHostAgentEvents(ctx, inst, haStdoutPath, haStderrPath, begin)
@@ -275,60 +271,3 @@ func ShowMessage(inst *store.Instance) error {
275271
}
276272
return nil
277273
}
278-
279-
// showUbuntuMarch2022Warning shows warning for https://github.com/lima-vm/lima/issues/712
280-
func showUbuntuMarch2022Warning(inst *store.Instance) {
281-
if runtime.GOARCH != "arm64" {
282-
return
283-
}
284-
if unlikelyUbuntu(inst.Name) {
285-
return
286-
}
287-
display := "sdl"
288-
if runtime.GOOS == "darwin" {
289-
display = "cocoa"
290-
}
291-
s := fmt.Sprintf(`
292-
============ ⚠️ March 2022 update of Ubuntu does not work on ARM ⚠️ ============
293-
Ubuntu kernel 5.13.0-35.40 (5.4.0-103.117 for 20.04 LTS) released in March 2022
294-
is not bootable on ARM hosts.
295-
(EFI stub: ERROR: FIRMWARE BUG: kernel image not aligned on 64k boundary
296-
297-
Until the issue gets resolved, it is HIGHLY RECOMMENDED to run the following
298-
command in the Ubuntu shell (NOT the host shell) to avoid upgrading the kernel:
299-
300-
------------------------------------------------------------
301-
sudo apt-mark hold linux-image-$(uname -r)
302-
------------------------------------------------------------
303-
304-
If your kernel was already upgraded and the VM does not boot, try running Lima
305-
with the following environment variable to show the QEMU video display:
306-
307-
------------------------------------------------------------
308-
export QEMU_SYSTEM_AARCH64="qemu-system-aarch64 -display %s"
309-
------------------------------------------------------------
310-
311-
After the display is shown, press the Esc key several times to show the GRUB
312-
prompt for choosing an older kernel.
313-
314-
To receive updates about this issue, subscribe to the following issue tickets:
315-
- https://github.com/lima-vm/lima/issues/712
316-
- https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1947046
317-
318-
If you are not using Ubuntu, you can ignore this warning message.
319-
============ ⚠️ March 2022 update of Ubuntu does not work on ARM ⚠️ ============
320-
`, display)
321-
logrus.Warn(s)
322-
}
323-
324-
func unlikelyUbuntu(instName string) bool {
325-
dict := []string{
326-
"alma", "alpine", "archlinux", "centos", "debian", "fedora", "red", "rhel", "suse", "oracle", "rocky",
327-
}
328-
for _, f := range dict {
329-
if strings.Contains(instName, f) {
330-
return true
331-
}
332-
}
333-
return false
334-
}

0 commit comments

Comments
 (0)