Build Guest Tools images in the macOS driver after all start hooks pass, through a host callback rather than a new macOS-to-guesttools dependency. Add driver.OptimizationAdvisor, keep generic hardware evaluation in host, and move WHPX recommendations and tests into macosdriver for both the UI and diagnostics.
70 lines
2.5 KiB
Go
70 lines
2.5 KiB
Go
package macosdriver
|
|
|
|
import (
|
|
"context"
|
|
"strings"
|
|
|
|
"github.com/Nwflower/reims-go/internal/host"
|
|
)
|
|
|
|
// DriverOptimizations returns only macOS/WHPX recommendations. The host adds
|
|
// its driver-independent facts once; startup uses the same runtime capabilities.
|
|
func DriverOptimizations(rep host.Report, runtimePatches []string) []host.Optimization {
|
|
hasPatch := func(substr string) bool {
|
|
for _, p := range runtimePatches {
|
|
if strings.Contains(strings.ToLower(p), strings.ToLower(substr)) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
var out []host.Optimization
|
|
switch {
|
|
case rep.WHPX != host.WHPXReady || !rep.WHPXCaps.KernelIrqchipAvailable:
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "unavailable", Supported: false})
|
|
case !rep.NeedsColdRebootWorkaround:
|
|
if rep.WHPXCaps.NestedVirtProperty || hasPatch("nested-virt-nonfatal") {
|
|
detail := ""
|
|
if !rep.WHPXCaps.NestedVirtProperty {
|
|
detail = "win11-nested-virt-nonfatal"
|
|
}
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "recommended", Supported: true, Recommended: true, Detail: detail})
|
|
} else {
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "unavailable", Supported: false, Detail: rep.WHPXCaps.NestedVirtProbeError})
|
|
}
|
|
default:
|
|
if hasPatch("startup-ipis") {
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "experimental", Supported: true, Detail: "win10-startup-ipis"})
|
|
} else {
|
|
out = append(out, host.Optimization{ID: "kernel_irqchip", Status: "unavailable", Supported: false, Detail: "win10-needs-patch"})
|
|
}
|
|
}
|
|
if rep.NeedsColdRebootWorkaround {
|
|
out = append(out, host.Optimization{ID: "cold_reboot", Status: "auto", Supported: true, Recommended: true})
|
|
} else {
|
|
out = append(out, host.Optimization{ID: "cold_reboot", Status: "unavailable", Supported: false})
|
|
}
|
|
return out
|
|
}
|
|
|
|
// EvaluateOptimizations preserves the existing host-page ordering.
|
|
func EvaluateOptimizations(rep host.Report, runtimePatches []string) []host.Optimization {
|
|
core := host.EvaluateCoreOptimizations(rep)
|
|
extra := DriverOptimizations(rep, runtimePatches)
|
|
if len(core) == 0 {
|
|
return extra
|
|
}
|
|
out := append([]host.Optimization{core[0]}, extra...)
|
|
return append(out, core[1:]...)
|
|
}
|
|
|
|
func (d *ReimsMacOSDriver) EvaluateOptimizations(_ context.Context, rep host.Report) []host.Optimization {
|
|
var patches []string
|
|
if _, active, err := d.startClient(); err == nil {
|
|
for _, p := range active.Manifest.Patches {
|
|
patches = append(patches, p.Name)
|
|
}
|
|
}
|
|
return DriverOptimizations(rep, patches)
|
|
}
|