package host import "strings" type GPUKind string const ( GPUDiscrete GPUKind = "discrete" GPUIntegrated GPUKind = "integrated" GPUVirtual GPUKind = "virtual" GPUUnknown GPUKind = "unknown" ) type GPUInfo struct { Name string `json:"name"` VulkanICD string `json:"vulkan_icd"` Kind GPUKind `json:"kind"` } type WHPXState string const ( WHPXReady WHPXState = "ready" WHPXNoHypervisor WHPXState = "no_hypervisor" WHPXMissing WHPXState = "missing" WHPXUnsupported WHPXState = "unsupported" ) type WHPXCapabilities struct { ModernOS bool `json:"modern_os"` APICEmulation bool `json:"apic_emulation"` KernelIrqchipAvailable bool `json:"kernel_irqchip_available"` NestedVirtProperty bool `json:"nested_virt_property"` NestedVirtProbeError string `json:"nested_virt_probe_error,omitempty"` } type Report struct { OS string `json:"os"` Arch string `json:"arch"` LogicalCPUs int `json:"logical_cpus"` PhysicalCores int `json:"physical_cores"` HasHybridCores bool `json:"has_hybrid_cores"` PCoreCount int `json:"p_core_count"` ECoreCount int `json:"e_core_count"` LPECoreCount int `json:"lpe_core_count,omitempty"` PCoreMask uint64 `json:"p_core_mask"` PCoreMaskHex string `json:"p_core_mask_hex"` PCoreLogicalCPUs []int `json:"p_core_logical_cpus,omitempty"` ECoreLogicalCPUs []int `json:"e_core_logical_cpus,omitempty"` NonLPEMask uint64 `json:"non_lpe_mask,omitempty"` NonLPEMaskHex string `json:"non_lpe_mask_hex,omitempty"` NonLPELogicalCPUs []int `json:"non_lpe_logical_cpus,omitempty"` TotalRAMGB float64 `json:"total_ram_gb"` AvailRAMGB float64 `json:"avail_ram_gb"` // Commit memory: QEMU commits all guest RAM at start (CreateFileMapping), so // a VM needs its memory free in the commit charge, not just in physical RAM. // Measured 2026-11-28: 14.7 GiB commit free with 17.3 GiB physical free, and a // 16G guest failed ("Cannot set up guest memory"). portable-runtime-spec.md ยง5.1. CommitAvailGB float64 `json:"commit_avail_gb"` CommitLimitGB float64 `json:"commit_limit_gb"` DataRoot string `json:"data_root"` FreeDiskGB float64 `json:"free_disk_gb"` WHPX WHPXState `json:"whpx"` WHPXCaps WHPXCapabilities `json:"whpx_caps"` NeedsColdRebootWorkaround bool `json:"needs_cold_reboot_workaround"` GPUs []GPUInfo `json:"gpus"` RecommendedGPU *GPUInfo `json:"recommended_gpu,omitempty"` } // ClassifyGPU distinguishes discrete, integrated, and virtual display adapters. func ClassifyGPU(name string) GPUKind { low := strings.ToLower(name) for _, v := range []string{"todesk", "gameviewer", "parsec", "virtual", "idd", "microsoft basic", "spacedesk"} { if strings.Contains(low, v) { return GPUVirtual } } for _, d := range []string{"nvidia", "geforce", "rtx", "gtx", "quadro", "radeon rx", "radeon pro", "intel(r) arc"} { if strings.Contains(low, d) { return GPUDiscrete } } for _, i := range []string{"intel(r) uhd", "intel(r) hd", "intel(r) iris", "radeon(tm) graphics"} { if strings.Contains(low, i) { return GPUIntegrated } } return GPUUnknown } // PickRecommendedGPU selects the best Vulkan GPU (preferring discrete over integrated, skipping virtual). func PickRecommendedGPU(gpus []GPUInfo) *GPUInfo { for i := range gpus { if gpus[i].Kind == GPUDiscrete && gpus[i].VulkanICD != "" { cp := gpus[i] return &cp } } for i := range gpus { if gpus[i].Kind == GPUIntegrated && gpus[i].VulkanICD != "" { cp := gpus[i] return &cp } } for i := range gpus { if gpus[i].Kind != GPUVirtual && gpus[i].VulkanICD != "" { cp := gpus[i] return &cp } } return nil }