diff options
author | Chirantan Ekbote <chirantan@chromium.org> | 2021-06-22 19:31:54 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-09-09 08:26:50 +0000 |
commit | d65bd280d9f4e192a884f1761e4b097c11aae6de (patch) | |
tree | a16f56700fe99dcf66356f31b28198e3d3e45e69 | |
parent | 02f8b005f568d7d959e1d977c36cbcf635f97043 (diff) | |
download | vmm_vhost-d65bd280d9f4e192a884f1761e4b097c11aae6de.tar.gz |
CHROMIUM: Use File for device request fd
There is nothing in the vhost-user documentation or spec that says this
must be a socket for fs device requests. It's not even guaranteed that
it is an fd for a UnixStream.
Change the type to a File and leave it up to the backend to convert it
into a more specialized type if necessary.
Upstream PR: https://github.com/rust-vmm/vhost/pull/49
BUG=b:179755651
TEST=cargo test
Cq-Depend: chromium:2987594
Change-Id: I52ce0c62e0627a87462be8e0a44fa534763f10ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/rust-vmm/vhost/+/2988140
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
-rw-r--r-- | src/vhost_user/slave_req_handler.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/vhost_user/slave_req_handler.rs b/src/vhost_user/slave_req_handler.rs index bbc935e..402030c 100644 --- a/src/vhost_user/slave_req_handler.rs +++ b/src/vhost_user/slave_req_handler.rs @@ -3,14 +3,13 @@ use std::fs::File; use std::mem; -use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd}; +use std::os::unix::io::{AsRawFd, RawFd}; use std::os::unix::net::UnixStream; use std::slice; use std::sync::{Arc, Mutex}; use super::connection::Endpoint; use super::message::*; -use super::slave_fs_cache::SlaveFsCacheReq; use super::{take_single_file, Error, Result}; /// Services provided to the master by the slave with interior mutability. @@ -62,7 +61,7 @@ pub trait VhostUserSlaveReqHandler { fn set_vring_enable(&self, index: u32, enable: bool) -> Result<()>; fn get_config(&self, offset: u32, size: u32, flags: VhostUserConfigFlags) -> Result<Vec<u8>>; fn set_config(&self, offset: u32, buf: &[u8], flags: VhostUserConfigFlags) -> Result<()>; - fn set_slave_req_fd(&self, _vu_req: SlaveFsCacheReq) {} + fn set_slave_req_fd(&self, _vu_req: File) {} fn get_inflight_fd(&self, inflight: &VhostUserInflight) -> Result<(VhostUserInflight, File)>; fn set_inflight_fd(&self, inflight: &VhostUserInflight, file: File) -> Result<()>; fn get_max_mem_slots(&self) -> Result<u64>; @@ -107,7 +106,7 @@ pub trait VhostUserSlaveReqHandlerMut { flags: VhostUserConfigFlags, ) -> Result<Vec<u8>>; fn set_config(&mut self, offset: u32, buf: &[u8], flags: VhostUserConfigFlags) -> Result<()>; - fn set_slave_req_fd(&mut self, _vu_req: SlaveFsCacheReq) {} + fn set_slave_req_fd(&mut self, _vu_req: File) {} fn get_inflight_fd( &mut self, inflight: &VhostUserInflight, @@ -201,7 +200,7 @@ impl<T: VhostUserSlaveReqHandlerMut> VhostUserSlaveReqHandler for Mutex<T> { self.lock().unwrap().set_config(offset, buf, flags) } - fn set_slave_req_fd(&self, vu_req: SlaveFsCacheReq) { + fn set_slave_req_fd(&self, vu_req: File) { self.lock().unwrap().set_slave_req_fd(vu_req) } @@ -639,9 +638,7 @@ impl<S: VhostUserSlaveReqHandler> SlaveReqHandler<S> { fn set_slave_req_fd(&mut self, files: Option<Vec<File>>) -> Result<()> { let file = take_single_file(files).ok_or(Error::InvalidMessage)?; - let sock = unsafe { UnixStream::from_raw_fd(file.into_raw_fd()) }; - let vu_req = SlaveFsCacheReq::from_stream(sock); - self.backend.set_slave_req_fd(vu_req); + self.backend.set_slave_req_fd(file); Ok(()) } |