From 40e4dc6339a507cc8ab31bf2459df87d4aca5ad0 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 9 Apr 2020 13:14:05 +0200 Subject: [PATCH] vhost_user_backend: Change handle_event as immutable By changing the mutability of this function, after adapting all backends, we should be able to implement multithreads with multiqueues support without hitting a bottleneck on the backend locking. Signed-off-by: Sebastien Boeuf --- src/bin/vhost_user_fs.rs | 2 +- vhost_user_backend/src/lib.rs | 4 ++-- vhost_user_block/src/lib.rs | 2 +- vhost_user_net/src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/bin/vhost_user_fs.rs b/src/bin/vhost_user_fs.rs index 03a279ac2..002b2a49e 100644 --- a/src/bin/vhost_user_fs.rs +++ b/src/bin/vhost_user_fs.rs @@ -217,7 +217,7 @@ impl VhostUserBackend for VhostUserFsBack } fn handle_event( - &mut self, + &self, device_event: u16, evset: epoll::Events, vrings: &[Arc>], diff --git a/vhost_user_backend/src/lib.rs b/vhost_user_backend/src/lib.rs index 10184a175..1be1cb1f0 100644 --- a/vhost_user_backend/src/lib.rs +++ b/vhost_user_backend/src/lib.rs @@ -81,7 +81,7 @@ pub trait VhostUserBackend: Send + Sync + 'static { /// virtqueues on its own, but does not know what to do with events /// happening on custom listeners. fn handle_event( - &mut self, + &self, device_event: u16, evset: epoll::Events, vrings: &[Arc>], @@ -310,7 +310,7 @@ impl VringEpollHandler { } self.backend - .write() + .read() .unwrap() .handle_event(device_event, evset, &self.vrings) .map_err(VringEpollHandlerError::HandleEventBackendHandling) diff --git a/vhost_user_block/src/lib.rs b/vhost_user_block/src/lib.rs index 46d364622..7e44deea8 100644 --- a/vhost_user_block/src/lib.rs +++ b/vhost_user_block/src/lib.rs @@ -277,7 +277,7 @@ impl VhostUserBackend for VhostUserBlkBackend { } fn handle_event( - &mut self, + &self, device_event: u16, evset: epoll::Events, vrings: &[Arc>], diff --git a/vhost_user_net/src/lib.rs b/vhost_user_net/src/lib.rs index f3dc74e0c..cc76d8d73 100644 --- a/vhost_user_net/src/lib.rs +++ b/vhost_user_net/src/lib.rs @@ -307,7 +307,7 @@ impl VhostUserBackend for VhostUserNetBackend { } fn handle_event( - &mut self, + &self, device_event: u16, evset: epoll::Events, vrings: &[Arc>],