vhost_user_backend: Allow for one exit_event per thread

By adding the "thread_index" parameter to the function exit_event() from
the VhostUserBackend trait, the backend crate now has the ability to ask
the backend implementation about the exit event related to a specific
thread.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2020-04-09 17:49:11 +02:00
parent b927dceed8
commit cfffb7edb0
4 changed files with 10 additions and 10 deletions

View File

@@ -105,7 +105,7 @@ pub trait VhostUserBackend: Send + Sync + 'static {
/// When this EventFd is written to the worker thread will exit. An optional id may
/// also be provided, if it not provided then the exit event will be first event id
/// after the last queue
fn exit_event(&self) -> Option<(EventFd, Option<u16>)> {
fn exit_event(&self, _thread_index: usize) -> Option<(EventFd, Option<u16>)> {
None
}
@@ -484,7 +484,7 @@ impl<S: VhostUserBackend> VhostUserHandler<S> {
let mut workers = Vec::new();
let mut worker_threads = Vec::new();
for queues_mask in queues_per_thread.iter() {
for (thread_index, queues_mask) in queues_per_thread.iter().enumerate() {
// Create the epoll file descriptor
let epoll_fd = epoll::create(true).map_err(VhostUserHandlerError::EpollCreateFd)?;
@@ -492,7 +492,7 @@ impl<S: VhostUserBackend> VhostUserHandler<S> {
let worker = vring_worker.clone();
let exit_event_id = if let Some((exit_event_fd, exit_event_id)) =
backend.read().unwrap().exit_event()
backend.read().unwrap().exit_event(thread_index)
{
let exit_event_id = exit_event_id.unwrap_or(num_queues as u16);
worker