virtio: add ability to iterate over vqs
authorMichael S. Tsirkin <mst@redhat.com>
Fri, 20 Apr 2018 17:22:40 +0000 (20:22 +0300)
committerSasha Levin <alexander.levin@microsoft.com>
Wed, 23 May 2018 01:36:37 +0000 (21:36 -0400)
[ Upstream commit 24a7e4d20783c0514850f24a5c41ede46ab058f0 ]

For cleanup it's helpful to be able to simply scan all vqs and discard
all data. Add an iterator to do that.

Cc: stable@vger.kernel.org
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
include/linux/virtio.h

index 8f4d4bfa6d46084d8bea6aa3181f7bd7184fc58c..d7844d2153817710b411d47529c7c2f9c1fc43c5 100644 (file)
@@ -124,6 +124,9 @@ int virtio_device_freeze(struct virtio_device *dev);
 int virtio_device_restore(struct virtio_device *dev);
 #endif
 
+#define virtio_device_for_each_vq(vdev, vq) \
+       list_for_each_entry(vq, &vdev->vqs, list)
+
 /**
  * virtio_driver - operations for a virtio I/O driver
  * @driver: underlying device driver (populate name and owner).