pub struct Cgroup { /* private fields */ }Expand description
Cgroup v2 manager
Implements the cgroup lifecycle state machine from Nucleus_Resources_CgroupLifecycle.tla
Implementations§
Source§impl Cgroup
impl Cgroup
Sourcepub fn create(name: &str) -> Result<Self>
pub fn create(name: &str) -> Result<Self>
Create a new cgroup with the given name
State transition: Nonexistent -> Created
Sourcepub fn set_limits(&mut self, limits: &ResourceLimits) -> Result<()>
pub fn set_limits(&mut self, limits: &ResourceLimits) -> Result<()>
Set resource limits
State transition: Created -> Configured
Sourcepub fn attach_process(&mut self, pid: u32) -> Result<()>
pub fn attach_process(&mut self, pid: u32) -> Result<()>
Attach a process to this cgroup
State transition: Configured -> Attached
Sourcepub fn freeze_existing(path: &Path) -> Result<CgroupFreezeGuard>
pub fn freeze_existing(path: &Path) -> Result<CgroupFreezeGuard>
Freeze an existing cgroup v2 subtree until the returned guard is dropped.
Sourcepub fn memory_current(&self) -> Result<u64>
pub fn memory_current(&self) -> Result<u64>
Get current memory usage
Sourcepub fn install_gpu_device_allowlist(
&self,
gpu_specs: &[DeviceNodeSpec],
include_tty: bool,
best_effort: bool,
) -> Result<bool>
pub fn install_gpu_device_allowlist( &self, gpu_specs: &[DeviceNodeSpec], include_tty: bool, best_effort: bool, ) -> Result<bool>
Install a cgroup v2 device allowlist (BPF_PROG_TYPE_CGROUP_DEVICE).
When GPU passthrough is enabled, this restricts device access to the
base /dev nodes plus the bound GPU devices, so a compromised workload
cannot reach other host devices even if it creates a device node.
best_effort matches --allow-degraded-security: when true, a kernel
or capability limitation degrades to a warning rather than failing the
launch, because the filesystem layer (only bound device nodes exist in
/dev) remains the primary gate.
Sourcepub fn state(&self) -> CgroupState
pub fn state(&self) -> CgroupState
Get the current state of this cgroup