virtio-devices: Pull correct EventFd from queue_evts list

When preparing the activator, we must provide the correct queue index to
clone the right EventFd associated with the queue.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2022-07-20 14:57:39 +02:00
parent e1a63822fa
commit 423c54eafe

View File

@ -699,15 +699,20 @@ impl VirtioPciDevice {
}
fn prepare_activator(&mut self, barrier: Option<Arc<Barrier>>) -> VirtioPciDeviceActivator {
let mut queues = Vec::new();
let mut queue_evts = Vec::new();
let mut queues: Vec<Queue<GuestMemoryAtomic<GuestMemoryMmap>>> =
self.queues.iter().map(vm_virtio::clone_queue).collect();
queues.retain(|q| q.state.ready);
for (i, queue) in queues.iter().enumerate() {
queue_evts.push(self.queue_evts[i].try_clone().unwrap());
if !queue.is_valid() {
error!("Queue {} is not valid", i);
for (queue_index, queue) in self.queues.iter().enumerate() {
if !queue.state.ready {
continue;
}
if !queue.is_valid() {
error!("Queue {} is not valid", queue_index);
}
queues.push(vm_virtio::clone_queue(queue));
queue_evts.push(self.queue_evts[queue_index].try_clone().unwrap());
}
VirtioPciDeviceActivator {
@ -716,12 +721,7 @@ impl VirtioPciDevice {
device: self.device.clone(),
queues: Some(queues),
device_activated: self.device_activated.clone(),
queue_evts: Some(
queue_evts
.iter()
.map(|fd| fd.try_clone().unwrap())
.collect(),
),
queue_evts: Some(queue_evts),
barrier,
id: self.id.clone(),
}