Skip to content

Commit

Permalink
qemu: disable pdpe1gb on Intel Mac
Browse files Browse the repository at this point in the history
https://stackoverflow.com/a/72863744/5167443

Workaround for issue 1485

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed Apr 14, 2023
1 parent 7574cd9 commit 6179bba
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion examples/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ containerd:
cpuType:
# 🟢 Builtin default: "cortex-a72" (or "host" when running on aarch64 host)
aarch64: null
# 🟢 Builtin default: "qemu64" (or "host" when running on x86_64 host)
# 🟢 Builtin default: "qemu64" (or "host,-pdpe1gb" when running on x86_64 host)
x86_64: null

rosetta:
Expand Down
9 changes: 9 additions & 0 deletions pkg/limayaml/defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,15 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
cpuType[arch] = "max"
}
}
if arch == X8664 && runtime.GOOS == "darwin" {
switch cpuType[arch] {
case "host", "max":
// Disable pdpe1gb on Intel Mac
// https://github.com/lima-vm/lima/issues/1485
// https://stackoverflow.com/a/72863744/5167443
cpuType[arch] += ",-pdpe1gb"
}
}
}
var overrideCPUType bool
for k, v := range d.CPUType {
Expand Down
6 changes: 6 additions & 0 deletions pkg/limayaml/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,12 @@ func TestFillDefault(t *testing.T) {
} else if HasMaxCPU() {
builtin.CPUType[arch] = "max"
}
if arch == X8664 && runtime.GOOS == "darwin" {
switch builtin.CPUType[arch] {
case "host", "max":
builtin.CPUType[arch] += ",-pdpe1gb"
}
}
}

defaultPortForward := PortForward{
Expand Down
9 changes: 9 additions & 0 deletions pkg/qemu/qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,16 @@ func Cmdline(cfg Config) (string, []string, error) {

// CPU
cpu := y.CPUType[*y.Arch]
if runtime.GOOS == "darwin" && runtime.GOARCH == "amd64" {
switch {
case strings.HasPrefix(cpu, "host"), strings.HasPrefix(cpu, "max"):
if !strings.Contains(cpu, ",-pdpe1gb") {
logrus.Warnf("On Intel Mac, CPU type %q typically needs \",-pdpe1gb\" option (https://stackoverflow.com/a/72863744/5167443)", cpu)
}
}
}
args = appendArgsIfNoConflict(args, "-cpu", cpu)

switch *y.Arch {
case limayaml.X8664:
if strings.HasPrefix(cpu, "qemu64") && runtime.GOOS != "windows" {
Expand Down

0 comments on commit 6179bba

Please # to comment.