From a37a4bf0ac8a96dfacdde30219f4703186b0b282 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Mon, 14 Mar 2022 16:38:40 +0900 Subject: [PATCH] Recommend QEMU 6.2.0_1 on M1 macOS Homebrew's QEMU 6.2.0_1 contains the following commits to run recent Linux guests: - qemu/qemu@ad99f64f `hvf: arm: Use macros for sysreg shift/masking` - qemu/qemu@7f6c295c `hvf: arm: Handle unknown ID registers as RES0` These commits are planned to be included in the upstream QEMU 7.0.0 (ETA: April 2022). See Homebrew/homebrew-core PR 96743 for the further information. Signed-off-by: Akihiro Suda --- README.md | 19 +++++++++++-- examples/buildkit.yaml | 1 - examples/default.yaml | 1 - examples/docker.yaml | 1 - examples/faasd.yaml | 1 - examples/k3s.yaml | 1 - examples/k8s.yaml | 1 - examples/nomad.yaml | 1 - examples/podman.yaml | 1 - examples/ubuntu-lts.yaml | 1 - examples/ubuntu.yaml | 1 - examples/vmnet.yaml | 1 - pkg/qemu/qemu.go | 42 +++++++++++++++++++++++++++ pkg/start/start.go | 61 ---------------------------------------- 14 files changed, 58 insertions(+), 75 deletions(-) diff --git a/README.md b/README.md index 017d7325a64..8a6e8cc0c04 100644 --- a/README.md +++ b/README.md @@ -110,7 +110,16 @@ brew install lima #### Install QEMU -Install recent version of QEMU. v6.2.0 or later is recommended. +Install recent version of QEMU. + +On M1 macOS, [Homebrew's QEMU `6.2.0_1`](https://github.com/Homebrew/homebrew-core/pull/96743) or later is recommended. + +If you are not using Homebrew, make sure to include the following commits to boot recent Linux guests: +- https://github.com/qemu/qemu/commit/ad99f64f `hvf: arm: Use macros for sysreg shift/masking` +- https://github.com/qemu/qemu/commit/7f6c295c `hvf: arm: Handle unknown ID registers as RES0` + +These commits are planned to be included in the upstream QEMU 7.0.0 (ETA: April 2022). +See https://github.com/Homebrew/homebrew-core/pull/96743 for the further information. #### Install Lima @@ -402,8 +411,12 @@ On Linux hosts, you might have to set sysctl value `net.ipv4.ip_unprivileged_por #### stuck on "Waiting for the essential requirement 1 of X: "ssh" -libslirp v4.6.0 used by QEMU is known to be [broken](https://gitlab.freedesktop.org/slirp/libslirp/-/issues/48). -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`). +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. +Run `brew upgrade` to upgrade QEMU. + +If you are not using Homebrew, see the "Manual installation steps" in the [Installation](#installation) section. + +See also `serial.log` in `~/.lima/` for debugging. #### "permission denied" for `limactl cp` command diff --git a/examples/buildkit.yaml b/examples/buildkit.yaml index fc9c58cf174..f037d1470f6 100644 --- a/examples/buildkit.yaml +++ b/examples/buildkit.yaml @@ -12,7 +12,6 @@ message: | ------- images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223" diff --git a/examples/default.yaml b/examples/default.yaml index 25d76764bc7..d2d7de06664 100644 --- a/examples/default.yaml +++ b/examples/default.yaml @@ -14,7 +14,6 @@ arch: null # 🔵 This file: Ubuntu 21.10 Impish Indri images images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223" diff --git a/examples/docker.yaml b/examples/docker.yaml index d04b873bed0..e93f7bb14a2 100644 --- a/examples/docker.yaml +++ b/examples/docker.yaml @@ -9,7 +9,6 @@ # This example requires Lima v0.8.0 or later images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223" diff --git a/examples/faasd.yaml b/examples/faasd.yaml index eaeabc2ca50..75309f25a6c 100644 --- a/examples/faasd.yaml +++ b/examples/faasd.yaml @@ -20,7 +20,6 @@ # Image is set to focal (20.04 LTS) for long-term stability images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe" diff --git a/examples/k3s.yaml b/examples/k3s.yaml index 8429adf1174..192e8b73289 100644 --- a/examples/k3s.yaml +++ b/examples/k3s.yaml @@ -15,7 +15,6 @@ images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223" diff --git a/examples/k8s.yaml b/examples/k8s.yaml index 36e2cc41097..5b4ffb5ebba 100644 --- a/examples/k8s.yaml +++ b/examples/k8s.yaml @@ -16,7 +16,6 @@ # Image is set to focal (20.04 LTS) for long-term stability images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe" diff --git a/examples/nomad.yaml b/examples/nomad.yaml index 1db19c656c6..adf228a65e4 100644 --- a/examples/nomad.yaml +++ b/examples/nomad.yaml @@ -12,7 +12,6 @@ # Image is set to focal (20.04 LTS) for long-term stability images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe" diff --git a/examples/podman.yaml b/examples/podman.yaml index c5575816bc9..28a0550355e 100644 --- a/examples/podman.yaml +++ b/examples/podman.yaml @@ -13,7 +13,6 @@ # This example requires Lima v0.8.0 or later images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223" diff --git a/examples/ubuntu-lts.yaml b/examples/ubuntu-lts.yaml index 954522c6020..328df065803 100644 --- a/examples/ubuntu-lts.yaml +++ b/examples/ubuntu-lts.yaml @@ -3,7 +3,6 @@ # This example requires Lima v0.7.0 or later. images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220308 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/20.04/release-20220302/ubuntu-20.04-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:243157ea0390890d6e60ce5e08e0249b16e23b6b313b63aed50f39f92b020afe" diff --git a/examples/ubuntu.yaml b/examples/ubuntu.yaml index 2478f7a9bbf..6114ed38b59 100644 --- a/examples/ubuntu.yaml +++ b/examples/ubuntu.yaml @@ -1,7 +1,6 @@ # This example requires Lima v0.7.0 or later. images: # Try to use release-yyyyMMdd image if available. Note that release-yyyyMMdd will be removed after several months. -# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223" diff --git a/examples/vmnet.yaml b/examples/vmnet.yaml index e73e81eb7ba..539a7167854 100644 --- a/examples/vmnet.yaml +++ b/examples/vmnet.yaml @@ -2,7 +2,6 @@ # This example requires Lima v0.7.0 or later. # Older versions of Lima were using a different syntax for supporting vmnet.framework. images: -# ⚠️ release-20220309 is known to be broken on aarch64: https://github.com/lima-vm/lima/issues/712 - location: "https://cloud-images.ubuntu.com/releases/21.10/release-20220201/ubuntu-21.10-server-cloudimg-amd64.img" arch: "x86_64" digest: "sha256:73fe1785c60edeb506f191affff0440abcc2de02420bb70865d51d0ff9b28223" diff --git a/pkg/qemu/qemu.go b/pkg/qemu/qemu.go index 2572c33798d..a35c7af6dfc 100644 --- a/pkg/qemu/qemu.go +++ b/pkg/qemu/qemu.go @@ -201,6 +201,47 @@ func inspectFeatures(exe string) (*features, error) { return &f, nil } +// showDarwinARM64HVFQEMU620Warning shows a warning on M1 macOS when QEMU is older than 6.2.0_1. +// +// See: +// - https://gitlab.com/qemu-project/qemu/-/issues/899 +// - https://github.com/Homebrew/homebrew-core/pull/96743 +// - https://github.com/lima-vm/lima/issues/712 +func showDarwinARM64HVFQEMU620Warning(exe, accel string, features *features) { + if runtime.GOOS != "darwin" { + return + } + if runtime.GOARCH != "arm64" { + return + } + if accel != "hvf" { + return + } + if strings.Contains(string(features.MachineHelp), "virt-7.0") { + // QEMU 7.0.0 or later + return + } + if exeFull, err := exec.LookPath(exe); err == nil { + if exeResolved, err2 := filepath.EvalSymlinks(exeFull); err2 == nil { + if strings.Contains(exeResolved, "Cellar/qemu/6.2.0_") { + // Homebrew's QEMU 6.2.0_1 or later + return + } + } + } + w := "This version of QEMU might not be able to boot recent Linux guests on M1 macOS hosts." + if _, err := exec.LookPath("brew"); err == nil { + w += "Run `brew upgrade` and make sure your QEMU version is 6.2.0_1 or later." + } else { + w += `Reinstall QEMU with the following commits (included in QEMU 7.0.0): +- https://github.com/qemu/qemu/commit/ad99f64f "hvf: arm: Use macros for sysreg shift/masking" +- https://github.com/qemu/qemu/commit/7f6c295c "hvf: arm: Handle unknown ID registers as RES0" +` + w += "See https://github.com/Homebrew/homebrew-core/pull/96743 for the further information." + } + logrus.Warn(w) +} + func Cmdline(cfg Config) (string, []string, error) { y := cfg.LimaYAML exe, args, err := getExe(*y.Arch) @@ -218,6 +259,7 @@ func Cmdline(cfg Config) (string, []string, error) { if !strings.Contains(string(features.AccelHelp), accel) { return "", nil, fmt.Errorf("accelerator %q is not supported by %s", accel, exe) } + showDarwinARM64HVFQEMU620Warning(exe, accel, features) cpu := y.CPUType[*y.Arch] args = appendArgsIfNoConflict(args, "-cpu", cpu) diff --git a/pkg/start/start.go b/pkg/start/start.go index 219a2d6c96a..f87e267c5e7 100644 --- a/pkg/start/start.go +++ b/pkg/start/start.go @@ -9,8 +9,6 @@ import ( "os" "os/exec" "path/filepath" - "runtime" - "strings" "text/template" "time" @@ -150,8 +148,6 @@ func Start(ctx context.Context, inst *store.Instance) error { return err } - showUbuntuMarch2022Warning(inst) // remove when Ubuntu fixes https://github.com/lima-vm/lima/issues/712 - watchErrCh := make(chan error) go func() { watchErrCh <- watchHostAgentEvents(ctx, inst, haStdoutPath, haStderrPath, begin) @@ -275,60 +271,3 @@ func ShowMessage(inst *store.Instance) error { } return nil } - -// showUbuntuMarch2022Warning shows warning for https://github.com/lima-vm/lima/issues/712 -func showUbuntuMarch2022Warning(inst *store.Instance) { - if runtime.GOARCH != "arm64" { - return - } - if unlikelyUbuntu(inst.Name) { - return - } - display := "sdl" - if runtime.GOOS == "darwin" { - display = "cocoa" - } - s := fmt.Sprintf(` -============ ⚠️ March 2022 update of Ubuntu does not work on ARM ⚠️ ============ -Ubuntu kernel 5.13.0-35.40 (5.4.0-103.117 for 20.04 LTS) released in March 2022 -is not bootable on ARM hosts. -(EFI stub: ERROR: FIRMWARE BUG: kernel image not aligned on 64k boundary - -Until the issue gets resolved, it is HIGHLY RECOMMENDED to run the following -command in the Ubuntu shell (NOT the host shell) to avoid upgrading the kernel: - ------------------------------------------------------------- -sudo apt-mark hold linux-image-$(uname -r) ------------------------------------------------------------- - -If your kernel was already upgraded and the VM does not boot, try running Lima -with the following environment variable to show the QEMU video display: - ------------------------------------------------------------- -export QEMU_SYSTEM_AARCH64="qemu-system-aarch64 -display %s" ------------------------------------------------------------- - -After the display is shown, press the Esc key several times to show the GRUB -prompt for choosing an older kernel. - -To receive updates about this issue, subscribe to the following issue tickets: -- https://github.com/lima-vm/lima/issues/712 -- https://bugs.launchpad.net/ubuntu/+source/grub2/+bug/1947046 - -If you are not using Ubuntu, you can ignore this warning message. -============ ⚠️ March 2022 update of Ubuntu does not work on ARM ⚠️ ============ -`, display) - logrus.Warn(s) -} - -func unlikelyUbuntu(instName string) bool { - dict := []string{ - "alma", "alpine", "archlinux", "centos", "debian", "fedora", "red", "rhel", "suse", "oracle", "rocky", - } - for _, f := range dict { - if strings.Contains(instName, f) { - return true - } - } - return false -}