diff options
author | Jakub Staron <jstaron@google.com> | 2019-04-09 12:31:14 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-04-10 02:20:58 -0700 |
commit | e7c590507c26116b2f8c63b226b0b60839ecbeff (patch) | |
tree | e42b29942035bb7b4f83e85c0e2046edca281df7 /devices/src | |
parent | 902e7c8450978ddf800b5a311f570aa982ff2ba4 (diff) | |
download | crosvm-e7c590507c26116b2f8c63b226b0b60839ecbeff.tar crosvm-e7c590507c26116b2f8c63b226b0b60839ecbeff.tar.gz crosvm-e7c590507c26116b2f8c63b226b0b60839ecbeff.tar.bz2 crosvm-e7c590507c26116b2f8c63b226b0b60839ecbeff.tar.lz crosvm-e7c590507c26116b2f8c63b226b0b60839ecbeff.tar.xz crosvm-e7c590507c26116b2f8c63b226b0b60839ecbeff.tar.zst crosvm-e7c590507c26116b2f8c63b226b0b60839ecbeff.zip |
Wrap the UnixSeqpacket with a more descriptive type.
Host/device sockets are now created as a pairs of MsgSockets instead of UnixSeqpacket sockets. BUG=chromium:950663 TEST=cargo check TEST=cargo test Change-Id: I8f61a711fe3c2547bf5d18fcfa23bfd0dc0ef5fd Reviewed-on: https://chromium-review.googlesource.com/1559041 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Jakub Staroń <jstaron@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'devices/src')
-rw-r--r-- | devices/src/virtio/block.rs | 21 | ||||
-rw-r--r-- | devices/src/virtio/wl.rs | 21 |
2 files changed, 21 insertions, 21 deletions
diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs index 71e7e4b..023e1df 100644 --- a/devices/src/virtio/block.rs +++ b/devices/src/virtio/block.rs @@ -18,13 +18,13 @@ use sync::Mutex; use sys_util::Error as SysError; use sys_util::Result as SysResult; use sys_util::{ - net::UnixSeqpacket, EventFd, FileSetLen, FileSync, GuestAddress, GuestMemory, GuestMemoryError, - PollContext, PollToken, PunchHole, TimerFd, WriteZeroes, + EventFd, FileSetLen, FileSync, GuestAddress, GuestMemory, GuestMemoryError, PollContext, + PollToken, PunchHole, TimerFd, WriteZeroes, }; use data_model::{DataInit, Le16, Le32, Le64}; -use msg_socket::{MsgReceiver, MsgSender, MsgSocket}; -use vm_control::{VmRequest, VmResponse}; +use msg_socket::{MsgReceiver, MsgSender}; +use vm_control::{VmControlResponseSocket, VmRequest, VmResponse}; use super::{ DescriptorChain, Queue, VirtioDevice, INTERRUPT_STATUS_CONFIG_CHANGED, @@ -695,7 +695,12 @@ impl<T: DiskFile> Worker<T> { self.interrupt_evt.write(1).unwrap(); } - fn run(&mut self, queue_evt: EventFd, kill_evt: EventFd, control_socket: UnixSeqpacket) { + fn run( + &mut self, + queue_evt: EventFd, + kill_evt: EventFd, + control_socket: VmControlResponseSocket, + ) { #[derive(PollToken)] enum Token { FlushTimer, @@ -714,8 +719,6 @@ impl<T: DiskFile> Worker<T> { }; let mut flush_timer_armed = false; - let control_socket = MsgSocket::<VmResponse, VmRequest>::new(control_socket); - let poll_ctx: PollContext<Token> = match PollContext::new() .and_then(|pc| pc.add(&flush_timer, Token::FlushTimer).and(Ok(pc))) .and_then(|pc| pc.add(&queue_evt, Token::QueueAvailable).and(Ok(pc))) @@ -819,7 +822,7 @@ pub struct Block<T: DiskFile> { disk_size: Arc<Mutex<u64>>, avail_features: u64, read_only: bool, - control_socket: Option<UnixSeqpacket>, + control_socket: Option<VmControlResponseSocket>, } fn build_config_space(disk_size: u64) -> virtio_blk_config { @@ -845,7 +848,7 @@ impl<T: DiskFile> Block<T> { pub fn new( mut disk_image: T, read_only: bool, - control_socket: Option<UnixSeqpacket>, + control_socket: Option<VmControlResponseSocket>, ) -> SysResult<Block<T>> { let disk_size = disk_image.seek(SeekFrom::End(0))? as u64; if disk_size % SECTOR_SIZE != 0 { diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs index 870b5ea..4a6d59d 100644 --- a/devices/src/virtio/wl.rs +++ b/devices/src/virtio/wl.rs @@ -56,10 +56,9 @@ use libc::{dup, EBADF, EINVAL}; use data_model::VolatileMemoryError; use data_model::*; -use msg_socket::{MsgError, MsgReceiver, MsgSender, MsgSocket}; +use msg_socket::{MsgError, MsgReceiver, MsgSender}; #[cfg(feature = "wl-dmabuf")] use resources::GpuMemoryDesc; -use sys_util::net::UnixSeqpacket; use sys_util::{ pipe, round_up_to_page_size, Error, EventFd, FileFlags, GuestAddress, GuestMemory, GuestMemoryError, PollContext, PollToken, Result, ScmSocket, SharedMemory, @@ -72,7 +71,7 @@ use super::resource_bridge::*; use super::{ DescriptorChain, Queue, VirtioDevice, INTERRUPT_STATUS_USED_RING, TYPE_WL, VIRTIO_F_VERSION_1, }; -use vm_control::{MaybeOwnedFd, VmRequest, VmResponse}; +use vm_control::{MaybeOwnedFd, VmControlRequestSocket, VmRequest, VmResponse}; const VIRTWL_SEND_MAX_ALLOCS: usize = 28; const VIRTIO_WL_CMD_VFD_NEW: u32 = 256; @@ -485,15 +484,13 @@ impl From<VolatileMemoryError> for WlError { #[derive(Clone)] struct VmRequester { - inner: Rc<RefCell<MsgSocket<VmRequest, VmResponse>>>, + inner: Rc<RefCell<VmControlRequestSocket>>, } impl VmRequester { - fn new(vm_socket: UnixSeqpacket) -> VmRequester { + fn new(vm_socket: VmControlRequestSocket) -> VmRequester { VmRequester { - inner: Rc::new(RefCell::new(MsgSocket::<VmRequest, VmResponse>::new( - vm_socket, - ))), + inner: Rc::new(RefCell::new(vm_socket)), } } @@ -1003,7 +1000,7 @@ struct WlState { impl WlState { fn new( wayland_path: PathBuf, - vm_socket: UnixSeqpacket, + vm_socket: VmControlRequestSocket, use_transition_flags: bool, resource_bridge: Option<ResourceRequestSocket>, ) -> WlState { @@ -1487,7 +1484,7 @@ impl Worker { in_queue: Queue, out_queue: Queue, wayland_path: PathBuf, - vm_socket: UnixSeqpacket, + vm_socket: VmControlRequestSocket, use_transition_flags: bool, resource_bridge: Option<ResourceRequestSocket>, ) -> Worker { @@ -1677,7 +1674,7 @@ impl Worker { pub struct Wl { kill_evt: Option<EventFd>, wayland_path: PathBuf, - vm_socket: Option<UnixSeqpacket>, + vm_socket: Option<VmControlRequestSocket>, resource_bridge: Option<ResourceRequestSocket>, use_transition_flags: bool, } @@ -1685,7 +1682,7 @@ pub struct Wl { impl Wl { pub fn new<P: AsRef<Path>>( wayland_path: P, - vm_socket: UnixSeqpacket, + vm_socket: VmControlRequestSocket, resource_bridge: Option<ResourceRequestSocket>, ) -> Result<Wl> { Ok(Wl { |