Skip to content

Commit 9fb0cea

Browse files
authored
Merge pull request #931 from afbjorklund/maxcpu-windows
whpx: Don't use -cpu max, add kernel-irqchip=off
2 parents 3af6768 + aeea90a commit 9fb0cea

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

pkg/limayaml/defaults.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func FillDefault(y, d, o *LimaYAML, filePath string) {
108108
if IsNativeArch(arch) && IsAccelOS() {
109109
if HasHostCPU() {
110110
cpuType[arch] = "host"
111-
} else {
111+
} else if HasMaxCPU() {
112112
cpuType[arch] = "max"
113113
}
114114
}
@@ -637,6 +637,11 @@ func HasHostCPU() bool {
637637
return false
638638
}
639639

640+
func HasMaxCPU() bool {
641+
// WHPX: Unexpected VP exit code 4
642+
return runtime.GOOS != "windows"
643+
}
644+
640645
func IsNativeArch(arch Arch) bool {
641646
nativeX8664 := arch == X8664 && runtime.GOARCH == "amd64"
642647
nativeAARCH64 := arch == AARCH64 && runtime.GOARCH == "arm64"

pkg/limayaml/defaults_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func TestFillDefault(t *testing.T) {
8686
if IsAccelOS() {
8787
if HasHostCPU() {
8888
builtin.CPUType[arch] = "host"
89-
} else {
89+
} else if HasMaxCPU() {
9090
builtin.CPUType[arch] = "max"
9191
}
9292
}

pkg/qemu/qemu.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ func Cmdline(cfg Config) (string, []string, error) {
369369
args = appendArgsIfNoConflict(args, "-cpu", cpu)
370370
switch *y.Arch {
371371
case limayaml.X8664:
372-
if strings.HasPrefix(cpu, "qemu64") {
372+
if strings.HasPrefix(cpu, "qemu64") && runtime.GOOS != "windows" {
373373
// use q35 machine with vmware io port disabled.
374374
args = appendArgsIfNoConflict(args, "-machine", "q35,vmport=off")
375375
// use tcg accelerator with multi threading with 512MB translation block size
@@ -379,6 +379,9 @@ func Cmdline(cfg Config) (string, []string, error) {
379379
args = appendArgsIfNoConflict(args, "-accel", "tcg,thread=multi,tb-size=512")
380380
// This will disable CPU S3 state.
381381
args = append(args, "-global", "ICH9-LPC.disable_s3=1")
382+
} else if runtime.GOOS == "windows" && accel == "whpx" {
383+
// whpx: injection failed, MSI (0, 0) delivery: 0, dest_mode: 0, trigger mode: 0, vector: 0
384+
args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel+",kernel-irqchip=off")
382385
} else {
383386
args = appendArgsIfNoConflict(args, "-machine", "q35,accel="+accel)
384387
}
@@ -608,7 +611,7 @@ func getAccel(arch limayaml.Arch) string {
608611
case "netbsd":
609612
return "nvmm"
610613
case "windows":
611-
return "whpx" // untested
614+
return "whpx"
612615
}
613616
}
614617
return "tcg"

0 commit comments

Comments
 (0)