virtio-devices: Improve queue handling with pop_descriptor_chain()

Using pop_descriptor_chain() is much more appropriate than iter() since
it recreates the iterator every time, avoiding the queue to be borrowed
and allowing the virtio-net implementation to match all the other ones.

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf
2022-07-08 14:30:50 +02:00
committed by Rob Bradford
parent a423bf13ad
commit 87f57f7c1e
12 changed files with 271 additions and 302 deletions
+2 -2
View File
@@ -35,7 +35,7 @@ use std::sync::mpsc;
use std::sync::{Arc, Barrier, Mutex};
use versionize::{VersionMap, Versionize, VersionizeResult};
use versionize_derive::Versionize;
use virtio_queue::{DescriptorChain, Queue, QueueOwnedT, QueueT};
use virtio_queue::{DescriptorChain, Queue, QueueT};
use vm_device::dma_mapping::ExternalDmaMapping;
use vm_memory::{
Address, ByteValued, Bytes, GuestAddress, GuestAddressSpace, GuestMemoryAtomic,
@@ -668,7 +668,7 @@ impl MemEpollHandler {
let mut request_list = Vec::new();
let mut used_count = 0;
for mut desc_chain in self.queue.iter(self.mem.memory()).unwrap() {
while let Some(mut desc_chain) = self.queue.pop_descriptor_chain(self.mem.memory()) {
request_list.push((
desc_chain.head_index(),
Request::parse(&mut desc_chain),