{"record":{"id":"34020fb19c80bede","repo":"lima-vm/lima","slug":"s-w-result-s","errorCode":null,"errorMessage":"%s: %w (result: %s)","messagePattern":"(.+?): %w \\(result: (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/driver/hcs/hcs_api_windows.go","lineNumber":95,"sourceCode":"\treturn hcsOperation(r0), nil\n}\n\nfunc hcsCloseOperation(op hcsOperation) {\n\t_, _, _ = syscall.SyscallN(procHcsCloseOperation.Addr(), uintptr(op))\n}\n\n// hcsWait drives one async HCS call to completion and returns the result\n// document (which carries structured error info on failure).\nfunc hcsWait(op hcsOperation, what string, callErr error) (string, error) {\n\tif callErr != nil {\n\t\treturn \"\", fmt.Errorf(\"%s: %w\", what, callErr)\n\t}\n\tvar result *uint16\n\tr0, _, _ := syscall.SyscallN(procHcsWaitForOperationResult.Addr(),\n\t\tuintptr(op), uintptr(infiniteTimeout), uintptr(unsafe.Pointer(&result)))\n\tdoc := coString(result)\n\tif err := hresultErr(r0); err != nil {\n\t\treturn doc, fmt.Errorf(\"%s: %w (result: %s)\", what, err, doc)\n\t}\n\treturn doc, nil\n}\n\nfunc hcsCreateComputeSystem(id, configuration string) (hcsSystem, error) {\n\top, err := hcsCreateOperation()\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tdefer hcsCloseOperation(op)\n\n\tidP, err := syscall.UTF16PtrFromString(id)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tcfgP, err := syscall.UTF16PtrFromString(configuration)\n\tif err != nil {\n\t\treturn 0, err","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/hcs/hcs_api_windows.go#L77-L113","documentation":"When HcsWaitForOperationResult itself fails (non-zero HRESULT), hcsWait returns '<what>: <hresultErr> (result: <doc>)'. The result document is the HCS JSON error payload, which contains the structured HCS error code and message — this is the richest diagnostic for create/start/terminate failures. The actual VM-level failure reason is inside that JSON.","triggerScenarios":"HcsWaitForOperationResult returns an error HRESULT after an async HcsCreateComputeSystem/HcsStartComputeSystem/HcsTerminateComputeSystem call — e.g. guest boot failure, bad configuration document, hypervisor not running, or resource exhaustion.","commonSituations":"Hyper-V/Virtual Machine Platform enabled but hypervisor not launched (bcdedit hypervisorlaunchtype off); invalid memory/CPU settings rejected by HCS; base image incompatible; WHP (Windows Hypervisor Platform) conflicts with other hypervisors (WSL2/VirtualBox).","solutions":["Parse the '(result: ...)' JSON for the HCS ErrorCode/ErrorMessage to find the root cause","Ensure the hypervisor is running: bcdedit /set hypervisorlaunchtype auto, then reboot","Validate VM settings (memory/cpu) are within host limits in lima.yaml","Close conflicting hypervisors (disable VirtualBox/older VMware when using WHP-based HCS)"],"exampleFix":"// before (admin prompt)\nPS> bcdedit /enum | findstr hypervisorlaunchtype  # shows Off\n// result doc: {\"ErrorCode\":2151351185,...}\n// after\nPS> bcdedit /set hypervisorlaunchtype auto\nPS> Restart-Computer","handlingStrategy":"try-catch","validationCode":"// pre-check: hypervisor must be launched for HCS to start compute systems\n// admin PowerShell: (Get-ComputerInfo).HyperVisorPresent -eq $true\nif !hypervisorPresent() {\n\treturn errors.New(\"enable hypervisor: bcdedit /set hypervisorlaunchtype auto, then reboot\")\n}","typeGuard":null,"tryCatchPattern":"if err := limactl.Start(inst); err != nil {\n\tif i := strings.Index(err.Error(), \"(result: \"); i >= 0 {\n\t\tdoc := err.Error()[i+len(\"(result: \") : len(err.Error())-1]\n\t\tvar hcsErr struct{ ErrorMessage string `json:\"ErrorMessage\"` }\n\t\tif json.Unmarshal([]byte(doc), &hcsErr) == nil {\n\t\t\tlog.Printf(\"HCS root cause: %s\", hcsErr.ErrorMessage)\n\t\t}\n\t}\n\treturn err\n}","preventionTips":["Parse the '(result: {...})' JSON for the real HCS error before guessing fixes","Keep hypervisorlaunchtype=auto and reboot after enabling virtualization features","Size memory/CPU in lima.yaml within host capacity","Avoid mixing conflicting hypervisors (VirtualBox/VMware with WHP) on one host"],"tags":["windows","hcs","hypervisor","hresult"],"backgroundTag":"hcs-operation-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}