virtio-devices: Pass a list of tuples for virtqueues

Instead of passing separately a list of Queues and the equivalent list
of EventFds, we consolidate these two through a tuple along with the
queue index.

The queue index can be very useful if looking for the actual index
related to the queue, no matter if other queues have been enabled or
not.

It's also convenient to have the EventFd associated with the Queue so
that we don't have to carry two lists with the same amount of items.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-07-20 16:45:49 +02:00
parent 423c54eafe
commit 3f62a172b2
20 changed files with 154 additions and 145 deletions

View File

@@ -587,18 +587,16 @@ impl VirtioDevice for Block {
&mut self,
mem: GuestMemoryAtomic<GuestMemoryMmap>,
interrupt_cb: Arc<dyn VirtioInterrupt>,
mut queues: Vec<Queue<GuestMemoryAtomic<GuestMemoryMmap>>>,
mut queue_evts: Vec<EventFd>,
mut queues: Vec<(usize, Queue<GuestMemoryAtomic<GuestMemoryMmap>>, EventFd)>,
) -> ActivateResult {
self.common.activate(&queues, &queue_evts, &interrupt_cb)?;
self.common.activate(&queues, &interrupt_cb)?;
let disk_image_id = build_disk_image_id(&self.disk_path);
self.update_writeback();
let mut epoll_threads = Vec::new();
for i in 0..queues.len() {
let queue_evt = queue_evts.remove(0);
let queue = queues.remove(0);
let (_, queue, queue_evt) = queues.remove(0);
let queue_size = queue.state.size;
let (kill_evt, pause_evt) = self.common.dup_eventfds();