mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-04-29 20:24:31 +00:00
rust-agent: Report errors to caller if possible
Various recently added error-causing calls This addresses the following warning: warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:93:9 | 93 | cg.add_task(CgroupPid::from(pid as u64)); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `#[warn(unused_must_use)]` on by default = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:196:17 | 196 | freezer_controller.thaw(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:199:17 | 199 | freezer_controller.freeze(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:365:9 | 365 | cpuset_controller.set_cpus(&cpu.cpus); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:369:9 | 369 | cpuset_controller.set_mems(&cpu.mems); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:381:13 | 381 | cpu_controller.set_shares(shares); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:385:5 | 385 | cpu_controller.set_cfs_quota_and_period(cpu.quota, cpu.period); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled warning: unused `std::result::Result` that must be used --> rustjail/src/cgroups/fs/mod.rs:1061:13 | 1061 | cpuset_controller.set_cpus(cpuset_cpus); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: this `Result` may be an `Err` variant, which should be handled The specific case of cpu_controller.set_cfs_quota_and_period is addressed in a way that changes the logic following a suggestion by Liu Bin, who had just added the code. Fixes: #750 Suggested-by: Liu Bin <bin@hyper.sh> Signed-off-by: Christophe de Dinechin <dinechin@redhat.com>
This commit is contained in:
parent
d5b492a1e7
commit
ee739c5d59
@ -91,7 +91,7 @@ impl CgroupManager for Manager {
|
|||||||
let h = cgroups::hierarchies::auto();
|
let h = cgroups::hierarchies::auto();
|
||||||
let h = Box::new(&*h);
|
let h = Box::new(&*h);
|
||||||
let cg = load_or_create(h, &self.cpath);
|
let cg = load_or_create(h, &self.cpath);
|
||||||
cg.add_task(CgroupPid::from(pid as u64));
|
cg.add_task(CgroupPid::from(pid as u64))?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,10 +194,10 @@ impl CgroupManager for Manager {
|
|||||||
let freezer_controller: &FreezerController = cg.controller_of().unwrap();
|
let freezer_controller: &FreezerController = cg.controller_of().unwrap();
|
||||||
match state {
|
match state {
|
||||||
FreezerState::Thawed => {
|
FreezerState::Thawed => {
|
||||||
freezer_controller.thaw();
|
freezer_controller.thaw()?;
|
||||||
}
|
}
|
||||||
FreezerState::Frozen => {
|
FreezerState::Frozen => {
|
||||||
freezer_controller.freeze();
|
freezer_controller.freeze()?;
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
return Err(nix::Error::Sys(Errno::EINVAL).into());
|
return Err(nix::Error::Sys(Errno::EINVAL).into());
|
||||||
@ -363,11 +363,11 @@ fn set_cpu_resources(cg: &cgroups::Cgroup, cpu: &LinuxCPU) -> Result<()> {
|
|||||||
let cpuset_controller: &CpuSetController = cg.controller_of().unwrap();
|
let cpuset_controller: &CpuSetController = cg.controller_of().unwrap();
|
||||||
|
|
||||||
if !cpu.cpus.is_empty() {
|
if !cpu.cpus.is_empty() {
|
||||||
cpuset_controller.set_cpus(&cpu.cpus);
|
cpuset_controller.set_cpus(&cpu.cpus)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
if !cpu.mems.is_empty() {
|
if !cpu.mems.is_empty() {
|
||||||
cpuset_controller.set_mems(&cpu.mems);
|
cpuset_controller.set_mems(&cpu.mems)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
let cpu_controller: &CpuController = cg.controller_of().unwrap();
|
let cpu_controller: &CpuController = cg.controller_of().unwrap();
|
||||||
@ -379,11 +379,12 @@ fn set_cpu_resources(cg: &cgroups::Cgroup, cpu: &LinuxCPU) -> Result<()> {
|
|||||||
shares
|
shares
|
||||||
};
|
};
|
||||||
if shares != 0 {
|
if shares != 0 {
|
||||||
cpu_controller.set_shares(shares);
|
cpu_controller.set_shares(shares)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cpu_controller.set_cfs_quota_and_period(cpu.quota, cpu.period);
|
set_resource!(cpu_controller, set_cfs_quota, cpu, quota);
|
||||||
|
set_resource!(cpu_controller, set_cfs_period, cpu, period);
|
||||||
|
|
||||||
set_resource!(cpu_controller, set_rt_runtime, cpu, realtime_runtime);
|
set_resource!(cpu_controller, set_rt_runtime, cpu, realtime_runtime);
|
||||||
set_resource!(cpu_controller, set_rt_period_us, cpu, realtime_period);
|
set_resource!(cpu_controller, set_rt_period_us, cpu, realtime_period);
|
||||||
@ -1059,7 +1060,7 @@ impl Manager {
|
|||||||
info!(sl!(), "updating cpuset for path {:?}", &r_path);
|
info!(sl!(), "updating cpuset for path {:?}", &r_path);
|
||||||
let cg = load_or_create(h, &r_path);
|
let cg = load_or_create(h, &r_path);
|
||||||
let cpuset_controller: &CpuSetController = cg.controller_of().unwrap();
|
let cpuset_controller: &CpuSetController = cg.controller_of().unwrap();
|
||||||
cpuset_controller.set_cpus(cpuset_cpus);
|
cpuset_controller.set_cpus(cpuset_cpus)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user