Skip to content

Commit 28f2d2e

Browse files
committed
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 <[email protected]>
1 parent d61330f commit 28f2d2e

19 files changed

+113
-33
lines changed

examples/almalinux-8.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ images:
1616
arch: "x86_64"
1717
- location: "https://repo.almalinux.org/almalinux/8/cloud/aarch64/images/AlmaLinux-8-GenericCloud-latest.aarch64.qcow2"
1818
arch: "aarch64"
19+
mountTypesUnsupported: ["9p"]
1920
mounts:
2021
- location: "~"
2122
- location: "/tmp/lima"

examples/almalinux-9.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ images:
1313
arch: "x86_64"
1414
- location: "https://repo.almalinux.org/almalinux/9/cloud/aarch64/images/AlmaLinux-9-GenericCloud-latest.aarch64.qcow2"
1515
arch: "aarch64"
16+
mountTypesUnsupported: ["9p"]
1617
mounts:
1718
- location: "~"
1819
- location: "/tmp/lima"

examples/centos-stream-9.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ images:
1414
arch: "x86_64"
1515
- location: "https://cloud.centos.org/centos/9-stream/aarch64/images/CentOS-Stream-GenericCloud-9-latest.aarch64.qcow2"
1616
arch: "aarch64"
17+
mountTypesUnsupported: ["9p"]
1718
mounts:
1819
- location: "~"
1920
- location: "/tmp/lima"

examples/debian-11.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ images:
1313
arch: "x86_64"
1414
- location: "https://cloud.debian.org/images/cloud/bullseye/latest/debian-11-genericcloud-arm64.qcow2"
1515
arch: "aarch64"
16-
16+
mountTypesUnsupported: ["9p"]
1717
mounts:
1818
- location: "~"
1919
- location: "/tmp/lima"

examples/debian-12.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ images:
1313
arch: "x86_64"
1414
- location: "https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-arm64.qcow2"
1515
arch: "aarch64"
16-
16+
mountTypesUnsupported: ["9p"]
1717
mounts:
1818
- location: "~"
1919
- location: "/tmp/lima"

examples/default.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,9 +111,13 @@ mounts:
111111
# 🔵 This file: true (only for "/tmp/lima")
112112
writable: true
113113

114+
# Deny list of mount types for resolving the "default" type.
115+
# 🟢 Builtin default: null
116+
mountTypesUnsupported: null
117+
114118
# 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),
115119
# or "virtiofs" (EXPERIMENTAL, needs `vmType: vz`; will graduate from experimental in Lima v1.0)
116-
# 🟢 Builtin default: "reverse-sshfs" (for QEMU), "virtiofs" (for vz)
120+
# 🟢 Builtin default: "default" (resolved to be "9p" for QEMU since Lima v1.0, "virtiofs" for vz)
117121
mountType: null
118122

119123
# Enable inotify support for mounted directories (EXPERIMENTAL)

examples/experimental/opensuse-tumbleweed.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ images:
55
arch: "x86_64"
66
- location: "https://download.opensuse.org/ports/aarch64/tumbleweed/appliances/openSUSE-Tumbleweed-Minimal-VM.aarch64-Cloud.qcow2"
77
arch: "aarch64"
8+
mountTypesUnsupported: ["9p"]
89
mounts:
910
- location: "~"
1011
- location: "/tmp/lima"

examples/opensuse-leap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ images:
55
arch: "x86_64"
66
- location: "https://download.opensuse.org/distribution/leap/15.6/appliances/openSUSE-Leap-15.6-Minimal-VM.aarch64-Cloud.qcow2"
77
arch: "aarch64"
8+
mountTypesUnsupported: ["9p"]
89
mounts:
910
- location: "~"
1011
- location: "/tmp/lima"

examples/oraclelinux-8.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ images:
1212
- location: "https://yum.oracle.com/templates/OracleLinux/OL8/u10/aarch64/OL8U10_aarch64-kvm-cloud-b100.qcow2"
1313
arch: "aarch64"
1414
digest: "sha256:def7b8055e275507a593f07dc6076a2adc5967af046c003072b479e69f25f407"
15+
mountTypesUnsupported: ["9p"]
1516
mounts:
1617
- location: "~"
1718
- location: "/tmp/lima"

