Internals
Read from the source at commit
9a3f1c4. Every claim here points at a file and line.
Code map
| Path | Responsibility |
|---|---|
cmd/limactl | CLI (cobra); main() at cmd/limactl/main.go:33. |
pkg/instance | Instance lifecycle: Create, Prepare, Start, StartWithPaths. |
pkg/hostagent | Host-side daemon driving the VM, SSH, mounts, port forward, DNS. |
pkg/driver + pkg/driver/{qemu,vz,wsl2,krunkit} | VM backend abstraction and in-tree drivers. |
pkg/driver/external | gRPC contract for out-of-tree drivers. |
pkg/guestagent + cmd/lima-guestagent | Agent inside the VM serving GuestService. |
pkg/cidata | cloud-init ISO9660 generation. |
pkg/limatype | Core data types (Instance, LimaYAML). |
pkg/registry | Driver registration and lookup. |
Core data structures
limatype.Instanceatpkg/limatype/lima_instance.go:26holds runtime state:Name,Status,Dir,VMType,Arch,CPUs,Memory,Disk,SSHLocalPort,HostAgentPID,DriverPID, andConfig *LimaYAML.Statusis a string alias (pkg/limatype/lima_instance.go:15) with values such asRunning,Stopped, andBroken.limatype.LimaYAMLatpkg/limatype/lima_yaml.go:16is the full template schema a user writes:VMType,Images,Mounts,MountType,PortForwards,Provision,Containerd,Networks,Rosetta,Plain, and more. Many fields are pointers so jsonschema can express nullability, andbaseallows template inheritance.driver.Driverinterface atpkg/driver/driver.go:81composesLifecycle,GUI,SnapshotManager, andGuestAgent, plusInfo,Configure,FillConfig,SSHAddress, andAdditionalSetupForSSH.Infoatpkg/driver/driver.go:110carries capability flags inFeatures.- Driver registry at
pkg/registry/registry.go:41keeps two maps:internalDriversandExternalDrivers.Getatpkg/registry/registry.go:73resolves a name (external drivers take precedence), andRegisteratpkg/registry/registry.go:197registers in-tree drivers. For example, the QEMU driver registers itself in aninit()viaregistry.Register(...)atpkg/driver/qemu/register.go:15.
A path worth tracing
The interesting path is how the CLI hands off to the background hostagent. StartWithPaths (pkg/instance/start.go:168) does not run the VM in-process; it re-executes limactl with the hostagent subcommand as a detached child:
"hostagent",
// ... args assembled ...
haCmd = exec.CommandContext(ctx, limactl, args...)
haCmd.SysProcAttr = executil.BackgroundSysProcAttr
haCmd.Stdout = haStdoutW
haCmd.Stderr = haStderrW
// ...
} else if err := haCmd.Start(); err != nil {The argument string is set at pkg/instance/start.go:218, the command at pkg/instance/start.go:234, and haCmd.Start() at pkg/instance/start.go:249. The parent then watches the child's stdout for JSON progress events. The child runs hostagentAction (cmd/limactl/hostagent.go:43), builds the agent with hostagent.New (cmd/limactl/hostagent.go:109), and calls ha.Run (cmd/limactl/hostagent.go:136). Run boots the VM with a.driver.Start(ctx) (pkg/hostagent/hostagent.go:424), then enters startRoutinesAndWait (pkg/hostagent/hostagent.go:498).
Things that surprised me
- External drivers are full gRPC services.
pkg/driver/external/driver.proto:7definesservice Driverwith more than 30 RPCs, includingStartreturningstream StartResponse, plusCreateSnapshot,Stop, and others. Driver selection goes throughCreateConfiguredDriveratpkg/driverutil/instance.go:25, which callsregistry.Get. Lifecycle hooks shell out to the external binary directly:handlePreConfiguredDriverActionrunsexec.CommandContext(ctx, extDriverPath, "--pre-driver-action")atpkg/driverutil/vm.go:56. This lets a backend like krunkit ship out-of-tree and still plug into core. - Everything is split into separate executables. Beyond drivers,
cmdholds*.limawrappers (nerdctl.lima,docker.lima,kubectl.lima,podman.lima,apptainer.lima), the per-driverlima-driver-*binaries, andlimactl-mcp. Plugins and drivers are deliberately separate processes. - Supply-chain metadata in
go.mod. The module file opens with// gomodjail:confined(go.mod:1) and//gosocialcheck:trusted(go.mod:7), and individual dependencies carry// gomodjail:unconfinedmarkers. These annotations classify dependencies for sandboxing as a supply-chain hardening measure.
Sources
- Lima source at commit
9a3f1c4, accessed 2026-06-24.