Skip to content

Commit

Permalink
Merge pull request #734 from AkihiroSuda/qemu-6.2.0_1
Browse files Browse the repository at this point in the history
Recommend QEMU 6.2.0_1 on M1 macOS
  • Loading branch information
AkihiroSuda authored Mar 14, 2022
2 parents ff72c3a + a37a4bf commit 5f6dae6
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 75 deletions.
19 changes: 16 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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/<INSTANCE>` for debugging.

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

Expand Down
1 change: 0 additions & 1 deletion examples/buildkit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/faasd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/k3s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/k8s.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/nomad.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/podman.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/ubuntu-lts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/ubuntu.yaml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
1 change: 0 additions & 1 deletion examples/vmnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
42 changes: 42 additions & 0 deletions pkg/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
61 changes: 0 additions & 61 deletions pkg/start/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"text/template"
"time"

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
}

0 comments on commit 5f6dae6

Please sign in to comment.