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

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