qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: qemu-devel@nongnu.org
Cc: mreitz@redhat.com, Daniel Henrique Barboza <danielhb413@gmail.com>
Subject: [Qemu-devel] [PATCH 4/4] scsi-generic: do not do VPD emulation for sense other than ILLEGAL_REQUEST
Date: Mon, 29 Oct 2018 18:34:37 +0100	[thread overview]
Message-ID: <20181029173437.32559-5-pbonzini@redhat.com> (raw)
In-Reply-To: <20181029173437.32559-1-pbonzini@redhat.com>

Pass other sense, such as UNIT_ATTENTION or BUSY, directly to the
guest.

Reported-by: Max Reitz <mreitz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/scsi/scsi-generic.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 8fc74ef0bd..b8fa0a0f7e 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -246,7 +246,6 @@ static void scsi_read_complete(void * opaque, int ret)
 {
     SCSIGenericReq *r = (SCSIGenericReq *)opaque;
     SCSIDevice *s = r->req.dev;
-    SCSISense sense;
     int len;
 
     assert(r->req.aiocb != NULL);
@@ -269,12 +268,15 @@ static void scsi_read_complete(void * opaque, int ret)
      * resulted in sense error but would need emulation.
      * In this case, emulate a valid VPD response.
      */
-    if (s->needs_vpd_bl_emulation) {
+    if (ret == 0 &&
+        (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) &&
+        scsi_parse_sense_buf(r->req.sense, r->io_header.sb_len_wr).key == ILLEGAL_REQUEST &&
+        s->needs_vpd_bl_emulation) {
         int is_vpd_bl = r->req.cmd.buf[0] == INQUIRY &&
                          r->req.cmd.buf[1] & 0x01 &&
                          r->req.cmd.buf[2] == 0xb0;
 
-        if (is_vpd_bl && sg_io_sense_from_errno(-ret, &r->io_header, &sense)) {
+        if (is_vpd_bl) {
             len = scsi_generic_emulate_block_limits(r, s);
             /*
              * No need to let scsi_read_complete go on and handle an
-- 
2.17.1

  parent reply	other threads:[~2018-10-29 17:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-29 17:34 [Qemu-devel] [PATCH 0/4] scsi-generic: fixes for Block Limits emulation Paolo Bonzini
2018-10-29 17:34 ` [Qemu-devel] [PATCH 1/4] scsi-generic: keep VPD page list sorted Paolo Bonzini
2018-11-06  1:45   ` Max Reitz
2018-11-06 15:39   ` Daniel Henrique Barboza
2018-10-29 17:34 ` [Qemu-devel] [PATCH 2/4] scsi-generic: avoid out-of-bounds access to VPD page list Paolo Bonzini
2018-10-30 21:26   ` Philippe Mathieu-Daudé
2018-11-06  1:52   ` Max Reitz
2018-11-06 15:40   ` Daniel Henrique Barboza
2018-10-29 17:34 ` [Qemu-devel] [PATCH 3/4] scsi-generic: avoid invalid access to struct when emulating block limits Paolo Bonzini
2018-11-06  2:16   ` Max Reitz
2018-11-06  9:44     ` Paolo Bonzini
2018-10-29 17:34 ` Paolo Bonzini [this message]
2018-11-06  2:22   ` [Qemu-devel] [PATCH 4/4] scsi-generic: do not do VPD emulation for sense other than ILLEGAL_REQUEST Max Reitz
2018-10-31 23:17 ` [Qemu-devel] [PATCH 0/4] scsi-generic: fixes for Block Limits emulation no-reply
2018-10-31 23:27 ` no-reply
2018-11-06 15:31 ` no-reply
2018-11-06 15:42 ` no-reply
2018-11-06 15:54 ` Daniel Henrique Barboza
2018-11-06 18:54   ` Paolo Bonzini
2018-11-07 11:36 ` no-reply
2018-11-07 11:46 ` no-reply

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=20181029173437.32559-5-pbonzini@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=danielhb413@gmail.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).