{"record":{"id":"83439a73671817e0","repo":"lima-vm/lima","slug":"vz-driver-state-stopped","errorCode":null,"errorMessage":"vz driver state stopped","messagePattern":"vz driver state stopped","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/driver/vz/vm_darwin.go","lineNumber":168,"sourceCode":"\t\t\t\t\t\t\t\t\tReason: \"Failed to wait for guest SSH server\",\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\terr := usernetClient.ConfigureDriver(ctx, inst, usernetSSHLocalPort)\n\t\t\t\t\t\tif err != nil {\n\t\t\t\t\t\t\tsendErrCh <- err\n\t\t\t\t\t\t}\n\t\t\t\t\t}()\n\t\t\t\tcase vz.VirtualMachineStateStopped:\n\t\t\t\t\tlogrus.Info(\"[VZ] - vm state change: stopped\")\n\t\t\t\t\twrapper.mu.Lock()\n\t\t\t\t\twrapper.stopped = true\n\t\t\t\t\twrapper.mu.Unlock()\n\t\t\t\t\t_ = usernetClient.UnExposeSSH(inst.SSHLocalPort)\n\t\t\t\t\tif stopUsernet != nil {\n\t\t\t\t\t\tstopUsernet()\n\t\t\t\t\t}\n\t\t\t\t\tsendErrCh <- errors.New(\"vz driver state stopped\")\n\t\t\t\tdefault:\n\t\t\t\t\tlogrus.Debugf(\"[VZ] - vm state change: %#q\", newState)\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}()\n\treturn wrapper, notifySSHLocalPortAccessible, sendErrCh, err\n}\n\nfunc startUsernet(ctx context.Context, inst *limatype.Instance) (*usernet.Client, context.CancelFunc, error) {\n\tif firstUsernetIndex := limayaml.FirstUsernetIndex(inst.Config); firstUsernetIndex != -1 {\n\t\tnwName := inst.Config.Networks[firstUsernetIndex].Lima\n\t\treturn usernet.NewClientByName(nwName), nil, nil\n\t}\n\t// Start a in-process gvisor-tap-vsock\n\tendpointSock, err := usernet.SockWithDirectory(inst.Dir, \"\", usernet.EndpointSock)\n\tif err != nil {\n\t\treturn nil, nil, err","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/lima-vm/lima/blob/dd909d0973cd84fa35f9e1693181b4585ea616c1/pkg/driver/vz/vm_darwin.go#L150-L186","documentation":"The VZ driver watches VM state changes; when the underlying VZ virtual machine transitions to a stopped state, the wrapper marks itself stopped, unexposes the SSH port, stops usernet, and sends errors.New(\"vz driver state stopped\") through the error channel. This is the driver's normal shutdown/propagation signal when the VM exits or crashes.","triggerScenarios":"The VZ VM process halts unexpectedly (guest shutdown, VZ runtime error, crash), causing the state-change watcher to observe .stopped and emit this error to the instance monitor.","commonSituations":"Guest-initiated shutdown; VZ aborting the VM due to invalid configuration or resource exhaustion; the VM crashing during boot; user stopping the instance from inside the guest.","solutions":["Inspect the instance logs (`limactl shell` unavailable now; check ~/.lima/<instance>/ha.stderr.log or journal) to learn why the VM stopped.","Restart with `limactl start <instance>`.","If the VM stopped unexpectedly, check macOS Virtualization framework logs and available memory/disk.","Treat it as expected lifecycle event if the guest deliberately shut down; the hostagent will reconcile instance state."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Go: consume the driver error channel\nfor err := range errCh {\n    if err != nil && err.Error() == \"vz driver state stopped\" {\n        log.Info(\"VM stopped; reconciling instance state\")\n        break\n    }\n}","preventionTips":["Monitor instance state with limactl list after unexpected stops","Check guest logs to find why the VM halted","Ensure sufficient host memory/disk for the VM","Treat guest-initiated shutdowns as expected"],"tags":["vz-driver","vm-lifecycle","shutdown"],"backgroundTag":"vm-state-stopped","analyzedSha":"dd909d0973cd84fa35f9e1693181b4585ea616c1","analyzedAt":"2026-09-01T14:24:59.842Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}