From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42832) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLaMh-0006bM-48 for qemu-devel@nongnu.org; Wed, 02 Nov 2011 08:56:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RLaMf-0002tp-6n for qemu-devel@nongnu.org; Wed, 02 Nov 2011 08:56:23 -0400 Received: from mail-yw0-f45.google.com ([209.85.213.45]:58485) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RLaMe-0002sc-RK for qemu-devel@nongnu.org; Wed, 02 Nov 2011 08:56:20 -0400 Received: by mail-yw0-f45.google.com with SMTP id 3so111109ywb.4 for ; Wed, 02 Nov 2011 05:56:20 -0700 (PDT) Message-ID: <4EB13DF1.60400@codemonkey.ws> Date: Wed, 02 Nov 2011 07:56:17 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <1320236380-26180-1-git-send-email-pbonzini@redhat.com> In-Reply-To: <1320236380-26180-1-git-send-email-pbonzini@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1.0] virtio-blk: pass full status to the guest List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org, mst@redhat.com On 11/02/2011 07:19 AM, Paolo Bonzini wrote: > When SCSI passthrough is being used by the guest with virtio-blk, the > guest is not able to detect disk failures. This is because the status > field is expected by the guest driver to include also the msg_status, > host_status and driver_status fields, but the device is only passing > down the SCSI status. > > The patch fixes this, and also makes sure that the guest always sees a > CHECK_CONDITION status when there is valid sense data. > --- Applied. Thanks. Regards, Anthony Liguori > Sorry for missing the -rc deadline, testing this requires > Fibre Channel stuff so I needed someone to do it for me. :) > > hw/virtio-blk.c | 16 +++++++++++++++- > 1 files changed, 15 insertions(+), 1 deletions(-) > > diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c > index 179747a..8beaa20 100644 > --- a/hw/virtio-blk.c > +++ b/hw/virtio-blk.c > @@ -16,6 +16,7 @@ > #include "trace.h" > #include "blockdev.h" > #include "virtio-blk.h" > +#include "scsi-defs.h" > #ifdef __linux__ > # include > #endif > @@ -231,7 +232,20 @@ static void virtio_blk_handle_scsi(VirtIOBlockReq *req) > status = VIRTIO_BLK_S_OK; > } > > - stl_p(&req->scsi->errors, hdr.status); > + /* > + * From SCSI-Generic-HOWTO: "Some lower level drivers (e.g. ide-scsi) > + * clear the masked_status field [hence status gets cleared too, see > + * block/scsi_ioctl.c] even when a CHECK_CONDITION or COMMAND_TERMINATED > + * status has occurred. However they do set DRIVER_SENSE in driver_status > + * field. Also a (sb_len_wr> 0) indicates there is a sense buffer. > + */ > + if (hdr.status == 0&& hdr.sb_len_wr> 0) { > + hdr.status = CHECK_CONDITION; > + } > + > + stl_p(&req->scsi->errors, > + hdr.status | (hdr.msg_status<< 8) | > + (hdr.host_status<< 16) | (hdr.driver_status<< 24)); > stl_p(&req->scsi->residual, hdr.resid); > stl_p(&req->scsi->sense_len, hdr.sb_len_wr); > stl_p(&req->scsi->data_len, hdr.dxfer_len);