{"record":{"id":"e939a1a7af2c70c8","repo":"lima-vm/lima","slug":"hcscreateoperation-w","errorCode":null,"errorMessage":"HcsCreateOperation: %w","messagePattern":"HcsCreateOperation: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/driver/hcs/hcs_api_windows.go","lineNumber":75,"sourceCode":"\t\tr0 &= 0xffff\n\t}\n\treturn syscall.Errno(r0)\n}\n\n// coString copies a CoTaskMem-allocated PWSTR into a Go string and frees it.\nfunc coString(p *uint16) string {\n\tif p == nil {\n\t\treturn \"\"\n\t}\n\ts := windows.UTF16PtrToString(p)\n\twindows.CoTaskMemFree(unsafe.Pointer(p))\n\treturn s\n}\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)","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/hcs/hcs_api_windows.go#L57-L93","documentation":"hcsCreateOperation calls the Win32 HcsCreateOperation API via syscall; if it returns a NULL operation handle, lima wraps the syscall's error value (e1) as 'HcsCreateOperation: <err>'. This is the first step of every async HCS call, so any compute-system create/start/terminate/state query can surface it. It almost always means the Host Compute Service is unavailable or broken on the host.","triggerScenarios":"Any hcsCreateComputeSystem / hcsStartComputeSystem / hcsTerminateComputeSystem / getComputeSystemState call when HcsCreateOperation fails — HCS service not running or corrupted, missing Windows feature (Virtual Machine Platform / Host Compute Service), or an OS build without the API export.","commonSituations":"Windows Home or stripped-down SKUs lacking HCS; 'Host Compute Service'/'Hyper-V' features disabled; vmcompute.dll missing or wrong version after a broken Windows update; running in a container or VM without nested virtualization.","solutions":["Verify the vmcompute (Host Compute Service) Windows service exists and is running: sc query vmcompute","Enable required Windows features: Virtual Machine Platform / Hyper-V (dism /online /enable-feature ...)","Repair system files (sfc /scannow, DISM /RestoreHealth) if vmcompute.dll is damaged","Ensure the Windows build supports HCS, or switch to a non-HCS lima driver"],"exampleFix":"// before (admin PowerShell)\nPS> sc query vmcompute   # service not found -> HcsCreateOperation fails\n// after: enable the feature and reboot\nPS> dism /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart\nPS> Restart-Computer","handlingStrategy":"validation","validationCode":"func hcsAvailable() error {\n\tif runtime.GOOS != \"windows\" {\n\t\treturn errors.New(\"hcs requires Windows\")\n\t}\n\t// Host Compute Service must be present\n\tif _, err := os.Stat(`C:\\Windows\\System32\\vmcompute.dll`); err != nil {\n\t\treturn errors.New(\"Host Compute Service (vmcompute.dll) missing; enable Virtual Machine Platform\")\n\t}\n\treturn nil\n}","typeGuard":null,"tryCatchPattern":"if err := limactl.Start(inst); err != nil {\n\tif strings.Contains(err.Error(), \"HcsCreateOperation\") {\n\t\t// HCS unavailable: check 'sc query vmcompute', enable features, reboot, retry once\n\t}\n\treturn err\n}","preventionTips":["Verify vmcompute service is running before automated Windows VM provisioning","Enable Virtual Machine Platform/Hyper-V features in host images","Avoid stripped-down Windows SKUs/containers lacking HCS","Keep Windows updated so vmcompute.dll exports stay intact"],"tags":["windows","hcs","syscall","virtualization"],"backgroundTag":"hcs-operation-failed","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}