qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: [Qemu-devel] [PULL 01/19] scsi-disk: pass sense correctly for guest-recoverable errors
Date: Tue, 16 Jul 2019 10:10:59 +0200	[thread overview]
Message-ID: <1563264677-39718-2-git-send-email-pbonzini@redhat.com> (raw)
In-Reply-To: <1563264677-39718-1-git-send-email-pbonzini@redhat.com>

From: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>

When an error was passed down to the guest because it was recoverable,
the sense length was not copied from the SG_IO data.  As a result,
the guest saw the CHECK CONDITION status but not the sense data.

Signed-off-by: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/scsi-disk.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
index ed7295b..5d3fb3c 100644
--- a/hw/scsi/scsi-disk.c
+++ b/hw/scsi/scsi-disk.c
@@ -62,6 +62,7 @@ typedef struct SCSIDiskClass {
     DMAIOFunc       *dma_readv;
     DMAIOFunc       *dma_writev;
     bool            (*need_fua_emulation)(SCSICommand *cmd);
+    void            (*update_sense)(SCSIRequest *r);
 } SCSIDiskClass;
 
 typedef struct SCSIDiskReq {
@@ -438,6 +439,7 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
 {
     bool is_read = (r->req.cmd.mode == SCSI_XFER_FROM_DEV);
     SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
+    SCSIDiskClass *sdc = (SCSIDiskClass *) object_get_class(OBJECT(s));
     BlockErrorAction action = blk_get_error_action(s->qdev.conf.blk,
                                                    is_read, error);
 
@@ -456,6 +458,7 @@ static bool scsi_handle_rw_error(SCSIDiskReq *r, int error, bool acct_failed)
             if (error == ECANCELED || error == EAGAIN || error == ENOTCONN ||
                 error == 0)  {
                 /* These errors are handled by guest. */
+                sdc->update_sense(&r->req);
                 scsi_req_complete(&r->req, *r->status);
                 return true;
             }
@@ -2894,6 +2897,12 @@ static int scsi_block_parse_cdb(SCSIDevice *d, SCSICommand *cmd,
     }
 }
 
+static void scsi_block_update_sense(SCSIRequest *req)
+{
+    SCSIDiskReq *r = DO_UPCAST(SCSIDiskReq, req, req);
+    SCSIBlockReq *br = DO_UPCAST(SCSIBlockReq, req, r);
+    r->req.sense_len = MIN(br->io_header.sb_len_wr, sizeof(r->req.sense));
+}
 #endif
 
 static
@@ -3059,6 +3068,7 @@ static void scsi_block_class_initfn(ObjectClass *klass, void *data)
     sc->parse_cdb    = scsi_block_parse_cdb;
     sdc->dma_readv   = scsi_block_dma_readv;
     sdc->dma_writev  = scsi_block_dma_writev;
+    sdc->update_sense = scsi_block_update_sense;
     sdc->need_fua_emulation = scsi_block_no_fua;
     dc->desc = "SCSI block device passthrough";
     dc->props = scsi_block_properties;
-- 
1.8.3.1




  reply	other threads:[~2019-07-16  8:11 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-16  8:10 [Qemu-devel] [PULL 00/19] Bugfix/cleanup patches for 2019-07-16 Paolo Bonzini
2019-07-16  8:10 ` Paolo Bonzini [this message]
2019-07-16  8:11 ` [Qemu-devel] [PULL 02/19] scsi: explicitly list guest-recoverable sense codes Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 03/19] scsi: add guest-recoverable ZBC errors Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 04/19] iscsi: fix busy/timeout/task set full Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 05/19] iscsi: base all handling of check condition on scsi_sense_to_errno Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 06/19] build-sys: remove slirp cflags from main-loop.o Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 07/19] rdmacm-mux: fix strcpy string warning Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 08/19] hw/i386: turn off vmport if CONFIG_VMPORT is disabled Paolo Bonzini
2019-07-16 18:55   ` Philippe Mathieu-Daudé
2019-07-16 19:13     ` Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 09/19] memory: unref the memory region in simplify flatview Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 10/19] Fix broken build with WHPX enabled Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 11/19] util: merge main-loop.c and iohandler.c Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 12/19] hw/lm32/Kconfig: Milkymist One provides a USB 1.1 Controller Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 13/19] checkpatch: detect doubly-encoded UTF-8 Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 14/19] target/i386: sev: Do not unpin ram device memory region Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 15/19] hw/usb/Kconfig: Add CONFIG_USB_EHCI_PCI Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 16/19] hw/usb/Kconfig: USB_XHCI_NEC requires USB_XHCI Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 17/19] Makefile: do not repeat $(CONFIG_SOFTMMU) in hw/Makefile.objs Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 18/19] create_config: remove $(CONFIG_SOFTMMU) hack Paolo Bonzini
2019-07-16  8:11 ` [Qemu-devel] [PULL 19/19] vl: make sure char-pty message displayed by moving setbuf to the beginning Paolo Bonzini
2019-07-16  8:18 ` [Qemu-devel] [PULL 00/19] Bugfix/cleanup patches for 2019-07-16 no-reply
2019-07-16 15:05 ` Peter Maydell
2019-07-19 16:15 ` Peter Maydell
2019-07-19 17:00   ` Paolo Bonzini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1563264677-39718-2-git-send-email-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=shinichiro.kawasaki@wdc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).