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

26ba25
From d186ce91950c1cd0d1ba354daca53a072390fb53 Mon Sep 17 00:00:00 2001
26ba25
From: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Date: Thu, 20 Dec 2018 12:31:03 +0000
26ba25
Subject: [PATCH 8/8] scsi-generic: do not do VPD emulation for sense other
26ba25
 than ILLEGAL_REQUEST
26ba25
26ba25
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Message-id: <20181220123103.29579-9-pbonzini@redhat.com>
26ba25
Patchwork-id: 83716
26ba25
O-Subject: [PATCH 8/8] scsi-generic: do not do VPD emulation for sense other than ILLEGAL_REQUEST
26ba25
Bugzilla: 1639957
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
26ba25
Pass other sense, such as UNIT_ATTENTION or BUSY, directly to the
26ba25
guest.
26ba25
26ba25
Reported-by: Max Reitz <mreitz@redhat.com>
26ba25
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
(cherry picked from commit 763c56872b08b98fde062a1feca003f200e7bd5c)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 hw/scsi/scsi-generic.c | 8 +++++---
26ba25
 1 file changed, 5 insertions(+), 3 deletions(-)
26ba25
26ba25
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
26ba25
index f218cef..4ac53e4 100644
26ba25
--- a/hw/scsi/scsi-generic.c
26ba25
+++ b/hw/scsi/scsi-generic.c
26ba25
@@ -247,7 +247,6 @@ static void scsi_read_complete(void * opaque, int ret)
26ba25
 {
26ba25
     SCSIGenericReq *r = (SCSIGenericReq *)opaque;
26ba25
     SCSIDevice *s = r->req.dev;
26ba25
-    SCSISense sense;
26ba25
     int len;
26ba25
 
26ba25
     assert(r->req.aiocb != NULL);
26ba25
@@ -270,11 +269,14 @@ static void scsi_read_complete(void * opaque, int ret)
26ba25
      * resulted in sense error but would need emulation.
26ba25
      * In this case, emulate a valid VPD response.
26ba25
      */
26ba25
-    if (s->needs_vpd_bl_emulation &&
26ba25
+    if (s->needs_vpd_bl_emulation && ret == 0 &&
26ba25
+        (r->io_header.driver_status & SG_ERR_DRIVER_SENSE) &&
26ba25
         r->req.cmd.buf[0] == INQUIRY &&
26ba25
         (r->req.cmd.buf[1] & 0x01) &&
26ba25
         r->req.cmd.buf[2] == 0xb0) {
26ba25
-        if (sg_io_sense_from_errno(-ret, &r->io_header, &sense)) {
26ba25
+        SCSISense sense =
26ba25
+            scsi_parse_sense_buf(r->req.sense, r->io_header.sb_len_wr);
26ba25
+        if (sense.key == ILLEGAL_REQUEST) {
26ba25
             len = scsi_generic_emulate_block_limits(r, s);
26ba25
             /*
26ba25
              * No need to let scsi_read_complete go on and handle an
26ba25
-- 
26ba25
1.8.3.1
26ba25