examples/oraclelinux-9.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ images:
99
- location: "https://yum.oracle.com/templates/OracleLinux/OL9/u4/aarch64/OL9U4_aarch64-kvm-cloud-b90.qcow2"
1010
arch: "aarch64"
1111
digest: "sha256:1f4e20190e87c76e8c3b4a9e15e660972386cbfa4f128e5cdcd8faa43a713d44"
12+
mountTypesUnsupported: ["9p"]
1213
mounts:
1314
- location: "~"
1415
- location: "/tmp/lima"

examples/rocky-8.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ images:
1616
arch: "x86_64"
1717
- location: "https://dl.rockylinux.org/pub/rocky/8/images/aarch64/Rocky-8-GenericCloud.latest.aarch64.qcow2"
1818
arch: "aarch64"
19+
mountTypesUnsupported: ["9p"]
1920
mounts:
2021
- location: "~"
2122
- location: "/tmp/lima"

examples/rocky-9.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ images:
1414
arch: "x86_64"
1515
- location: "https://dl.rockylinux.org/pub/rocky/9/images/aarch64/Rocky-9-GenericCloud.latest.aarch64.qcow2"
1616
arch: "aarch64"
17+
mountTypesUnsupported: ["9p"]
1718
mounts:
1819
- location: "~"
1920
- location: "/tmp/lima"

hack/test-templates/test-misc.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# The test template for testing misc configurations:
22
# - disk
3+
# - snapshots
34
# - (More to come)
45
#
56
# This template requires Lima v1.0.0-alpha.0 or later.
@@ -18,6 +19,8 @@ images:
1819
- location: "https://cloud-images.ubuntu.com/releases/24.04/release/ubuntu-24.04-server-cloudimg-arm64.img"
1920
arch: "aarch64"
2021

22+
# 9p is not compatible with `limactl snapshot`
23+
mountTypesUnsupported: ["9p"]
2124
mounts:
2225
- location: "~"
2326
writable: true

pkg/limayaml/defaults.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"github.com/lima-vm/lima/pkg/ptr"
2828
"github.com/lima-vm/lima/pkg/store/dirnames"
2929
"github.com/lima-vm/lima/pkg/store/filenames"
30+
"github.com/lima-vm/lima/pkg/version/versionutil"
3031
)
3132

