summary refs log tree commit diff
path: root/devices/src
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-03-11 20:36:11 +0000
committerAlyssa Ross <hi@alyssa.is>2020-06-15 09:36:22 +0000
commit9ecffa4880b741d0de23c6d0ee4755bd66db01fb (patch)
tree324b1ef3442d2f2ecc7113a1b9d311641e99bbed /devices/src
parent4140a7d1871bae2d73a1fe6955af75ac07e7e86f (diff)
downloadcrosvm-9ecffa4880b741d0de23c6d0ee4755bd66db01fb.tar
crosvm-9ecffa4880b741d0de23c6d0ee4755bd66db01fb.tar.gz
crosvm-9ecffa4880b741d0de23c6d0ee4755bd66db01fb.tar.bz2
crosvm-9ecffa4880b741d0de23c6d0ee4755bd66db01fb.tar.lz
crosvm-9ecffa4880b741d0de23c6d0ee4755bd66db01fb.tar.xz
crosvm-9ecffa4880b741d0de23c6d0ee4755bd66db01fb.tar.zst
crosvm-9ecffa4880b741d0de23c6d0ee4755bd66db01fb.zip
drop lazy_static
Diffstat (limited to 'devices/src')
-rw-r--r--devices/src/lib.rs3
-rw-r--r--devices/src/virtio/controller.rs16
2 files changed, 5 insertions, 14 deletions
diff --git a/devices/src/lib.rs b/devices/src/lib.rs
index d648ac2..294a8cb 100644
--- a/devices/src/lib.rs
+++ b/devices/src/lib.rs
@@ -4,9 +4,6 @@
 
 //! Emulates virtual and hardware devices.
 
-#[macro_use]
-extern crate lazy_static;
-
 mod bus;
 mod cmos;
 mod i8042;
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()),