Skip to content

Commit f32d795

Browse files
authored
Merge pull request #894 from afbjorklund/accel-os
Only use cpuType=host for OS with accel available
2 parents 600f342 + 5dacccc commit f32d795

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

pkg/limayaml/defaults.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
105105
RISCV64: "rv64", // FIXME: what is the right choice for riscv64?
106106
}
107107
for arch := range cpuType {
108-
if IsNativeArch(arch) {
108+
if IsNativeArch(arch) && IsAccelOS() {
109109
cpuType[arch] = "host"
110110
}
111111
}
@@ -612,6 +612,16 @@ func ResolveArch(s *string) Arch {
612612
return *s
613613
}
614614

615+
func IsAccelOS() bool {
616+
switch runtime.GOOS {
617+
case "darwin", "linux", "netbsd", "windows":
618+
// Accelerator
619+
return true
620+
}
621+
// Using TCG
622+
return false
623+
}
624+
615625
func IsNativeArch(arch Arch) bool {
616626
nativeX8664 := arch == X8664 && runtime.GOARCH == "amd64"
617627
nativeAARCH64 := arch == AARCH64 && runtime.GOARCH == "arm64"

pkg/limayaml/defaults_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,9 @@ func TestFillDefault(t *testing.T) {
8383
RemoveDefaults: pointer.Bool(false),
8484
},
8585
}
86-
builtin.CPUType[arch] = "host"
86+
if IsAccelOS() {
87+
builtin.CPUType[arch] = "host"
88+
}
8789

8890
defaultPortForward := PortForward{
8991
GuestIP: api.IPv4loopback1,

0 commit comments

Comments
 (0)