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