diff options
author | Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> | 2020-02-07 10:36:25 +0800 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2020-03-25 01:33:59 +0000 |
commit | 57b8201eeb75d9b2cbf424fa7a91d6738fe8610c (patch) | |
tree | c057756783df53b0c9df7cb237051754cb7df160 | |
parent | 02f58e6d74bc1926424de43e9caec707f17c1b80 (diff) | |
download | crosvm-57b8201eeb75d9b2cbf424fa7a91d6738fe8610c.tar crosvm-57b8201eeb75d9b2cbf424fa7a91d6738fe8610c.tar.gz crosvm-57b8201eeb75d9b2cbf424fa7a91d6738fe8610c.tar.bz2 crosvm-57b8201eeb75d9b2cbf424fa7a91d6738fe8610c.tar.lz crosvm-57b8201eeb75d9b2cbf424fa7a91d6738fe8610c.tar.xz crosvm-57b8201eeb75d9b2cbf424fa7a91d6738fe8610c.tar.zst crosvm-57b8201eeb75d9b2cbf424fa7a91d6738fe8610c.zip |
vhost: pass response_socket to activate thread
Pass the Option of the response socket should be used by the activate thread, to communicate with its device model. BUG=None TEST=cargo test -p devices Change-Id: I929f4c901468e920116f2a744ec73571d91080e3 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2046451 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
-rw-r--r-- | devices/src/virtio/vhost/net.rs | 7 | ||||
-rw-r--r-- | devices/src/virtio/vhost/vsock.rs | 1 | ||||
-rw-r--r-- | devices/src/virtio/vhost/worker.rs | 4 |
3 files changed, 12 insertions, 0 deletions
diff --git a/devices/src/virtio/vhost/net.rs b/devices/src/virtio/vhost/net.rs index 21f1587..cc9521a 100644 --- a/devices/src/virtio/vhost/net.rs +++ b/devices/src/virtio/vhost/net.rs @@ -204,6 +204,11 @@ where if let Some(vhost_interrupt) = self.vhost_interrupt.take() { if let Some(kill_evt) = self.workers_kill_evt.take() { let acked_features = self.acked_features; + let socket = if self.response_socket.is_some() { + self.response_socket.take() + } else { + None + }; let worker_result = thread::Builder::new() .name("vhost_net".to_string()) .spawn(move || { @@ -214,6 +219,7 @@ where interrupt, acked_features, kill_evt, + socket, ); let activate_vqs = |handle: &U| -> Result<()> { for idx in 0..NUM_QUEUES { @@ -284,6 +290,7 @@ where self.tap = Some(tap); self.vhost_interrupt = Some(worker.vhost_interrupt); self.workers_kill_evt = Some(worker.kill_evt); + self.response_socket = worker.response_socket; return true; } } diff --git a/devices/src/virtio/vhost/vsock.rs b/devices/src/virtio/vhost/vsock.rs index 03826ff..390c857 100644 --- a/devices/src/virtio/vhost/vsock.rs +++ b/devices/src/virtio/vhost/vsock.rs @@ -169,6 +169,7 @@ impl VirtioDevice for Vsock { interrupt, acked_features, kill_evt, + None, ); let activate_vqs = |handle: &VhostVsockHandle| -> Result<()> { handle.set_cid(cid).map_err(Error::VhostVsockSetCid)?; diff --git a/devices/src/virtio/vhost/worker.rs b/devices/src/virtio/vhost/worker.rs index 1eff01f..03c1066 100644 --- a/devices/src/virtio/vhost/worker.rs +++ b/devices/src/virtio/vhost/worker.rs @@ -7,6 +7,7 @@ use std::os::raw::c_ulonglong; use sys_util::{EventFd, PollContext, PollToken}; use vhost::Vhost; +use super::control_socket::VhostDevResponseSocket; use super::{Error, Result}; use crate::virtio::{Interrupt, Queue}; @@ -21,6 +22,7 @@ pub struct Worker<T: Vhost> { pub vhost_interrupt: Vec<EventFd>, acked_features: u64, pub kill_evt: EventFd, + pub response_socket: Option<VhostDevResponseSocket>, } impl<T: Vhost> Worker<T> { @@ -31,6 +33,7 @@ impl<T: Vhost> Worker<T> { interrupt: Interrupt, acked_features: u64, kill_evt: EventFd, + response_socket: Option<VhostDevResponseSocket>, ) -> Worker<T> { Worker { interrupt, @@ -39,6 +42,7 @@ impl<T: Vhost> Worker<T> { vhost_interrupt, acked_features, kill_evt, + response_socket, } } |