feat(guests): cap guest resources and gate boot-start (task 0008) #34
Reference in New Issue
Block a user
Delete Branch "task-0008-guest-resource-limits"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Task:
.claude/tasks/0008-guest-resource-limits.mdSummary
Adds the Host-side placement that caps a Guest's resources and controls whether it starts at boot.
limitsfield —memory,cpu,tasksMax— maps to the guest's owncontainer@<name>.serviceunit asMemoryMax,CPUQuota, andTasksMax.A
filterAttrsdrops any limit left null, so an unset limit writes no key and systemd keeps its uncapped default.memoryandcpuare strings passed through to systemd verbatim (2G,150%);tasksMaxis a positive int.autoStartplacement option, on by default, drives the container'sautoStartdirectly (wasmkDefault true).The backend gates
wantedBy = [ "machines.target" ]on it, sofalseleaves the unit defined but out ofmachines.target— startable on demand, not at boot.neogaia's skeleton guest carries modest demonstrative caps, following task 0002's precedent of exercising the guest path on this host throughnix flake check.No deviations from the plan; all four acceptance criteria are met and verified by
nix evaland a passingnix flake check.Review
Risk
Overall: Medium
lib.nixguest helper plus one host's demonstrative caps; opt-in options only.autoStartstill defaults true.nix flake checkbuilds and passes, but no test asserts the caps land on the unit; correctness rests on eval-time wiring.MemoryMax/CPUQuota/TasksMax); a mis-mapped value could OOM-kill or throttle a guest, though confined to it.filterAttrsand amkIf.Unaddressed findings
Standards — two judgement calls, kept deliberately:
lib.nix):mkIf (cfg.backend == "container")now guards both the newserviceConfigand the pre-existingcontainers.<name>block.Kept as per-attribute guarding, which is idiomatic here; folding both under one conditional would nest the whole config block for a single predicate.
lib.nix):autoStartis a hard assignment (cfg.autoStart) while sibling container settings keepmkDefault.Intentional —
autoStartis the host-owned placement control, so it should bind directly rather than stay overridable by a guest interior.Spec — clean pass, no findings.
— Claude