Skip to content

Commit 6410674

Browse files
authored
Merge pull request #900 from afbjorklund/accel-host
Not all OS with -accel has -cpu host option
2 parents e255855 + 3da3588 commit 6410674

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

pkg/limayaml/defaults.go

+14-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
106106
}
107107
for arch := range cpuType {
108108
if IsNativeArch(arch) && IsAccelOS() {
109-
cpuType[arch] = "host"
109+
if HasHostCPU() {
110+
cpuType[arch] = "host"
111+
}
110112
}
111113
}
112114
for k, v := range d.CPUType {
@@ -622,6 +624,17 @@ func IsAccelOS() bool {
622624
return false
623625
}
624626

627+
func HasHostCPU() bool {
628+
switch runtime.GOOS {
629+
case "darwin", "linux":
630+
return true
631+
case "netbsd", "windows":
632+
return false
633+
}
634+
// Not reached
635+
return false
636+
}
637+
625638
func IsNativeArch(arch Arch) bool {
626639
nativeX8664 := arch == X8664 && runtime.GOARCH == "amd64"
627640
nativeAARCH64 := arch == AARCH64 && runtime.GOARCH == "arm64"

pkg/limayaml/defaults_test.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,9 @@ func TestFillDefault(t *testing.T) {
8484
},
8585
}
8686
if IsAccelOS() {
87-
builtin.CPUType[arch] = "host"
87+
if HasHostCPU() {
88+
builtin.CPUType[arch] = "host"
89+
}
8890
}
8991

9092
defaultPortForward := PortForward{

0 commit comments

Comments
 (0)