diff options
author | Alyssa Ross <hi@alyssa.is> | 2020-03-13 23:21:40 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-06-15 09:36:40 +0000 |
commit | 23dd7efca023fcb3c1e90486a48c1cb24f7f9951 (patch) | |
tree | 2554cef7688aff9a4c007a88999d29f4aef7f633 | |
parent | 94f83d7bafb86770555457d7a11f9b2b2cb7166c (diff) | |
download | crosvm-23dd7efca023fcb3c1e90486a48c1cb24f7f9951.tar crosvm-23dd7efca023fcb3c1e90486a48c1cb24f7f9951.tar.gz crosvm-23dd7efca023fcb3c1e90486a48c1cb24f7f9951.tar.bz2 crosvm-23dd7efca023fcb3c1e90486a48c1cb24f7f9951.tar.lz crosvm-23dd7efca023fcb3c1e90486a48c1cb24f7f9951.tar.xz crosvm-23dd7efca023fcb3c1e90486a48c1cb24f7f9951.tar.zst crosvm-23dd7efca023fcb3c1e90486a48c1cb24f7f9951.zip |
write_config
-rw-r--r-- | devices/src/virtio/controller.rs | 9 | ||||
-rw-r--r-- | src/wl.rs | 34 |
2 files changed, 28 insertions, 15 deletions
diff --git a/devices/src/virtio/controller.rs b/devices/src/virtio/controller.rs index a1656c6..04cde10 100644 --- a/devices/src/virtio/controller.rs +++ b/devices/src/virtio/controller.rs @@ -289,6 +289,15 @@ impl VirtioDevice for Controller { } } + fn write_config(&mut self, offset: u64, data: &[u8]) { + if let Err(e) = self.socket.send(BincodeRequest::WriteConfig { + offset, + data: data.to_vec(), + }) { + error!("failed to send WriteConfig: {}", e); + } + } + fn activate( &mut self, mem: GuestMemory, diff --git a/src/wl.rs b/src/wl.rs index 6b7f164..0598b4a 100644 --- a/src/wl.rs +++ b/src/wl.rs @@ -50,25 +50,27 @@ fn main() { let mut wayland_paths = BTreeMap::new(); wayland_paths.insert("".into(), "/run/user/1000/wayland-0".into()); - let mut wl = Some(Wl::new(wayland_paths, vm_socket, None).unwrap()); + let mut wl = Wl::new(wayland_paths, vm_socket, None).unwrap(); loop { + use poly_msg_socket::Value::*; match msg_socket.recv() { - Ok(poly_msg_socket::Value::MsgOnSocket(MsgOnSocketRequest::Kill)) => { - if let Some(wl) = wl.take() { - // Will block until worker shuts down. - drop(wl); - - if let Err(e) = msg_socket.send(MsgOnSocketResponse::Kill) { - error!("failed to send Response::Kill: {}", e); - break; - } - } else { - warn!("received Kill but no Wl is running"); + Ok(MsgOnSocket(MsgOnSocketRequest::Kill)) => { + // Will block until worker shuts down. + drop(wl); + + if let Err(e) = msg_socket.send(MsgOnSocketResponse::Kill) { + error!("failed to send Response::Kill: {}", e); } + + break; } - Ok(poly_msg_socket::Value::MsgOnSocket(MsgOnSocketRequest::Activate { + Ok(Bincode(BincodeRequest::WriteConfig { offset, ref data })) => { + wl.write_config(offset, data) + } + + Ok(MsgOnSocket(MsgOnSocketRequest::Activate { shm, interrupt, interrupt_resample_evt, @@ -86,7 +88,7 @@ fn main() { let interrupt: MsgSocket<InterruptProxyEvent, ()> = MsgSocket::new(interrupt.owned()); - wl.as_mut().unwrap().activate( + wl.activate( mem, Box::new(InterruptProxy::new( interrupt, @@ -99,7 +101,9 @@ fn main() { println!("activated Wl"); } - Ok(msg) => panic!("unexpected message {:?}", msg), + Ok(MsgOnSocket(msg @ MsgOnSocketRequest::Create { .. })) => { + panic!("unexpected message {:?}", msg) + } Err(e) => panic!("recv failed: {}", e), } |