Skip to contentSkip to conversation

virtio: check for vring setup in virtio_queue_empty

PATCH In review Paolo Bonzini 3 participants 3 messages Feb 23, 2017 – Feb 27, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: check for vring setup in virtio_queue_empty

If the vring has not been set up, there is nothing in the virtqueue. virtio_queue_host_notifier_aio_poll calls virtio_queue_empty even in this case; we have to filter it out just like virtio_queue_notify_aio_vq.

---
 hw/virtio/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio.c +1 -1
index 23483c7..e487e36 100644
@@ -2291,7 +2291,7 @@ static bool virtio_queue_host_notifier_aio_poll(void *opaque)
     VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
     bool progress;
 
-    if (virtio_queue_empty(vq)) {
+    if (!vq->vring.desc || virtio_queue_empty(vq)) {
         return false;
     }
 
Signature · 1 line
2.9.3
Tested-by on v1 1/1
#1 lore raw
Quoted 17 lines · Paolo Bonzini

If the vring has not been set up, there is nothing in the virtqueue. virtio_queue_host_notifier_aio_poll calls virtio_queue_empty even in this case; we have to filter it out just like virtio_queue_notify_aio_vq.

---
 hw/virtio/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio.c +0 -0
index 23483c7..e487e36 100644

hw/virtio/virtio.c static bool virtio_queue_host_notifier_aio_poll(void *opaque) · line 2297

Quoted 8 lines
hw/virtio/virtio.c +1 -1
@@ -2291,7 +2291,7 @@ static bool virtio_queue_host_notifier_aio_poll(void *opaque)
     VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
     bool progress;
 
-    if (virtio_queue_empty(vq)) {
+    if (!vq->vring.desc || virtio_queue_empty(vq)) {
         return false;
     }
 

Thanks!
Laszlo

Tested-by on v1 1/1
#2 lore raw
In reply to Paolo Bonzini
Quoted 16 lines · On Thu, 23 Feb 2017 09:51:30 +0100 Paolo Bonzini <[email protected]> wrote:

If the vring has not been set up, there is nothing in the virtqueue. virtio_queue_host_notifier_aio_poll calls virtio_queue_empty even in this case; we have to filter it out just like virtio_queue_notify_aio_vq.

---
 hw/virtio/virtio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/virtio/virtio.c +0 -0
index 23483c7..e487e36 100644

hw/virtio/virtio.c static bool virtio_queue_host_notifier_aio_poll(void *opaque) · line 2297

Quoted 8 lines
hw/virtio/virtio.c +1 -1
@@ -2291,7 +2291,7 @@ static bool virtio_queue_host_notifier_aio_poll(void *opaque)
     VirtQueue *vq = container_of(n, VirtQueue, host_notifier);
     bool progress;
 
-    if (virtio_queue_empty(vq)) {
+    if (!vq->vring.desc || virtio_queue_empty(vq)) {
         return false;
     }
 

...although it is not sufficient...