mirror of
https://github.com/kata-containers/cgroups-rs.git
synced 2026-08-05 02:13:23 +00:00
Support customized attributes for CpuController and MemController
Customized attributes are useful for customized kernels.
Usage:
let resource = &mut cgroups::Resources::default();
resource.cpu.attrs.insert("cpu.cfs_init_buffer_us", "10".to_string());
// apply here
Signed-off-by: Tim Zhang <tim@hyper.sh>
This commit is contained in:
10
src/cpu.rs
10
src/cpu.rs
@@ -18,8 +18,8 @@ use crate::error::*;
|
||||
use crate::{parse_max_value, read_i64_from};
|
||||
|
||||
use crate::{
|
||||
ControllIdentifier, ControllerInternal, Controllers, CpuResources, MaxValue, Resources,
|
||||
Subsystem,
|
||||
ControllIdentifier, ControllerInternal, Controllers, CpuResources, CustomizedAttribute,
|
||||
MaxValue, Resources, Subsystem,
|
||||
};
|
||||
|
||||
/// A controller that allows controlling the `cpu` subsystem of a Cgroup.
|
||||
@@ -91,6 +91,10 @@ impl ControllerInternal for CpuController {
|
||||
return Err(Error::new(ErrorKind::Other));
|
||||
}
|
||||
|
||||
res.attrs.iter().for_each(|(k, v)| {
|
||||
let _ = self.set(k, v);
|
||||
})
|
||||
|
||||
// TODO: rt properties (CONFIG_RT_GROUP_SCHED) are not yet supported
|
||||
}
|
||||
|
||||
@@ -306,6 +310,8 @@ impl CpuController {
|
||||
}
|
||||
}
|
||||
|
||||
impl CustomizedAttribute for CpuController {}
|
||||
|
||||
fn parse_cfs_quota_and_period(mut file: File) -> Result<CFSQuotaAndPeriod> {
|
||||
let mut content = String::new();
|
||||
file.read_to_string(&mut content)
|
||||
|
||||
Reference in New Issue
Block a user