diff options
Diffstat (limited to 'src/linux.rs')
-rw-r--r-- | src/linux.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/linux.rs b/src/linux.rs index d5e12cd..3ef323e 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -11,6 +11,7 @@ use std::ffi::{CStr, OsString}; use std::fmt::{self, Display}; use std::fs::{File, OpenOptions}; use std::io::{self, stdin, Read}; +use std::iter::once; use std::mem; use std::net::Ipv4Addr; #[cfg(feature = "gpu")] @@ -61,7 +62,8 @@ use vm_control::{ DiskControlResult, UsbControlSocket, VmControlResponseSocket, VmIrqRequest, VmIrqResponse, VmIrqResponseSocket, VmMemoryControlRequestSocket, VmMemoryControlResponseSocket, VmMemoryRequest, VmMemoryResponse, VmMsyncRequest, VmMsyncRequestSocket, VmMsyncResponse, - VmMsyncResponseSocket, VmRequest, VmRunMode, + VmMsyncResponseSocket, VmRequest, VmRunMode, WlControlCommand, WlControlRequestSocket, + WlControlResponseSocket, WlControlResult, }; use crate::{Config, DiskOption, Executable, SharedDir, SharedDirKind, TouchDeviceOption}; @@ -772,6 +774,7 @@ fn create_wayland_device( vm_socket: VmMemoryControlRequestSocket, resource_bridge: Option<virtio::resource_bridge::ResourceRequestSocket>, memory_params: MemoryParams, + control_socket: WlControlResponseSocket, ) -> DeviceResult { let mut wayland_socket_paths = cfg.wayland_socket_paths.clone(); @@ -799,6 +802,7 @@ fn create_wayland_device( wayland_paths: wayland_socket_paths.clone(), vm_socket, resource_bridge, + control_socket, }) .unwrap(), ), @@ -1100,6 +1104,7 @@ fn create_virtio_devices( balloon_device_control_socket: BalloonControlResponseSocket, disk_device_control_sockets: &mut Vec<DiskControlResponseSocket>, pmem_device_control_sockets: &mut Vec<VmMsyncRequestSocket>, + wl_device_control_socket: WlControlResponseSocket, ) -> DeviceResult<Vec<VirtioDeviceStub>> { let mut devs = Vec::new(); @@ -1194,6 +1199,7 @@ fn create_virtio_devices( wayland_device_control_socket, wl_resource_bridge, mem_params, + wl_device_control_socket, )?); } @@ -1307,6 +1313,7 @@ fn create_devices( disk_device_control_sockets: &mut Vec<DiskControlResponseSocket>, pmem_device_control_sockets: &mut Vec<VmMsyncRequestSocket>, usb_provider: HostBackendDeviceProvider, + wl_device_control_socket: WlControlResponseSocket, ) -> DeviceResult<Vec<(Box<dyn PciDevice>, Option<Minijail>)>> { let stubs = create_virtio_devices( &cfg, @@ -1321,6 +1328,7 @@ fn create_devices( balloon_device_control_socket, disk_device_control_sockets, pmem_device_control_sockets, + wl_device_control_socket, )?; let mut pci_devices = Vec::new(); @@ -1852,6 +1860,9 @@ pub fn run_config(cfg: Config) -> Result<()> { msg_socket::pair::<VmIrqResponse, VmIrqRequest>().map_err(Error::CreateSocket)?; control_sockets.push(TaggedControlSocket::VmIrq(ioapic_host_socket)); + let (wl_host_socket, wl_device_control_socket) = + msg_socket::pair::<WlControlCommand, WlControlResult>().map_err(Error::CreateSocket)?; + let mut servers = vec![]; let mut memfd_socket_path = None; @@ -1899,6 +1910,7 @@ pub fn run_config(cfg: Config) -> Result<()> { &mut disk_device_control_sockets, &mut pmem_device_control_sockets, usb_provider, + wl_device_control_socket, ) }, ) @@ -1911,6 +1923,7 @@ pub fn run_config(cfg: Config) -> Result<()> { balloon_host_socket, &disk_host_sockets, usb_control_socket, + wl_host_socket, sigchld_fd, sandbox, ) @@ -1923,6 +1936,7 @@ fn run_control( balloon_host_socket: BalloonControlRequestSocket, disk_host_sockets: &[DiskControlRequestSocket], usb_control_socket: UsbControlSocket, + wl_host_socket: WlControlRequestSocket, sigchld_fd: SignalFd, sandbox: bool, ) -> Result<()> { @@ -2049,7 +2063,7 @@ fn run_control( // to the event loop, so that when they become ready, we can process their queues. After the // initial queue is processed, the device becomes ready, and the socket is removed from the // event loop. - for socket in disk_host_sockets.iter().map(AsRef::as_ref) { + for socket in once(wl_host_socket.as_ref()).chain(disk_host_sockets.iter().map(AsRef::as_ref)) { let token = Token::DeviceReady { sock_fd: socket.as_raw_fd(), }; @@ -2261,6 +2275,7 @@ fn run_control( &balloon_host_socket, &disk_host_sockets, &usb_control_socket, + &wl_host_socket, ); match device_socket |