virtio-blk: report non-zero status when failing SG_IO requests
authorPaolo Bonzini <pbonzini@redhat.com>
Wed, 16 May 2012 10:54:03 +0000 (12:54 +0200)
committerAnthony Liguori <aliguori@us.ibm.com>
Mon, 21 May 2012 20:40:50 +0000 (15:40 -0500)
commitf34e73cd69bdbdb9b1d56b288c5e14d6fff58165
tree1214cf7f27ee9b25cfb49e1f0ae531a8c79385e9
parent80a2ba3d3cf33b777d6a45776b0625b9a4283951
virtio-blk: report non-zero status when failing SG_IO requests

Linux really looks only at scsi->errors for SG_IO requests; it does
not look at the virtio request status at all.  Because of this, when
a SG_IO request is failed early with virtio_blk_req_complete(req,
VIRTIO_BLK_S_UNSUPP), without writing hdr.status, it will look like
a success to the guest.

This is their bug, but we can make it safe for older guests now by
forcing scsi->errors to have a non-zero value whenever a request
has to be failed.

But if we fix the bug in the guest driver, we will have another problem
because QEMU returns VIRTIO_BLK_S_IOERR if the status is non-zero, and
Linux translates that to -EIO.  Rather, the guest should succeed the
request and pass the non-zero status via the userspace-provided SG_IO
structure.  So, remove the case where virtio_blk_handle_scsi can
return VIRTIO_BLK_S_IOERR.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/virtio-blk.c