Skip to content

Commit f0a08a9

Browse files
jiangliuandreeaflorescu
authored andcommitted
virtio: avoid redundant invocation of Queue::is_valid()
The lifecycle of VirtIO queue object is as below: 1) MMIO transport driver creates queues 2) MMIO transport validates all queues are valid by calling Queue::is_valid() 3) Passing queues to VirtDevice by calling VirtDevice::activate() 4) VirtDevice device driver creates iterator to access available descritpors 5) MMIO transport reset the VirtDevice by calling VirtDevice::reset() 6) MMIO transport changes/destroys queues The MMIO transport driver won't touch those queues between stage 3 and stage 5, so Queue::is_valid will always return true during stage 4. Get rid of the redundant invocation of Queue::is_valid() in Queue::iter(). Signed-off-by: Liu Jiang <[email protected]>
1 parent 138760f commit f0a08a9

File tree

1 file changed

+0
-3
lines changed

1 file changed

+0
-3
lines changed

devices/src/virtio/queue.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,9 +322,6 @@ impl Queue {
322322

323323
/// A consuming iterator over all available descriptor chain heads offered by the driver.
324324
pub fn iter<'a, 'b>(&'b mut self, mem: &'a GuestMemory) -> AvailIter<'a, 'b> {
325-
if !self.is_valid(mem) {
326-
return AvailIter::new(mem, &mut self.next_avail);
327-
}
328325
let queue_size = self.actual_size();
329326
let avail_ring = self.avail_ring;
330327

0 commit comments

Comments
 (0)