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

26ba25
From 3c469960b02ee2645f582a8f1c072308754aff96 Mon Sep 17 00:00:00 2001
26ba25
From: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Date: Thu, 20 Dec 2018 12:30:59 +0000
26ba25
Subject: [PATCH 4/8] scsi-disk: Block Device Characteristics emulation fix
26ba25
MIME-Version: 1.0
26ba25
Content-Type: text/plain; charset=UTF-8
26ba25
Content-Transfer-Encoding: 8bit
26ba25
26ba25
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Message-id: <20181220123103.29579-5-pbonzini@redhat.com>
26ba25
Patchwork-id: 83717
26ba25
O-Subject: [PATCH 4/8] scsi-disk: Block Device Characteristics emulation fix
26ba25
Bugzilla: 1639957
26ba25
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
26ba25
RH-Acked-by: Philippe Mathieu-Daudé <philmd@redhat.com>
26ba25
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
26ba25
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
26ba25
26ba25
From: Daniel Henrique Barboza <danielhb413@gmail.com>
26ba25
26ba25
The current BDC VPD page (page 0xb1) is too short. This can be
26ba25
seen running sg_utils:
26ba25
26ba25
$ sg_vpd --page=bdc /dev/sda
26ba25
Block device characteristics VPD page (SBC):
26ba25
Block device characteristics VPD page length too short=8
26ba25
26ba25
By the SCSI spec, the expected size of the SBC page is 0x40.
26ba25
There is no telling how the guest will behave with a shorter
26ba25
message - it can ignore it, or worse, make (wrong)
26ba25
assumptions.
26ba25
26ba25
This patch fixes the emulation by setting the size to 0x40.
26ba25
This is the output of the previous sg_vpd command after
26ba25
applying it:
26ba25
26ba25
$ sg_vpd --page=bdc /dev/sda -v
26ba25
    inquiry cdb: 12 01 b1 00 fc 00
26ba25
Block device characteristics VPD page (SBC):
26ba25
   [PQual=0  Peripheral device type: disk]
26ba25
  Medium rotation rate is not reported
26ba25
  Product type: Not specified
26ba25
  WABEREQ=0
26ba25
  WACEREQ=0
26ba25
  Nominal form factor not reported
26ba25
  FUAB=0
26ba25
  VBULS=0
26ba25
26ba25
To improve readability, this patch also adds the VBULS value
26ba25
explictly and add comments on the existing fields we're
26ba25
setting.
26ba25
26ba25
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
26ba25
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
26ba25
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
26ba25
(cherry picked from commit 740842c9656cd5dbc9ccf2ea0c3a74f0ba35144a)
26ba25
Signed-off-by: Danilo C. L. de Paula <ddepaula@redhat.com>
26ba25
---
26ba25
 hw/scsi/scsi-disk.c | 7 ++++---
26ba25
 1 file changed, 4 insertions(+), 3 deletions(-)
26ba25
26ba25
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
26ba25
index b3d53ec..b8a27d6 100644
26ba25
--- a/hw/scsi/scsi-disk.c
26ba25
+++ b/hw/scsi/scsi-disk.c
26ba25
@@ -774,11 +774,12 @@ int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
26ba25
     }
26ba25
     case 0xb1: /* block device characteristics */
26ba25
     {
26ba25
-        buflen = 8;
26ba25
+        buflen = 0x40;
26ba25
         outbuf[4] = (s->rotation_rate >> 8) & 0xff;
26ba25
         outbuf[5] = s->rotation_rate & 0xff;
26ba25
-        outbuf[6] = 0;
26ba25
-        outbuf[7] = 0;
26ba25
+        outbuf[6] = 0; /* PRODUCT TYPE */
26ba25
+        outbuf[7] = 0; /* WABEREQ | WACEREQ | NOMINAL FORM FACTOR */
26ba25
+        outbuf[8] = 0; /* VBULS */
26ba25
         break;
26ba25
     }
26ba25
     case 0xb2: /* thin provisioning */
26ba25
-- 
26ba25
1.8.3.1
26ba25