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

@@ -337,17 +337,17 @@ impl VhostUserBackend for VhostUserNetBackend {
Ok(false)
}
fn exit_event(&self) -> Option<(EventFd, Option<u16>)> {
let tap_end_index = (self.num_queues + self.num_queues / 2 - 1) as u16;
let kill_index = tap_end_index + 1;
fn exit_event(&self, thread_index: usize) -> Option<(EventFd, Option<u16>)> {
// The exit event is placed after the queues and the tap event, which
// is event index 3.
Some((
self.threads[0]
self.threads[thread_index]
.lock()
.unwrap()
.kill_evt
.try_clone()
.unwrap(),
Some(kill_index),
Some(3),
))
}
}