diff --git a/runc/src/sandbox.rs b/runc/src/sandbox.rs index 00eb532d..376fc9f9 100644 --- a/runc/src/sandbox.rs +++ b/runc/src/sandbox.rs @@ -165,18 +165,19 @@ impl Sandboxer for RuncSandboxer { let mut sandbox = sandbox.lock().await; let mut sandbox_parent = self.sandbox_parent.lock().await; let sandbox_pid = sandbox_parent.fork_sandbox_process(id, &sandbox.data.netns)?; - sandbox.prepare_sandbox_ns(sandbox_pid).await.map_err(|e| { - kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default(); - e - })?; + sandbox + .prepare_sandbox_ns(sandbox_pid) + .await + .inspect_err(|_| { + kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default(); + })?; sandbox .data .task_address .clone_from(&format!("ttrpc+{}", self.task_address)); - sandbox.dump().await.map_err(|e| { + sandbox.dump().await.inspect_err(|_| { kill(Pid::from_raw(sandbox_pid), Signal::SIGKILL).unwrap_or_default(); - e })?; Ok(()) } diff --git a/vmm/common/build.rs b/vmm/common/build.rs index 3e108bed..29d1551d 100644 --- a/vmm/common/build.rs +++ b/vmm/common/build.rs @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +use std::fs; + use ttrpc_codegen::{Codegen, Customize, ProtobufCustomize}; fn main() { @@ -45,4 +47,27 @@ fn main() { ) .run() .expect("Gen protos code failed"); + + // Protobuf-rust 3.5.1 no longer generates the `#![allow(box_pointers)]` lint. + // However, ttrpc-rust has not yet upgraded to protobuf-rust 3.5.1. + // As a temporary measure, we are modifying the files to suppress the warning. + remove_box_pointers("src/api").expect("Remove api box_pointer failed"); +} + +fn remove_box_pointers(dir: &str) -> std::io::Result<()> { + // 遍历指定目录下的所有文件 + for entry in fs::read_dir(dir)? { + let entry = entry?; + let path = entry.path(); + + // 如果是文件,读取内容并进行替换 + if path.is_file() { + let content = fs::read_to_string(&path)?; + let new_content = content.replace("#![allow(box_pointers)]", ""); + + // 将修改后的内容写回文件 + fs::write(path, new_content)?; + } + } + Ok(()) }