From 03dd24978edec38399b1d6da6a94313fea5d4835 Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Tue, 21 Apr 2020 18:29:55 +0200 Subject: [PATCH] vm-virtio: Restore queues based on used index On the restore path, using the available and used indexes read from memory to fill the Queue structure was a mistake. Indeed, the available index is written from the guest and it reflects the last available index in the descriptor table. But the driver might have queued a lot of buffers which have not yet been used by the device. This leads to a situation where the next_avail from Queue is completely different from the one we can read from memory. Instead, the right way to determine the next_avail index that should be used by the device is by relying on the used index from the memory. This index represents the correct information we're looking for as it has been updated before the snapshot to let the guest know the next index to process. Signed-off-by: Sebastien Boeuf --- vm-virtio/src/transport/mmio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vm-virtio/src/transport/mmio.rs b/vm-virtio/src/transport/mmio.rs index b8a63ceb7..1001c5d41 100644 --- a/vm-virtio/src/transport/mmio.rs +++ b/vm-virtio/src/transport/mmio.rs @@ -175,7 +175,7 @@ impl MmioDevice { for queue in self.queues.iter_mut() { queue.next_avail = Wrapping( queue - .avail_index_from_memory(&mem) + .used_index_from_memory(&mem) .map_err(Error::QueueRingIndex)?, ); queue.next_used = Wrapping(