diff options
Diffstat (limited to 'devices/src/virtio/controller.rs')
-rw-r--r-- | devices/src/virtio/controller.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/devices/src/virtio/controller.rs b/devices/src/virtio/controller.rs index c131b6c..c29112d 100644 --- a/devices/src/virtio/controller.rs +++ b/devices/src/virtio/controller.rs @@ -57,15 +57,6 @@ pub struct Activate { type Socket = MsgSocket<Activate, ()>; -lazy_static! { - static ref SOCKET: Socket = { - let mut path = std::env::var("XDG_RUNTIME_DIR").expect("XDG_RUNTIME_DIR missing"); - path.push_str("/crosvm-wl.sock"); - let socket = UnixSeqpacket::connect(&path).expect("connect failed"); - MsgSocket::new(socket) - }; -} - const VIRTIO_WL_F_TRANS_FLAGS: u32 = 0x01; // TODO: support arbitrary number of queues @@ -109,6 +100,7 @@ pub struct Controller { vm_socket: Option<VmMemoryControlRequestSocket>, resource_bridge: Option<ResourceRequestSocket>, use_transition_flags: bool, + socket: Socket, } impl Controller { @@ -116,6 +108,7 @@ impl Controller { wayland_paths: Map<String, PathBuf>, vm_socket: VmMemoryControlRequestSocket, resource_bridge: Option<ResourceRequestSocket>, + socket: Socket, ) -> Result<Controller> { Ok(Controller { kill_evt: None, @@ -124,6 +117,7 @@ impl Controller { vm_socket: Some(vm_socket), resource_bridge, use_transition_flags: false, + socket, }) } } @@ -156,7 +150,7 @@ impl VirtioDevice for Controller { keep_fds.push(kill_evt.as_raw_fd()); } - keep_fds.push(SOCKET.as_raw_fd()); + keep_fds.push(self.socket.as_raw_fd()); keep_fds } @@ -206,7 +200,7 @@ impl VirtioDevice for Controller { let (ours, theirs) = UnixSeqpacket::pair().expect("pair failed"); - if let Err(e) = SOCKET.send(&Activate { + if let Err(e) = self.socket.send(&Activate { shm: MaybeOwnedFd::new_borrowed(&mem), interrupt: MaybeOwnedFd::new_borrowed(&theirs), interrupt_resample_evt: MaybeOwnedFd::new_borrowed(interrupt.get_resample_evt()), |