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 <fupan.lfp@antgroup.com>
This commit is contained in:
Fupan Li 2023-11-02 17:03:17 +08:00 committed by Zixuan Tan
parent 4a762fcfdd
commit cfb262d02f

View File

@ -16,7 +16,9 @@ async fn passfd_connect(uds: &str, port: u32, fd: OwnedFd) -> Result<u32> {
let mut stream = UnixStream::connect(&uds).await.context("connect")?; let mut stream = UnixStream::connect(&uds).await.context("connect")?;
stream.write_all(b"passfd\n").await.context("write all")?; 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 stream
.send_with_fd(buf.as_bytes(), &[fd.as_raw_fd()]) .send_with_fd(buf.as_bytes(), &[fd.as_raw_fd()])
.context("send port and fd")?; .context("send port and fd")?;