qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Dongli Zhang <dongli.zhang@oracle.com>
To: qemu-block@nongnu.org, qemu-devel@nongnu.org
Cc: fam@euphon.net, pbonzini@redhat.com, rui.loura@oracle.com,
	joe.jin@oracle.com, adnan.misherfi@oracle.com
Subject: [PATCH 2/2] scsi/utils: pass host_status = SCSI_HOST_ERROR to guest kernel
Date: Fri, 10 Dec 2021 06:16:15 -0800	[thread overview]
Message-ID: <20211210141615.2585-3-dongli.zhang@oracle.com> (raw)
In-Reply-To: <20211210141615.2585-1-dongli.zhang@oracle.com>

For scsi_req_complete_failed() and when the req->bus->info->fail() is
implemented, the virtio-scsi passes SCSI_HOST_ERROR to the guest kernel as
VIRTIO_SCSI_S_FAILURE, while the pvscsi passes SCSI_HOST_ERROR to guest
kernel as BTSTAT_HASOFTWARE.

However, the scsi_req_complete_failed()->scsi_sense_from_host_status()
always returns GOOD for SCSI_HOST_ERROR, when the req->bus->info->fail() is
not implemented (e.g., megasas). As a result, the sense is not passed to
the guest kernel.

The SCSI_HOST_ERROR is reproduced on purpose by below QEMU command line:

-device megasas,id=vscsi0,bus=pci.0,addr=0x4 \
-drive file=/dev/sdc,format=raw,if=none,id=drive01 \
-device scsi-block,bus=vscsi0.0,channel=0,scsi-id=0,lun=0,drive=drive01 \

... and when we remove the /dev/sdc from the host with:

"echo 1 > /sys/block/sdc/device/delete"

This patch passes sense_code_IO_ERROR to the guest kernel for
host_status = SCSI_HOST_ERROR.

(This issue is detected by running a testing code from Rui Loura).

Cc: Joe Jin <joe.jin@oracle.com>
Cc: Adnan Misherfi <adnan.misherfi@oracle.com>
Cc: Rui Loura <rui.loura@oracle.com>
Signed-off-by: Dongli Zhang <dongli.zhang@oracle.com>
---
 scsi/utils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scsi/utils.c b/scsi/utils.c
index 357b036671..086a1fea66 100644
--- a/scsi/utils.c
+++ b/scsi/utils.c
@@ -638,6 +638,9 @@ int scsi_sense_from_host_status(uint8_t host_status,
     case SCSI_HOST_ABORTED:
         *sense = SENSE_CODE(COMMAND_ABORTED);
         return CHECK_CONDITION;
+    case SCSI_HOST_ERROR:
+        *sense = SENSE_CODE(IO_ERROR);
+        return CHECK_CONDITION;
     case SCSI_HOST_RESET:
         *sense = SENSE_CODE(RESET);
         return CHECK_CONDITION;
-- 
2.17.1



  parent reply	other threads:[~2021-12-10 14:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-10 14:16 [PATCH 0/2] scsi: to fix issue on passing host_status to the guest kernel Dongli Zhang
2021-12-10 14:16 ` [PATCH 1/2] scsi/scsi_bus: use host_status as parameter for scsi_sense_from_host_status() Dongli Zhang
2021-12-10 14:16 ` Dongli Zhang [this message]
2022-01-11  1:15 ` [PATCH 0/2] scsi: to fix issue on passing host_status to the guest kernel Dongli Zhang

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=20211210141615.2585-3-dongli.zhang@oracle.com \
    --to=dongli.zhang@oracle.com \
    --cc=adnan.misherfi@oracle.com \
    --cc=fam@euphon.net \
    --cc=joe.jin@oracle.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=rui.loura@oracle.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).