mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 05:03:05 +00:00
vmm_vhost: rename unix Endpoint impl to SocketEndpoint
This matches the Windows Endpoint naming (TubeEndpoint) and helps avoid confusion with `trait Endpoint`. Change-Id: Idd3d8c84e995e38dad68848c8bd5b2188f619485 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4844140 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
0bf7df47ec
commit
0419cd9401
5 changed files with 16 additions and 16 deletions
|
@ -60,7 +60,7 @@ pub mod test_helpers {
|
|||
use std::os::unix::net::UnixStream;
|
||||
|
||||
use tempfile::TempDir;
|
||||
use vmm_vhost::connection::socket::Endpoint as SocketEndpoint;
|
||||
use vmm_vhost::connection::socket::SocketEndpoint;
|
||||
use vmm_vhost::connection::Listener;
|
||||
use vmm_vhost::message::MasterReq;
|
||||
use vmm_vhost::SlaveReqHandler;
|
||||
|
|
|
@ -13,7 +13,7 @@ use base::AsRawDescriptor;
|
|||
use base::SafeDescriptor;
|
||||
use cros_async::AsyncWrapper;
|
||||
use cros_async::Executor;
|
||||
use vmm_vhost::connection::socket::Endpoint as SocketEndpoint;
|
||||
use vmm_vhost::connection::socket::SocketEndpoint;
|
||||
use vmm_vhost::message::MasterReq;
|
||||
use vmm_vhost::Error as VhostError;
|
||||
use vmm_vhost::Master;
|
||||
|
|
|
@ -8,8 +8,8 @@ pub(crate) mod tests {
|
|||
use tempfile::Builder;
|
||||
use tempfile::TempDir;
|
||||
|
||||
use crate::connection::socket::Endpoint as SocketEndpoint;
|
||||
use crate::connection::socket::Listener as SocketListener;
|
||||
use crate::connection::socket::SocketEndpoint;
|
||||
use crate::connection::Listener;
|
||||
use crate::master::Master;
|
||||
use crate::message::MasterReq;
|
||||
|
|
24
third_party/vmm_vhost/src/connection/socket.rs
vendored
24
third_party/vmm_vhost/src/connection/socket.rs
vendored
|
@ -73,7 +73,7 @@ impl Listener {
|
|||
|
||||
impl ListenerTrait for Listener {
|
||||
type Connection = SystemStream;
|
||||
type Endpoint = Endpoint<MasterReq>;
|
||||
type Endpoint = SocketEndpoint<MasterReq>;
|
||||
|
||||
/// Accept an incoming connection.
|
||||
///
|
||||
|
@ -85,7 +85,7 @@ impl ListenerTrait for Listener {
|
|||
loop {
|
||||
match self.fd.accept() {
|
||||
Ok((stream, _addr)) => {
|
||||
return Ok(Some(Endpoint {
|
||||
return Ok(Some(SocketEndpoint {
|
||||
sock: stream.try_into()?,
|
||||
_r: PhantomData,
|
||||
}))
|
||||
|
@ -122,12 +122,12 @@ impl AsRawDescriptor for Listener {
|
|||
}
|
||||
|
||||
/// Unix domain socket endpoint for vhost-user connection.
|
||||
pub struct Endpoint<R: Req> {
|
||||
pub struct SocketEndpoint<R: Req> {
|
||||
sock: ScmSocket<SystemStream>,
|
||||
_r: PhantomData<R>,
|
||||
}
|
||||
|
||||
impl<R: Req> From<SystemStream> for Endpoint<R> {
|
||||
impl<R: Req> From<SystemStream> for SocketEndpoint<R> {
|
||||
fn from(sock: SystemStream) -> Self {
|
||||
Self {
|
||||
sock: sock.try_into().unwrap(),
|
||||
|
@ -136,11 +136,11 @@ impl<R: Req> From<SystemStream> for Endpoint<R> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<R: Req> EndpointTrait<R> for Endpoint<R> {
|
||||
impl<R: Req> EndpointTrait<R> for SocketEndpoint<R> {
|
||||
/// Create a new stream by connecting to server at `str`.
|
||||
///
|
||||
/// # Return:
|
||||
/// * - the new Endpoint object on success.
|
||||
/// * - the new SocketEndpoint object on success.
|
||||
/// * - SocketConnect: failed to connect to peer.
|
||||
fn connect<P: AsRef<Path>>(path: P) -> Result<Self> {
|
||||
let sock = SystemStream::connect(path).map_err(Error::SocketConnect)?;
|
||||
|
@ -224,17 +224,17 @@ impl<R: Req> EndpointTrait<R> for Endpoint<R> {
|
|||
let file = take_single_file(files).ok_or(Error::InvalidMessage)?;
|
||||
// Safe because we own the file
|
||||
let tube = unsafe { SystemStream::from_raw_descriptor(file.into_raw_descriptor()) };
|
||||
Ok(Box::new(Endpoint::from(tube)))
|
||||
Ok(Box::new(SocketEndpoint::from(tube)))
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Req> AsRawDescriptor for Endpoint<T> {
|
||||
impl<T: Req> AsRawDescriptor for SocketEndpoint<T> {
|
||||
fn as_raw_descriptor(&self) -> RawDescriptor {
|
||||
self.sock.as_raw_descriptor()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Req> AsMut<SystemStream> for Endpoint<T> {
|
||||
impl<T: Req> AsMut<SystemStream> for SocketEndpoint<T> {
|
||||
fn as_mut(&mut self) -> &mut SystemStream {
|
||||
self.sock.inner_mut()
|
||||
}
|
||||
|
@ -290,7 +290,7 @@ mod tests {
|
|||
path.push("sock");
|
||||
let mut listener = Listener::new(&path, true).unwrap();
|
||||
listener.set_nonblocking(true).unwrap();
|
||||
let mut master = Endpoint::<MasterReq>::connect(&path).unwrap();
|
||||
let mut master = SocketEndpoint::<MasterReq>::connect(&path).unwrap();
|
||||
let mut slave = listener.accept().unwrap().unwrap();
|
||||
|
||||
let buf1 = [0x1, 0x2, 0x3, 0x4];
|
||||
|
@ -317,7 +317,7 @@ mod tests {
|
|||
path.push("sock");
|
||||
let mut listener = Listener::new(&path, true).unwrap();
|
||||
listener.set_nonblocking(true).unwrap();
|
||||
let mut master = Endpoint::<MasterReq>::connect(&path).unwrap();
|
||||
let mut master = SocketEndpoint::<MasterReq>::connect(&path).unwrap();
|
||||
let mut slave = listener.accept().unwrap().unwrap();
|
||||
|
||||
let mut fd = tempfile().unwrap();
|
||||
|
@ -489,7 +489,7 @@ mod tests {
|
|||
path.push("sock");
|
||||
let mut listener = Listener::new(&path, true).unwrap();
|
||||
listener.set_nonblocking(true).unwrap();
|
||||
let mut master = Endpoint::<MasterReq>::connect(&path).unwrap();
|
||||
let mut master = SocketEndpoint::<MasterReq>::connect(&path).unwrap();
|
||||
let mut slave = listener.accept().unwrap().unwrap();
|
||||
|
||||
let mut hdr1 =
|
||||
|
|
2
third_party/vmm_vhost/src/sys/linux.rs
vendored
2
third_party/vmm_vhost/src/sys/linux.rs
vendored
|
@ -15,7 +15,7 @@ pub type SystemStream = UnixStream;
|
|||
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(feature = "device")] {
|
||||
use crate::{connection::socket::Endpoint as SocketEndpoint};
|
||||
use crate::connection::socket::SocketEndpoint;
|
||||
use crate::message::{MasterReq, SlaveReq};
|
||||
|
||||
pub(crate) type SlaveReqEndpoint = SocketEndpoint<SlaveReq>;
|
||||
|
|
Loading…
Reference in a new issue