mirror of
https://github.com/mii443/izoli.git
synced 2025-08-22 16:05:40 +00:00
add cpuset.cpus
This commit is contained in:
@ -30,7 +30,8 @@ fn main() {
|
|||||||
period: 100000,
|
period: 100000,
|
||||||
}),
|
}),
|
||||||
memory_max: Some(CGroupLimitValue::Value(1024 * 1024 * 1024)),
|
memory_max: Some(CGroupLimitValue::Value(1024 * 1024 * 1024)),
|
||||||
pids_max: Some(CGroupLimitValue::Value(3)),
|
pids_max: Some(CGroupLimitValue::Value(10)),
|
||||||
|
cpus: Some(vec![0]),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
new_net: false,
|
new_net: false,
|
||||||
|
@ -63,6 +63,11 @@ impl CGroup {
|
|||||||
self.set_pids_max(pids_max)?;
|
self.set_pids_max(pids_max)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(cpus) = &option.cpus {
|
||||||
|
info!("setting cpuset.cpus");
|
||||||
|
self.set_cpuset_cpus(cpus)?;
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -249,6 +254,18 @@ impl CGroup {
|
|||||||
self.write("pids.max", &to_write)
|
self.write("pids.max", &to_write)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// cpuset read
|
||||||
|
|
||||||
|
pub fn get_cpuset_cpus(&self) -> Result<Vec<u32>, std::io::Error> {
|
||||||
|
self.get_u32_list("cpuset.cpus")
|
||||||
|
}
|
||||||
|
|
||||||
|
// cpuset write
|
||||||
|
|
||||||
|
pub fn set_cpuset_cpus(&self, cpus: &Vec<u32>) -> Result<(), std::io::Error> {
|
||||||
|
self.write_list("cpuset.cpus", cpus.clone())
|
||||||
|
}
|
||||||
|
|
||||||
fn write_value<T>(&self, name: &str, value: T) -> Result<(), std::io::Error>
|
fn write_value<T>(&self, name: &str, value: T) -> Result<(), std::io::Error>
|
||||||
where
|
where
|
||||||
T: fmt::Display,
|
T: fmt::Display,
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
use super::{cpu_limit::CpuLimit, limit_value::CGroupLimitValue};
|
use super::{cpu_limit::CpuLimit, limit_value::CGroupLimitValue};
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, Default)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct CGroupOption {
|
pub struct CGroupOption {
|
||||||
pub cpu_max: Option<CpuLimit>,
|
pub cpu_max: Option<CpuLimit>,
|
||||||
|
pub cpus: Option<Vec<u32>>,
|
||||||
pub memory_max: Option<CGroupLimitValue<u32>>,
|
pub memory_max: Option<CGroupLimitValue<u32>>,
|
||||||
pub pids_max: Option<CGroupLimitValue<u32>>,
|
pub pids_max: Option<CGroupLimitValue<u32>>,
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user