summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-03-12 01:04:03 +0000
committerAlyssa Ross <hi@alyssa.is>2020-06-15 09:36:24 +0000
commita24b1e1c1d287b5de7946a6225f2ef9326c433b3 (patch)
tree01ca117855e908c148fe2d8ecce09a6aab81dc93 /src
parent9ecffa4880b741d0de23c6d0ee4755bd66db01fb (diff)
downloadcrosvm-a24b1e1c1d287b5de7946a6225f2ef9326c433b3.tar
crosvm-a24b1e1c1d287b5de7946a6225f2ef9326c433b3.tar.gz
crosvm-a24b1e1c1d287b5de7946a6225f2ef9326c433b3.tar.bz2
crosvm-a24b1e1c1d287b5de7946a6225f2ef9326c433b3.tar.lz
crosvm-a24b1e1c1d287b5de7946a6225f2ef9326c433b3.tar.xz
crosvm-a24b1e1c1d287b5de7946a6225f2ef9326c433b3.tar.zst
crosvm-a24b1e1c1d287b5de7946a6225f2ef9326c433b3.zip
forward kill to/from wl
Diffstat (limited to 'src')
-rw-r--r--src/wl.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/wl.rs b/src/wl.rs
index 1e3b0a3..1874929 100644
--- a/src/wl.rs
+++ b/src/wl.rs
@@ -1,10 +1,10 @@
 // SPDX-License-Identifier: BSD-3-Clause
 
-use devices::virtio::{Activate, InterruptProxy, InterruptProxyEvent, VirtioDevice, Wl};
-use msg_socket::{MsgReceiver, MsgSocket};
+use devices::virtio::{InterruptProxy, InterruptProxyEvent, Request, Response, VirtioDevice, Wl};
+use msg_socket::{MsgReceiver, MsgSender, MsgSocket};
 use std::collections::BTreeMap;
 use std::fs::remove_file;
-use sys_util::{net::UnixSeqpacketListener, GuestMemory};
+use sys_util::{error, net::UnixSeqpacketListener, warn, GuestMemory};
 use vm_control::VmMemoryControlRequestSocket;
 
 #[cfg(any(target_arch = "arm", target_arch = "aarch64"))]
@@ -12,7 +12,7 @@ pub use aarch64::{arch_memory_regions, MemoryParams};
 #[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
 pub use x86_64::{arch_memory_regions, MemoryParams};
 
-type Socket = MsgSocket<(), Activate>;
+type Socket = MsgSocket<Response, Request>;
 
 fn main() {
     eprintln!("hello world");
@@ -32,7 +32,21 @@ fn main() {
 
     loop {
         match msg_socket.recv() {
-            Ok(Activate {
+            Ok(Request::Kill) => {
+                if let Some(wl) = wl.take() {
+                    // Will block until worker shuts down.
+                    drop(wl);
+
+                    if let Err(e) = msg_socket.send(&Response::Kill) {
+                        error!("failed to send Response::Kill: {}", e);
+                        break;
+                    }
+                } else {
+                    warn!("received Kill but no Wl is running");
+                }
+            }
+
+            Ok(Request::Activate {
                 shm,
                 interrupt,
                 interrupt_resample_evt,