diff options
author | Keiichi Watanabe <keiichiw@chromium.org> | 2020-01-22 19:35:02 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-02-03 12:33:52 +0000 |
commit | 392b73cdbc3c862cf4ffaa0cace19d22077c5648 (patch) | |
tree | db73f0df31ee95e241a3fecbaaf48680d30f16d8 /devices/src/virtio/wl.rs | |
parent | 327fc2454cdfe36fb612c73c9994435b8602c81a (diff) | |
download | crosvm-392b73cdbc3c862cf4ffaa0cace19d22077c5648.tar crosvm-392b73cdbc3c862cf4ffaa0cace19d22077c5648.tar.gz crosvm-392b73cdbc3c862cf4ffaa0cace19d22077c5648.tar.bz2 crosvm-392b73cdbc3c862cf4ffaa0cace19d22077c5648.tar.lz crosvm-392b73cdbc3c862cf4ffaa0cace19d22077c5648.tar.xz crosvm-392b73cdbc3c862cf4ffaa0cace19d22077c5648.tar.zst crosvm-392b73cdbc3c862cf4ffaa0cace19d22077c5648.zip |
devices: virtio: Add a function to get a FD via resource_bridge
Add a function to get a resource FD via resource_bridge by extracting code from the wayland device implementation. This function will be used by virtio-video devices. BUG=b:147465619 TEST=Run ARCVM and check that a window is displayed Change-Id: I7b064c9a04bd082e30dd488d0b14731228e6047d Signed-off-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2014520 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Diffstat (limited to 'devices/src/virtio/wl.rs')
-rw-r--r-- | devices/src/virtio/wl.rs | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/devices/src/virtio/wl.rs b/devices/src/virtio/wl.rs index 5bbd914..5ace29c 100644 --- a/devices/src/virtio/wl.rs +++ b/devices/src/virtio/wl.rs @@ -1092,26 +1092,18 @@ impl WlState { }, #[cfg(feature = "gpu")] VIRTIO_WL_CTRL_VFD_SEND_KIND_VIRTGPU if self.resource_bridge.is_some() => { - if let Err(e) = self - .resource_bridge - .as_ref() - .unwrap() - .send(&ResourceRequest::GetResource { id }) - { - error!("error sending resource bridge request: {}", e); - return Ok(WlResp::InvalidId); - } - match self.resource_bridge.as_ref().unwrap().recv() { - Ok(ResourceResponse::Resource(bridged_file)) => { + let sock = self.resource_bridge.as_ref().unwrap(); + match get_resource_fd(sock, id) { + Ok(bridged_file) => { *fd = bridged_file.as_raw_fd(); bridged_files.push(bridged_file); } - Ok(ResourceResponse::Invalid) => { - warn!("attempt to send non-existant gpu resource {}", id); + Err(ResourceBridgeError::InvalidResource(id)) => { + warn!("attempt to send non-existent gpu resource {}", id); return Ok(WlResp::InvalidId); } Err(e) => { - error!("error receiving resource bridge response: {}", e); + error!("{}", e); // If there was an error with the resource bridge, it can no longer be // trusted to continue to function. self.resource_bridge = None; |