# spinifex-unit-version: 3 [Unit] Description=Spinifex Daemon (VM Orchestration) PartOf=spinifex.target After=spinifex-nats.service spinifex-viperblock.service openvswitch-switch.service ovn-controller.service openvswitch-ipsec.service # Wants (not Requires): stay bootable when openvswitch-ipsec is absent Wants=openvswitch-ipsec.service [Service] EnvironmentFile=-/etc/spinifex/telemetry.env # ZFS root: installer raises SPINIFEX_RESERVED_MEM_GB by the ARC ceiling the admission gate cannot see EnvironmentFile=-/etc/spinifex/host.env Type=simple Slice=spinifex-system.slice User=spinifex-daemon Group=spinifex ExecStart=/usr/local/bin/spx service spinifex start Restart=on-failure RestartSec=5 # KillMode=process: guest QEMU survives daemon restart; the new daemon reattaches (DDIL) KillMode=process TimeoutStopSec=15 # RG-4: infra tier — reaped only after every guest OOMScoreAdjust=-500 # Guest QEMU shares this cgroup: the ceiling tracks the slice budget, not daemon overhead MemoryHigh=75% MemoryMax=85% Environment=SPINIFEX_CONFIG_PATH=/etc/spinifex/spinifex.toml Environment=SPINIFEX_BASE_DIR=/var/lib/spinifex/spinifex/ Environment=SPINIFEX_WAL_DIR=/var/lib/spinifex/spinifex/ # Pin to host tmpfs: QEMU pidfiles/QMP sockets must survive PrivateTmp namespace churn (DDIL) Environment=XDG_RUNTIME_DIR=/run/spinifex # RG-9: daemon tier — privileged by necessity (GPU vfio). No CAP_NET_ADMIN here, # so unlike vpcd it still escalates ip/sysctl and NoNewPrivileges stays omitted. AmbientCapabilities=CAP_SYS_ADMIN CAP_DAC_OVERRIDE ProtectSystem=full PrivateDevices=no DevicePolicy=closed DeviceAllow=/dev/kvm rw DeviceAllow=/dev/net/tun rw DeviceAllow=/dev/vhost-net rw DeviceAllow=char-vfio rw DeviceAllow=/dev/vfio/vfio rw ReadOnlyPaths=/etc/spinifex/spinifex.toml /etc/spinifex/server.pem /etc/spinifex/server.key /etc/spinifex/ca.pem # /proc/sys/net/ipv4/conf: ProtectKernelTunables would keep the per-tap IMDS # rp_filter/accept_local read-only; /etc/spinifex/firewall: the root helper writes peers.nft. ReadWritePaths=/var/lib/spinifex/spinifex /var/log/spinifex /run/spinifex /run/spinifex/nbd /proc/sys/net/ipv4/conf -/etc/spinifex/firewall # RG-9: hardening baseline ProtectHome=yes PrivateTmp=yes RestrictSUIDSGID=yes LockPersonality=yes RestrictRealtime=yes RestrictNamespaces=yes ProtectClock=yes ProtectKernelTunables=yes ProtectKernelModules=yes ProtectKernelLogs=yes ProtectControlGroups=yes ProtectProc=invisible SystemCallArchitectures=native MemoryDenyWriteExecute=yes RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK ProtectHostname=yes KeyringMode=private RemoveIPC=yes LimitCORE=0 LimitNOFILE=65536 LimitNPROC=4096 # LimitMEMLOCK=infinity: VFIO pins all guest RAM LimitMEMLOCK=infinity [Install] WantedBy=spinifex.target