Blame SOURCES/kvm-scsi-disk-Block-Device-Characteristics-emulation-fix.patch

7711c0
From 691b2859207e4cee5e86f0cb86a7a81b9efa2bda Mon Sep 17 00:00:00 2001
7711c0
From: Paolo Bonzini <pbonzini@redhat.com>
7711c0
Date: Wed, 7 Nov 2018 18:00:03 +0100
7711c0
Subject: [PATCH 29/34] scsi-disk: Block Device Characteristics emulation fix
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-6-pbonzini@redhat.com>
7711c0
Patchwork-id: 82945
7711c0
O-Subject: [RHEL7.6.z qemu-kvm-rhev PATCH 5/9] scsi-disk: Block Device Characteristics emulation fix
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
From: Daniel Henrique Barboza <danielhb413@gmail.com>
7711c0
7711c0
The current BDC VPD page (page 0xb1) is too short. This can be
7711c0
seen running sg_utils:
7711c0
7711c0
$ sg_vpd --page=bdc /dev/sda
7711c0
Block device characteristics VPD page (SBC):
7711c0
Block device characteristics VPD page length too short=8
7711c0
7711c0
By the SCSI spec, the expected size of the SBC page is 0x40.
7711c0
There is no telling how the guest will behave with a shorter
7711c0
message - it can ignore it, or worse, make (wrong)
7711c0
assumptions.
7711c0
7711c0
This patch fixes the emulation by setting the size to 0x40.
7711c0
This is the output of the previous sg_vpd command after
7711c0
applying it:
7711c0
7711c0
$ sg_vpd --page=bdc /dev/sda -v
7711c0
    inquiry cdb: 12 01 b1 00 fc 00
7711c0
Block device characteristics VPD page (SBC):
7711c0
   [PQual=0  Peripheral device type: disk]
7711c0
  Medium rotation rate is not reported
7711c0
  Product type: Not specified
7711c0
  WABEREQ=0
7711c0
  WACEREQ=0
7711c0
  Nominal form factor not reported
7711c0
  FUAB=0
7711c0
  VBULS=0
7711c0
7711c0
To improve readability, this patch also adds the VBULS value
7711c0
explictly and add comments on the existing fields we're
7711c0
setting.
7711c0
7711c0
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
7711c0
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
(cherry picked from commit 740842c9656cd5dbc9ccf2ea0c3a74f0ba35144a)
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 hw/scsi/scsi-disk.c | 7 ++++---
7711c0
 1 file changed, 4 insertions(+), 3 deletions(-)
7711c0
7711c0
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
7711c0
index b3d53ec..b8a27d6 100644
7711c0
--- a/hw/scsi/scsi-disk.c
7711c0
+++ b/hw/scsi/scsi-disk.c
7711c0
@@ -774,11 +774,12 @@ int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
7711c0
     }
7711c0
     case 0xb1: /* block device characteristics */
7711c0
     {
7711c0
-        buflen = 8;
7711c0
+        buflen = 0x40;
7711c0
         outbuf[4] = (s->rotation_rate >> 8) & 0xff;
7711c0
         outbuf[5] = s->rotation_rate & 0xff;
7711c0
-        outbuf[6] = 0;
7711c0
-        outbuf[7] = 0;
7711c0
+        outbuf[6] = 0; /* PRODUCT TYPE */
7711c0
+        outbuf[7] = 0; /* WABEREQ | WACEREQ | NOMINAL FORM FACTOR */
7711c0
+        outbuf[8] = 0; /* VBULS */
7711c0
         break;
7711c0
     }
7711c0
     case 0xb2: /* thin provisioning */
7711c0
-- 
7711c0
1.8.3.1
7711c0