Skip to content

Commit b03835d

Browse files
authored
Merge pull request #1487 from AkihiroSuda/qemu-disable-pdpe1gb
qemu: disable pdpe1gb on Intel Mac
2 parents 7574cd9 + 6179bba commit b03835d

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

examples/default.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ containerd:
227227
cpuType:
228228
# 🟢 Builtin default: "cortex-a72" (or "host" when running on aarch64 host)
229229
aarch64: null
230-
# 🟢 Builtin default: "qemu64" (or "host" when running on x86_64 host)
230+
# 🟢 Builtin default: "qemu64" (or "host,-pdpe1gb" when running on x86_64 host)
231231
x86_64: null
232232

233233
rosetta:

pkg/limayaml/defaults.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,15 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
120120
cpuType[arch] = "max"
121121
}
122122
}
123+
if arch == X8664 && runtime.GOOS == "darwin" {
124+
switch cpuType[arch] {
125+
case "host", "max":
126+
// Disable pdpe1gb on Intel Mac
127+
// https://github.com/lima-vm/lima/issues/1485
128+
// https://stackoverflow.com/a/72863744/5167443
129+
cpuType[arch] += ",-pdpe1gb"
130+
}
131+
}
123132
}
124133
var overrideCPUType bool
125134
for k, v := range d.CPUType {

pkg/limayaml/defaults_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,12 @@ func TestFillDefault(t *testing.T) {
9898
} else if HasMaxCPU() {
9999
builtin.CPUType[arch] = "max"
100100
}
101+
if arch == X8664 && runtime.GOOS == "darwin" {
102+
switch builtin.CPUType[arch] {
103+
case "host", "max":
104+
builtin.CPUType[arch] += ",-pdpe1gb"
105+
}
106+
}
101107
}
102108

103109
defaultPortForward := PortForward{

pkg/qemu/qemu.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,16 @@ func Cmdline(cfg Config) (string, []string, error) {
356356

357357
// CPU
358358
cpu := y.CPUType[*y.Arch]
359+
if runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" {
360+
switch {
361+
case strings.HasPrefix(cpu, "host"), strings.HasPrefix(cpu, "max"):
362+
if !strings.Contains(cpu, ",-pdpe1gb") {
363+
logrus.Warnf("On Intel Mac, CPU type %q typically needs \",-pdpe1gb\" option (https://stackoverflow.com/a/72863744/5167443)", cpu)
364+
}
365+
}
366+
}
359367
args = appendArgsIfNoConflict(args, "-cpu", cpu)
368+
360369
switch *y.Arch {
361370
case limayaml.X8664:
362371
if strings.HasPrefix(cpu, "qemu64") && runtime.GOOS != "windows" {

0 commit comments

Comments
 (0)