From e9988f0c6817fcf4120044343892a7b74dee3e8f Mon Sep 17 00:00:00 2001 From: Quanwei Zhou Date: Tue, 19 Jul 2022 08:19:24 +0800 Subject: [PATCH] runtime-rs: fix sandbox_cgroup_only=false panic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When run with configuration `sandbox_cgroup_only=false`, we will call `gen_overhead_path()` as the overhead path. The `cgroup-rs` will push the path with the subsystem prefix by `PathBuf::push()`. When the path has prefix “/” it will act as root path, such as ``` let mut path = PathBuf::from("/tmp"); path.push("/etc"); assert_eq!(path, PathBuf::from("/etc")); ``` So we shoud not set overhead path with prefix "/". Fixes: #4687 Signed-off-by: Quanwei Zhou --- src/runtime-rs/crates/resource/src/cgroups/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/resource/src/cgroups/utils.rs b/src/runtime-rs/crates/resource/src/cgroups/utils.rs index a81316358c..7a2d630982 100644 --- a/src/runtime-rs/crates/resource/src/cgroups/utils.rs +++ b/src/runtime-rs/crates/resource/src/cgroups/utils.rs @@ -12,5 +12,5 @@ // /sys/fs/cgroup/memory/kata_overhead/$CGPATH where $CGPATH is // defined by the orchestrator. pub(crate) fn gen_overhead_path(path: &str) -> String { - format!("/kata_overhead/{}", path.trim_start_matches('/')) + format!("kata_overhead/{}", path.trim_start_matches('/')) }