3233
const (
@@ -171,6 +172,15 @@ func defaultGuestInstallPrefix() string {
171172
// - CACertificates Files and Certs are uniquely appended in d, y, o order
172173
func FillDefault(y, d, o *LimaYAML, filePath string) {
173174
instDir := filepath.Dir(filePath)
175+
176+
var existingLimaVersion string // empty if the instance was created with Lima prior to v0.20
177+
limaVersionFile := filepath.Join(instDir, filenames.LimaVersion)
178+
if b, err := os.ReadFile(limaVersionFile); err == nil {
179+
existingLimaVersion = strings.TrimSpace(string(b))
180+
} else if !errors.Is(err, os.ErrNotExist) {
181+
logrus.WithError(err).Warnf("Failed to read %q", limaVersionFile)
182+
}
183+
174184
if y.VMType == nil {
175185
y.VMType = d.VMType
176186
}
@@ -547,21 +557,41 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
547557
}
548558
}
549559

560+
y.MountTypesUnsupported = append(append(o.MountTypesUnsupported, y.MountTypesUnsupported...), d.MountTypesUnsupported...)
561+
mountTypesUnsupported := make(map[string]struct{})
562+
for _, f := range y.MountTypesUnsupported {
563+
mountTypesUnsupported[f] = struct{}{}
564+
}
550565
// MountType has to be resolved before resolving Mounts
551566
if y.MountType == nil {
552567
y.MountType = d.MountType
553568
}
554569
if o.MountType != nil {
555570
y.MountType = o.MountType
556571
}
557-
if y.MountType == nil || *y.MountType == "" {
558-
if *y.VMType == VZ {
572+
if y.MountType == nil || *y.MountType == "" || *y.MountType == "default" {
573+
switch *y.VMType {
574+
case VZ:
559575
y.MountType = ptr.Of(VIRTIOFS)
560-
} else {
576+
case QEMU:
577+
y.MountType = ptr.Of(NINEP)
578+
if _, ok := mountTypesUnsupported[NINEP]; ok {
579+
// Use REVSSHFS if the instance does not support 9p
580+
y.MountType = ptr.Of(REVSSHFS)
581+
} else if isExistingInstanceDir(instDir) && !versionutil.GreaterEqual(existingLimaVersion, "1.0.0") {
582+
// Use REVSSHFS if the instance was created with Lima prior to v1.0
583+
y.MountType = ptr.Of(REVSSHFS)
584+
}
585+
default:
561586
y.MountType = ptr.Of(REVSSHFS)
562587
}
563588
}
564589

590+
if _, ok := mountTypesUnsupported[*y.MountType]; ok {
591+
// We cannot return an error here, but Validate() will return it.
592+
logrus.Warnf("Unsupported mount type: %q", *y.MountType)
593+
}
594+
565595
if y.MountInotify == nil {
566596
y.MountInotify = d.MountInotify
567597
}

pkg/limayaml/limayaml.go

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,34 @@ import (
77
)
88

99
type LimaYAML struct {
10-
MinimumLimaVersion *string `yaml:"minimumLimaVersion,omitempty" json:"minimumLimaVersion,omitempty"`
11-
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
12-
VMOpts VMOpts `yaml:"vmOpts,omitempty" json:"vmOpts,omitempty"`
13-
OS *OS `yaml:"os,omitempty" json:"os,omitempty"`
14-
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
15-
Images []Image `yaml:"images" json:"images"` // REQUIRED
16-
CPUType CPUType `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
17-
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
18-
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
19-
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
20-
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty"`
21-
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
22-
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
23-
MountInotify *bool `yaml:"mountInotify,omitempty" json:"mountInotify,omitempty"`
24-
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
25-
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
26-
Audio Audio `yaml:"audio,omitempty" json:"audio,omitempty"`
27-
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
28-
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
29-
UpgradePackages *bool `yaml:"upgradePackages,omitempty" json:"upgradePackages,omitempty"`
30-
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
31-
GuestInstallPrefix *string `yaml:"guestInstallPrefix,omitempty" json:"guestInstallPrefix,omitempty"`
32-
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
33-
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
34-
CopyToHost []CopyToHost `yaml:"copyToHost,omitempty" json:"copyToHost,omitempty"`
35-
Message string `yaml:"message,omitempty" json:"message,omitempty"`
36-
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
10+
MinimumLimaVersion *string `yaml:"minimumLimaVersion,omitempty" json:"minimumLimaVersion,omitempty"`
11+
VMType *VMType `yaml:"vmType,omitempty" json:"vmType,omitempty"`
12+
VMOpts VMOpts `yaml:"vmOpts,omitempty" json:"vmOpts,omitempty"`
13+
OS *OS `yaml:"os,omitempty" json:"os,omitempty"`
14+
Arch *Arch `yaml:"arch,omitempty" json:"arch,omitempty"`
15+
Images []Image `yaml:"images" json:"images"` // REQUIRED
16+
CPUType CPUType `yaml:"cpuType,omitempty" json:"cpuType,omitempty"`
17+
CPUs *int `yaml:"cpus,omitempty" json:"cpus,omitempty"`
18+
Memory *string `yaml:"memory,omitempty" json:"memory,omitempty"` // go-units.RAMInBytes
19+
Disk *string `yaml:"disk,omitempty" json:"disk,omitempty"` // go-units.RAMInBytes
20+
AdditionalDisks []Disk `yaml:"additionalDisks,omitempty" json:"additionalDisks,omitempty"`
21+
Mounts []Mount `yaml:"mounts,omitempty" json:"mounts,omitempty"`
22+
MountTypesUnsupported []string `yaml:"mountTypesUnsupported,omitempty" json:"mountTypesUnsupported,omitempty"`
23+
MountType *MountType `yaml:"mountType,omitempty" json:"mountType,omitempty"`
24+
MountInotify *bool `yaml:"mountInotify,omitempty" json:"mountInotify,omitempty"`
25+
SSH SSH `yaml:"ssh,omitempty" json:"ssh,omitempty"` // REQUIRED (FIXME)
26+
Firmware Firmware `yaml:"firmware,omitempty" json:"firmware,omitempty"`
27+
Audio Audio `yaml:"audio,omitempty" json:"audio,omitempty"`
28+
Video Video `yaml:"video,omitempty" json:"video,omitempty"`
29+
Provision []Provision `yaml:"provision,omitempty" json:"provision,omitempty"`
30+
UpgradePackages *bool `yaml:"upgradePackages,omitempty" json:"upgradePackages,omitempty"`
31+
Containerd Containerd `yaml:"containerd,omitempty" json:"containerd,omitempty"`
32+
GuestInstallPrefix *string `yaml:"guestInstallPrefix,omitempty" json:"guestInstallPrefix,omitempty"`
33+
Probes []Probe `yaml:"probes,omitempty" json:"probes,omitempty"`
34+
PortForwards []PortForward `yaml:"portForwards,omitempty" json:"portForwards,omitempty"`
35+
CopyToHost []CopyToHost `yaml:"copyToHost,omitempty" json:"copyToHost,omitempty"`
36+
Message string `yaml:"message,omitempty" json:"message,omitempty"`
37+
Networks []Network `yaml:"networks,omitempty" json:"networks,omitempty"`
3738
// `network` was deprecated in Lima v0.7.0, removed in Lima v0.14.0. Use `networks` instead.
3839
Env map[string]string `yaml:"env,omitempty" json:"env,omitempty"`
3940
Param map[string]string `yaml:"param,omitempty" json:"param,omitempty"`

pkg/limayaml/validate.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,12 @@ func Validate(y *LimaYAML, warn bool) error {
185185
return fmt.Errorf("field `mountType` must be %q or %q or %q, or %q, got %q", REVSSHFS, NINEP, VIRTIOFS, WSLMount, *y.MountType)
186186
}
187187

188+
for _, f := range y.MountTypesUnsupported {
189+
if f == *y.MountType {
190+
return fmt.Errorf("field `mountType` must not be one of %v (`mountTypesUnsupported`), got %q", y.MountTypesUnsupported, *y.MountType)
191+
}
192+
}
193+
188194
if warn && runtime.GOOS != "linux" {
189195
for i, mount := range y.Mounts {
190196
if mount.Virtiofs.QueueSize != nil {

pkg/version/versionutil/versionutil.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,9 @@ func GreaterThan(limaVersion, oldVersion string) bool {
3838
}
3939
panic("unreachable")
4040
}
41+
42+
// GreaterEqual return true if limaVersion >= oldVersion.
43+
func GreaterEqual(limaVersion, oldVersion string) bool {
44+
return strings.TrimPrefix(limaVersion, "v") == strings.TrimPrefix(oldVersion, "v") ||
45+
GreaterThan(limaVersion, oldVersion)
46+
}

pkg/vz/vz_driver_darwin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ var knownYamlProperties = []string{
3939
"Message",
4040
"Mounts",
4141
"MountType",
42+
"MountTypesUnsupported",
4243
"MountInotify",
4344
"Networks",
4445
"OS",

website/content/en/docs/faq/_index.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ weight: 6
3232
- [Filesystem sharing](#filesystem-sharing)
3333
- ["Filesystem is slow"](#filesystem-is-slow)
3434
- ["Filesystem is not writable"](#filesystem-is-not-writable)
35+
- ["Filesystem is unmounted after upgrading Lima to v1.0 (pre-release)"](#filesystem-is-unmounted-after-upgrading-lima-to-v10-pre-release)
3536
- [External projects](#external-projects)
3637
- ["I am using Rancher Desktop. How to deal with the underlying Lima?"](#i-am-using-rancher-desktop-how-to-deal-with-the-underlying-lima)
3738
- ["Hints for debugging other problems?"](#hints-for-debugging-other-problems)
@@ -230,6 +231,25 @@ mounts:
230231

231232
Run `limactl edit <INSTANCE>` to open the YAML editor for an existing instance.
232233

234+
#### "Filesystem is unmounted after upgrading Lima to v1.0 (pre-release)"
235+
236+
Lima v1.0 (pre-release) changed the default mount type for QEMU from `reverse-sshfs` to `9p`.
237+
238+
The `9p` mount type is known to be incompatible with the following guest operating systems:
239+
- AlmaLinux, CentOS Stream, Oracle Linux, and RockyLinux
240+
- Debian GNU/Linux
241+
- openSUSE
242+
243+
A new instance of these OS still use `reverse-sshfs` by default.
244+
However, an existing instance created with a previous version of Lima may potentially need
245+
running the following command (usually not needed):
246+
247+
```
248+
limactl edit --mount-type=reverse-sshfs <NAME>
249+
```
250+
251+
Ubuntu users are not affected by this issue.
252+
233253
### External projects
234254
#### "I am using Rancher Desktop. How to deal with the underlying Lima?"
235255

0 commit comments

Comments
 (0)