From cfb262d02f635b3ec4a28463ae22b544dcb8f032 Mon Sep 17 00:00:00 2001 From: Fupan Li Date: Thu, 2 Nov 2023 17:03:17 +0800 Subject: [PATCH] container: keep the io connection when pass fd to hybrid vsock We want the io connection keep connected when the containerd closed the io pipe, thus it can be attached on the io stream. Signed-off-by: Fupan Li --- .../virt_container/src/container_manager/io/passfd_io.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/io/passfd_io.rs b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/io/passfd_io.rs index 4af2e0084..2224f85f6 100644 --- a/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/io/passfd_io.rs +++ b/src/runtime-rs/crates/runtimes/virt_container/src/container_manager/io/passfd_io.rs @@ -16,7 +16,9 @@ async fn passfd_connect(uds: &str, port: u32, fd: OwnedFd) -> Result { let mut stream = UnixStream::connect(&uds).await.context("connect")?; stream.write_all(b"passfd\n").await.context("write all")?; - let buf = format!("{}", port); + // We want the io connection keep connected when the containerd closed the io pipe, + // thus it can be attached on the io stream. + let buf = format!("{} keep", port); stream .send_with_fd(buf.as_bytes(), &[fd.as_raw_fd()]) .context("send port and fd")?;