{"record":{"id":"c567012d7e40e32b","repo":"lima-vm/lima","slug":"s-w","errorCode":null,"errorMessage":"%s: %w","messagePattern":"%s: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/hcs/hcs_api_windows.go","lineNumber":88,"sourceCode":"}\n\nfunc hcsCreateOperation() (hcsOperation, error) {\n\tr0, _, e1 := syscall.SyscallN(procHcsCreateOperation.Addr(), 0, 0)\n\tif r0 == 0 {\n\t\treturn 0, fmt.Errorf(\"HcsCreateOperation: %w\", e1)\n\t}\n\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","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/hcs/hcs_api_windows.go#L70-L106","documentation":"hcsWait drives an async HCS operation to completion via HcsWaitForOperationResult. If the initiating call already returned an error (callErr), it is re-wrapped as '<what>: <callErr>'. Otherwise the wrapped error comes from the HRESULT of WaitForOperationResult. The 'what' prefix names the failing phase (e.g. 'HcsCreateComputeSystem').","triggerScenarios":"The initial HCS call (create/start/terminate/getState) returns non-nil callErr — invalid handle, access denied, or an invalid parameter passed to the API — so hcsWait bails before waiting on the result.","commonSituations":"Access denied from running without required privileges; corrupted VM state file making the create call reject parameters; HCS API rejecting a malformed configuration document; another process holds the compute system lock.","solutions":["Read the '<what>:' prefix to identify which HCS phase failed and the inner callErr","Re-run limactl from an elevated shell if the inner error is access denied","Delete stale VM state for the instance and recreate it","Run 'limactl delete -f' on the broken instance, then start fresh"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// require elevation: most callErr cases here are access denied\nif !isAdmin() {\n\treturn errors.New(\"re-run elevated: HCS calls commonly fail with access denied otherwise\")\n}","typeGuard":null,"tryCatchPattern":"if err := limactl.Start(inst); err != nil {\n\tif strings.Contains(err.Error(), \": access is denied\") {\n\t\treturn fmt.Errorf(\"elevate permissions or fix WHP ACLs, then retry: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Run limactl from an elevated shell for HCS-based instances","Delete stale instance state after a crashed VM before restarting","Don't let two processes manage the same HCS compute system concurrently","Validate lima.yaml fields against HCS-supported values"],"tags":["windows","hcs","async-operation","syscall"],"backgroundTag":"hcs-operation-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}