diff options
-rw-r--r-- | Cargo.lock | 7 | ||||
-rw-r--r-- | devices/Cargo.toml | 1 | ||||
-rw-r--r-- | devices/src/lib.rs | 3 | ||||
-rw-r--r-- | devices/src/virtio/controller.rs | 16 | ||||
-rw-r--r-- | src/linux.rs | 13 |
5 files changed, 16 insertions, 24 deletions
diff --git a/Cargo.lock b/Cargo.lock index 2b6c00e..d236770 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -184,7 +184,6 @@ dependencies = [ "io_jail 0.1.0", "kvm 0.1.0", "kvm_sys 0.1.0", - "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)", "libcras 0.1.0", "libvda 0.1.0", @@ -405,11 +404,6 @@ dependencies = [ ] [[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] name = "libc" version = "0.2.44" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -833,7 +827,6 @@ dependencies = [ "checksum futures-task 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bae52d6b29cf440e298856fec3965ee6fa71b06aa7495178615953fd669e5f9" "checksum futures-util 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c0d66274fb76985d3c62c886d1da7ac4c0903a8c9f754e8fe0f35a6a6cc39e76" "checksum getopts 0.2.18 (registry+https://github.com/rust-lang/crates.io-index)" = "0a7292d30132fb5424b354f5dc02512a86e4c516fe544bb7a25e7f266951b797" -"checksum lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" "checksum libc 0.2.44 (registry+https://github.com/rust-lang/crates.io-index)" = "10923947f84a519a45c8fefb7dd1b3e8c08747993381adee176d7a82b4195311" "checksum log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)" = "d4fcce5fa49cc693c312001daf1d13411c4a5283796bac1084299ea3e567113f" "checksum memchr 2.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3197e20c7edb283f87c071ddfc7a2cca8f8e0b888c242959846a6fce03c72223" diff --git a/devices/Cargo.toml b/devices/Cargo.toml index a500cf8..8bea78d 100644 --- a/devices/Cargo.toml +++ b/devices/Cargo.toml @@ -49,7 +49,6 @@ vfio_sys = { path = "../vfio_sys" } vhost = { path = "../vhost" } virtio_sys = { path = "../virtio_sys" } vm_control = { path = "../vm_control" } -lazy_static = "1.4.0" [dev-dependencies] tempfile = { path = "../tempfile" } 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()), diff --git a/src/linux.rs b/src/linux.rs index 286d387..411d529 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -762,8 +762,17 @@ fn create_wayland_device( .collect::<Option<Vec<_>>>() .ok_or(Error::InvalidWaylandPath)?; - let dev = virtio::Controller::new(cfg.wayland_socket_paths.clone(), socket, resource_bridge) - .map_err(Error::WaylandDeviceNew)?; + let mut path = std::env::var("XDG_RUNTIME_DIR").expect("XDG_RUNTIME_DIR missing"); + path.push_str("/crosvm-wl.sock"); + let seq_socket = UnixSeqpacket::connect(&path).expect("connect failed"); + let msg_socket = MsgSocket::new(seq_socket); + let dev = virtio::Controller::new( + cfg.wayland_socket_paths.clone(), + socket, + resource_bridge, + msg_socket, + ) + .map_err(Error::WaylandDeviceNew)?; let jail = match simple_jail(&cfg, "wl_device")? { Some(mut jail) => { |