diff mbox

[1/3] virtio: add missing vdev->broken check

Message ID 1479333189-20082-2-git-send-email-stefanha@redhat.com
State New
Headers show

Commit Message

Stefan Hajnoczi Nov. 16, 2016, 9:53 p.m. UTC
virtio_queue_notify_vq() checks vdev->broken before invoking the
handler, virtio_queue_notify_aio_vq() should too.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 hw/virtio/virtio.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Cornelia Huck Nov. 17, 2016, 8:31 a.m. UTC | #1
On Wed, 16 Nov 2016 21:53:07 +0000
Stefan Hajnoczi <stefanha@redhat.com> wrote:

> virtio_queue_notify_vq() checks vdev->broken before invoking the
> handler, virtio_queue_notify_aio_vq() should too.
> 
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
>  hw/virtio/virtio.c | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>

I think this makes sense as a fix independent of your other patches.
Stefan Hajnoczi Nov. 17, 2016, 10:58 a.m. UTC | #2
On Thu, Nov 17, 2016 at 09:31:18AM +0100, Cornelia Huck wrote:
> On Wed, 16 Nov 2016 21:53:07 +0000
> Stefan Hajnoczi <stefanha@redhat.com> wrote:
> 
> > virtio_queue_notify_vq() checks vdev->broken before invoking the
> > handler, virtio_queue_notify_aio_vq() should too.
> > 
> > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > ---
> >  hw/virtio/virtio.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> 
> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> 
> I think this makes sense as a fix independent of your other patches.

I'm not aware of an actual bug caused by this.  virtio_queue_pop()
returns NULL when the device is broken.

This is more for consistency than correctness, so I didn't add
qemu-stable, -rc1, or send it as a separate fix.
Cornelia Huck Nov. 17, 2016, 12:24 p.m. UTC | #3
On Thu, 17 Nov 2016 10:58:30 +0000
Stefan Hajnoczi <stefanha@gmail.com> wrote:

> On Thu, Nov 17, 2016 at 09:31:18AM +0100, Cornelia Huck wrote:
> > On Wed, 16 Nov 2016 21:53:07 +0000
> > Stefan Hajnoczi <stefanha@redhat.com> wrote:
> > 
> > > virtio_queue_notify_vq() checks vdev->broken before invoking the
> > > handler, virtio_queue_notify_aio_vq() should too.
> > > 
> > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > > ---
> > >  hw/virtio/virtio.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > 
> > Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > 
> > I think this makes sense as a fix independent of your other patches.
> 
> I'm not aware of an actual bug caused by this.  virtio_queue_pop()
> returns NULL when the device is broken.
> 
> This is more for consistency than correctness, so I didn't add
> qemu-stable, -rc1, or send it as a separate fix.

Fair enough. It was more "we should add this patch even if we don't use
the other patches in this series".
Stefan Hajnoczi Nov. 18, 2016, 10:55 a.m. UTC | #4
On Thu, Nov 17, 2016 at 01:24:47PM +0100, Cornelia Huck wrote:
> On Thu, 17 Nov 2016 10:58:30 +0000
> Stefan Hajnoczi <stefanha@gmail.com> wrote:
> 
> > On Thu, Nov 17, 2016 at 09:31:18AM +0100, Cornelia Huck wrote:
> > > On Wed, 16 Nov 2016 21:53:07 +0000
> > > Stefan Hajnoczi <stefanha@redhat.com> wrote:
> > > 
> > > > virtio_queue_notify_vq() checks vdev->broken before invoking the
> > > > handler, virtio_queue_notify_aio_vq() should too.
> > > > 
> > > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> > > > ---
> > > >  hw/virtio/virtio.c | 4 ++++
> > > >  1 file changed, 4 insertions(+)
> > > 
> > > Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
> > > 
> > > I think this makes sense as a fix independent of your other patches.
> > 
> > I'm not aware of an actual bug caused by this.  virtio_queue_pop()
> > returns NULL when the device is broken.
> > 
> > This is more for consistency than correctness, so I didn't add
> > qemu-stable, -rc1, or send it as a separate fix.
> 
> Fair enough. It was more "we should add this patch even if we don't use
> the other patches in this series".

Okay.

Stefan
diff mbox

Patch

diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index 55a00cd..a4759bd 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1239,6 +1239,10 @@  static void virtio_queue_notify_aio_vq(VirtQueue *vq)
     if (vq->vring.desc && vq->handle_aio_output) {
         VirtIODevice *vdev = vq->vdev;
 
+        if (unlikely(vq->vdev->broken)) {
+            return;
+        }
+
         trace_virtio_queue_notify(vdev, vq - vdev->vq, vq);
         vq->handle_aio_output(vdev, vq);
     }