From 81b2bd5e0aaa7f98c0063e136cfa1fb2d9f0c713 Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Thu, 26 Oct 2023 22:50:29 +0900 Subject: [PATCH] qemu: use 9p by default Templates for the following distro are updated to continue using reverse-sshfs, as 9p is not available on them. - AlmaLinux - CentOS Stream - Debian - openSUSE - Oracle Linux - Rocky Linux Close issue 971 Signed-off-by: Akihiro Suda --- examples/almalinux-8.yaml | 2 ++ examples/almalinux-9.yaml | 2 ++ examples/centos-stream-9.yaml | 2 ++ examples/debian-11.yaml | 2 ++ examples/debian-12.yaml | 2 ++ examples/default.yaml | 2 +- .../experimental/opensuse-tumbleweed.yaml | 2 ++ examples/opensuse.yaml | 2 ++ examples/oraclelinux-8.yaml | 2 ++ examples/oraclelinux-9.yaml | 2 ++ examples/rocky-8.yaml | 2 ++ examples/rocky-9.yaml | 2 ++ hack/test-templates/test-misc.yaml | 3 ++ pkg/limayaml/defaults.go | 30 +++++++++++++++++-- website/content/en/docs/faq/_index.md | 19 ++++++++++++ 15 files changed, 73 insertions(+), 3 deletions(-) diff --git a/examples/almalinux-8.yaml b/examples/almalinux-8.yaml index 92bd1251753..06266004f89 100644 --- a/examples/almalinux-8.yaml +++ b/examples/almalinux-8.yaml @@ -16,6 +16,8 @@ images: arch: "x86_64" - location: "https://repo.almalinux.org/almalinux/8/cloud/aarch64/images/AlmaLinux-8-GenericCloud-latest.aarch64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/almalinux-9.yaml b/examples/almalinux-9.yaml index cf457b2a87b..37cc69ab9b4 100644 --- a/examples/almalinux-9.yaml +++ b/examples/almalinux-9.yaml @@ -13,6 +13,8 @@ images: arch: "x86_64" - location: "https://repo.almalinux.org/almalinux/9/cloud/aarch64/images/AlmaLinux-9-GenericCloud-latest.aarch64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/centos-stream-9.yaml b/examples/centos-stream-9.yaml index db9023b519a..e559dd1078a 100644 --- a/examples/centos-stream-9.yaml +++ b/examples/centos-stream-9.yaml @@ -14,6 +14,8 @@ images: arch: "x86_64" - location: "https://cloud.centos.org/centos/9-stream/aarch64/images/CentOS-Stream-GenericCloud-9-latest.aarch64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/debian-11.yaml b/examples/debian-11.yaml index 182cb16b2d2..6c3323ebbf2 100644 --- a/examples/debian-11.yaml +++ b/examples/debian-11.yaml @@ -14,6 +14,8 @@ images: - location: "https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/debian-12.yaml b/examples/debian-12.yaml index b054a22666e..8ce47f150f9 100644 --- a/examples/debian-12.yaml +++ b/examples/debian-12.yaml @@ -14,6 +14,8 @@ images: - location: "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-arm64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/default.yaml b/examples/default.yaml index c2721e51460..44c7bef3e56 100644 --- a/examples/default.yaml +++ b/examples/default.yaml @@ -99,7 +99,7 @@ mounts: # Mount type for above mounts, such as "reverse-sshfs" (from sshocker), "9p" (EXPERIMENTAL (until Lima v1.0), from QEMU’s virtio-9p-pci, aka virtfs), # or "virtiofs" (EXPERIMENTAL, needs `vmType: vz`) -# 🟢 Builtin default: "reverse-sshfs" (for QEMU), "virtiofs" (for vz) +# 🟢 Builtin default: "9p" (for QEMU, since Lima v1.0), "virtiofs" (for vz) mountType: null # Enable inotify support for mounted directories (EXPERIMENTAL) diff --git a/examples/experimental/opensuse-tumbleweed.yaml b/examples/experimental/opensuse-tumbleweed.yaml index c3fe0b1bc84..7ea7af3b294 100644 --- a/examples/experimental/opensuse-tumbleweed.yaml +++ b/examples/experimental/opensuse-tumbleweed.yaml @@ -17,6 +17,8 @@ images: - location: "https://provo-mirror.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/opensuse.yaml b/examples/opensuse.yaml index b6a74ec007b..940b653bb45 100644 --- a/examples/opensuse.yaml +++ b/examples/opensuse.yaml @@ -5,6 +5,8 @@ images: arch: "x86_64" - location: "https://download.opensuse.org/distribution/leap/15.5/appliances/openSUSE-Leap-15.5-Minimal-VM.aarch64-Cloud.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/oraclelinux-8.yaml b/examples/oraclelinux-8.yaml index 76ac366cde7..9e862ca3694 100644 --- a/examples/oraclelinux-8.yaml +++ b/examples/oraclelinux-8.yaml @@ -12,6 +12,8 @@ images: - location: "https://yum.oracle.com/templates/OracleLinux/OL8/u10/aarch64/OL8U10_aarch64-kvm-cloud-b100.qcow2" arch: "aarch64" digest: "sha256:def7b8055e275507a593f07dc6076a2adc5967af046c003072b479e69f25f407" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/oraclelinux-9.yaml b/examples/oraclelinux-9.yaml index 4c79205d009..88ee6982e72 100644 --- a/examples/oraclelinux-9.yaml +++ b/examples/oraclelinux-9.yaml @@ -9,6 +9,8 @@ images: - location: "https://yum.oracle.com/templates/OracleLinux/OL9/u4/aarch64/OL9U4_aarch64-kvm-cloud-b90.qcow2" arch: "aarch64" digest: "sha256:1f4e20190e87c76e8c3b4a9e15e660972386cbfa4f128e5cdcd8faa43a713d44" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/rocky-8.yaml b/examples/rocky-8.yaml index 21ca6e36abc..52a5e48fec2 100644 --- a/examples/rocky-8.yaml +++ b/examples/rocky-8.yaml @@ -16,6 +16,8 @@ images: arch: "x86_64" - location: "https://dl.rockylinux.org/pub/rocky/8/images/aarch64/Rocky-8-GenericCloud.latest.aarch64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/examples/rocky-9.yaml b/examples/rocky-9.yaml index fe17c3c7cb0..5863e0c97e0 100644 --- a/examples/rocky-9.yaml +++ b/examples/rocky-9.yaml @@ -13,6 +13,8 @@ images: arch: "x86_64" - location: "https://dl.rockylinux.org/pub/rocky/9/images/aarch64/Rocky-9-GenericCloud.latest.aarch64.qcow2" arch: "aarch64" +# The mount type is set to reverse-sshfs because 9p (default for QEMU) is not supported by the guest kernel. VZ users should specify `--mount-type=virtiofs` on `limactl create` for better performance. +mountType: "reverse-sshfs" mounts: - location: "~" - location: "/tmp/lima" diff --git a/hack/test-templates/test-misc.yaml b/hack/test-templates/test-misc.yaml index 2bf6cc8bd1a..b4dea4ee6b1 100644 --- a/hack/test-templates/test-misc.yaml +++ b/hack/test-templates/test-misc.yaml @@ -1,5 +1,6 @@ # The test template for testing misc configurations: # - disk +# - snapshots # - (More to come) # # This template requires Lima v0.14.0 or later. @@ -18,6 +19,8 @@ images: - location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img" arch: "aarch64" +# 9p is not compatible with `limactl snapshot` +mountType: "reverse-sshfs" mounts: - location: "~" writable: true diff --git a/pkg/limayaml/defaults.go b/pkg/limayaml/defaults.go index 13815bb675f..fac1cdf21e3 100644 --- a/pkg/limayaml/defaults.go +++ b/pkg/limayaml/defaults.go @@ -3,6 +3,7 @@ package limayaml import ( "bytes" "crypto/sha256" + "errors" "fmt" "net" "os" @@ -23,6 +24,7 @@ import ( "github.com/lima-vm/lima/pkg/ptr" "github.com/lima-vm/lima/pkg/store/dirnames" "github.com/lima-vm/lima/pkg/store/filenames" + "github.com/lima-vm/lima/pkg/version/versionutil" ) const ( @@ -172,6 +174,15 @@ func defaultGuestInstallPrefix() string { // - CACertificates Files and Certs are uniquely appended in d, y, o order func FillDefault(y, d, o *LimaYAML, filePath string) { instDir := filepath.Dir(filePath) + + var existingLimaVersion string // empty if the instance was created with Lima prior to v0.20 + limaVersionFile := filepath.Join(instDir, filenames.LimaVersion) + if b, err := os.ReadFile(limaVersionFile); err == nil { + existingLimaVersion = strings.TrimSpace(string(b)) + } else if !errors.Is(err, os.ErrNotExist) { + logrus.WithError(err).Warnf("Failed to read %q", limaVersionFile) + } + if y.VMType == nil { y.VMType = d.VMType } @@ -551,9 +562,24 @@ func FillDefault(y, d, o *LimaYAML, filePath string) { y.MountType = o.MountType } if y.MountType == nil || *y.MountType == "" { - if *y.VMType == VZ { + switch *y.VMType { + case VZ: y.MountType = ptr.Of(VIRTIOFS) - } else { + case QEMU: + y.MountType = ptr.Of(NINEP) + // Use REVSSHFS if the instance was created with Lima prior to v1.0 + if _, err := os.Stat(filePath); err == nil { // existing instance + switch { + case existingLimaVersion == "": // created with Lima < 0.20 + y.MountType = ptr.Of(REVSSHFS) + case strings.TrimPrefix(existingLimaVersion, "v") == "1.0.0", + versionutil.GreaterThan(existingLimaVersion, "1.0.0"): + // NOP + default: // created with 0.20 <= Lima < 1.0 + y.MountType = ptr.Of(REVSSHFS) + } + } + default: y.MountType = ptr.Of(REVSSHFS) } } diff --git a/website/content/en/docs/faq/_index.md b/website/content/en/docs/faq/_index.md index 6457c1c00f3..f4d308a7b4e 100644 --- a/website/content/en/docs/faq/_index.md +++ b/website/content/en/docs/faq/_index.md @@ -32,6 +32,7 @@ weight: 6 - [Filesystem sharing](#filesystem-sharing) - ["Filesystem is slow"](#filesystem-is-slow) - ["Filesystem is not writable"](#filesystem-is-not-writable) + - ["Filesystem is unmounted after upgrading Lima to v1.0 (pre-release)"](#filesystem-is-unmounted-after-upgrading-lima-to-v10-pre-release) - [External projects](#external-projects) - ["I am using Rancher Desktop. How to deal with the underlying Lima?"](#i-am-using-rancher-desktop-how-to-deal-with-the-underlying-lima) - ["Hints for debugging other problems?"](#hints-for-debugging-other-problems) @@ -230,6 +231,24 @@ mounts: Run `limactl edit ` to open the YAML editor for an existing instance. +#### "Filesystem is unmounted after upgrading Lima to v1.0 (pre-release)" + +Lima v1.0 (pre-release) changed the default mount driver for QEMU from `reverse-sshfs` to `9p`. + +This change is known to be incompatible with the following guest operating systems: +- AlmaLinux, CentOS Stream, Oracle Linux, and RockyLinux +- Debian GNU/Linux +- openSUSE + +A new instance of these OS still use `reverse-sshfs` by default, however, +an existing instance created with a previous version of Lima may potentially need running the following command: + +``` +limactl edit --mount-type=reverse-sshfs +``` + +Ubuntu users are not affected by this issue. + ### External projects #### "I am using Rancher Desktop. How to deal with the underlying Lima?"