virtio-blk: handle virtio_blk_handle_request() errors
commit20ea686a0cacdec1bde9a39e74afd38bf672424d
authorGreg Kurz <groug@kaod.org>
Fri, 30 Sep 2016 15:13:07 +0000 (30 17:13 +0200)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 9 Oct 2016 22:16:59 +0000 (10 01:16 +0300)
tree7932a023d98f87301b5412d480e15ae63cdbad85
parentd3d74d6fe095e2e49d030e0c163cecfb9c20f1d4
virtio-blk: handle virtio_blk_handle_request() errors

All these errors are caused by a buggy guest: QEMU should not exit.

With this patch, if virtio_blk_handle_request() detects a buggy request, it
marks the device as broken and returns an error to the caller so it takes
appropriate action.

In the case of virtio_blk_handle_vq(), we detach the request from the
virtqueue, free its allocated memory and stop popping new requests.
We don't need to bother about multireq since virtio_blk_handle_request()
errors out early and mrb.num_reqs == 0.

In the case of virtio_blk_dma_restart_bh(), we need to detach and free all
queued requests as well.

Signed-off-by: Greg Kurz <groug@kaod.org>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/block/virtio-blk.c