Blame SOURCES/kvm-scsi-generic-do-not-do-VPD-emulation-for-sense-other.patch

7711c0
From b6e4458e8c01c680b607495f1408b53c38138db0 Mon Sep 17 00:00:00 2001
7711c0
From: Paolo Bonzini <pbonzini@redhat.com>
7711c0
Date: Wed, 7 Nov 2018 18:00:07 +0100
7711c0
Subject: [PATCH 33/34] scsi-generic: do not do VPD emulation for sense other
7711c0
 than ILLEGAL_REQUEST
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
7711c0
Message-id: <20181107180007.22954-10-pbonzini@redhat.com>
7711c0
Patchwork-id: 82942
7711c0
O-Subject: [RHEL7.6.z qemu-kvm-rhev PATCH 9/9] scsi-generic: do not do VPD emulation for sense other than ILLEGAL_REQUEST
7711c0
Bugzilla: 1566195
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
7711c0
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
7711c0
Pass other sense, such as UNIT_ATTENTION or BUSY, directly to the
7711c0
guest.
7711c0
7711c0
Reported-by: Max Reitz <mreitz@redhat.com>
7711c0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
7711c0
(cherry picked from commit 763c56872b08b98fde062a1feca003f200e7bd5c)
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 hw/scsi/scsi-generic.c | 8 +++++---
7711c0
 1 file changed, 5 insertions(+), 3 deletions(-)
7711c0
7711c0
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
7711c0
index f218cef..4ac53e4 100644
7711c0
--- a/hw/scsi/scsi-generic.c
7711c0
+++ b/hw/scsi/scsi-generic.c
7711c0
@@ -247,7 +247,6 @@ static void scsi_read_complete(void * opaque, int ret)
7711c0
 {
7711c0
     SCSIGenericReq *r = (SCSIGenericReq *)opaque;
7711c0
     SCSIDevice *s = r->req.dev;
7711c0
-    SCSISense sense;
7711c0
     int len;
7711c0
 
7711c0
     assert(r->req.aiocb != NULL);
7711c0
@@ -270,11 +269,14 @@ static void scsi_read_complete(void * opaque, int ret)
7711c0
      * resulted in sense error but would need emulation.
7711c0
      * In this case, emulate a valid VPD response.
7711c0
      */
7711c0
-    if (s->needs_vpd_bl_emulation &&
7711c0
+    if (s->needs_vpd_bl_emulation && ret == 0 &&
7711c0
+        (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) &&
7711c0
         r->req.cmd.buf[0] == INQUIRY &&
7711c0
         (r->req.cmd.buf[1] & 0x01) &&
7711c0
         r->req.cmd.buf[2] == 0xb0) {
7711c0
-        if (sg_io_sense_from_errno(-ret, &r->io_header, &sense)) {
7711c0
+        SCSISense sense =
7711c0
+            scsi_parse_sense_buf(r->req.sense, r->io_header.sb_len_wr);
7711c0
+        if (sense.key == ILLEGAL_REQUEST) {
7711c0
             len = scsi_generic_emulate_block_limits(r, s);
7711c0
             /*
7711c0
              * No need to let scsi_read_complete go on and handle an
7711c0
-- 
7711c0
1.8.3.1
7711c0