Blame SOURCES/kvm-scsi-disk-Don-t-use-empty-string-as-device-id.patch

7711c0
From 66d5fd223afbf662589611f3d6a22ff7bcc38bb0 Mon Sep 17 00:00:00 2001
7711c0
From: Kevin Wolf <kwolf@redhat.com>
7711c0
Date: Wed, 6 Feb 2019 15:58:28 +0100
7711c0
Subject: [PATCH 08/33] scsi-disk: Don't use empty string as device id
7711c0
MIME-Version: 1.0
7711c0
Content-Type: text/plain; charset=UTF-8
7711c0
Content-Transfer-Encoding: 8bit
7711c0
7711c0
RH-Author: Kevin Wolf <kwolf@redhat.com>
7711c0
Message-id: <20190206155829.14641-2-kwolf@redhat.com>
7711c0
Patchwork-id: 84253
7711c0
O-Subject: [RHEL-7.7/8.0-AV qemu-kvm-rhev PATCH 1/2] scsi-disk: Don't use empty string as device id
7711c0
Bugzilla: 1673080
7711c0
RH-Acked-by: Max Reitz <mreitz@redhat.com>
7711c0
RH-Acked-by: Thomas Huth <thuth@redhat.com>
7711c0
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
7711c0
7711c0
scsi-disk includes in the Device Identification VPD page, depending on
7711c0
configuration amongst others, a vendor specific designator that consists
7711c0
either of the serial number if given or the BlockBackend name (which is
7711c0
a host detail that better shouldn't have been leaked to the guest, but
7711c0
now we have to maintain it for compatibility).
7711c0
7711c0
With anonymous BlockBackends, i.e. scsi-disk devices constructed with
7711c0
drive=<node-name>, and no serial number explicitly specified, this ends
7711c0
up as an empty string. If this happens to more than one disk, we have
7711c0
accidentally signalled to the OS that this is a multipath setup, which
7711c0
is obviously not what was intended.
7711c0
7711c0
Instead of using an empty string for the vendor specific designator,
7711c0
simply leave out that designator, which makes Linux detect such setups
7711c0
as separate disks again.
7711c0
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Reviewed-by: Eric Blake <eblake@redhat.com>
7711c0
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
7711c0
(cherry picked from commit a8f58afcdb86e266e06c9dc41a71605e570244c3)
7711c0
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
7711c0
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
7711c0
---
7711c0
 hw/scsi/scsi-disk.c | 14 ++++++++------
7711c0
 1 file changed, 8 insertions(+), 6 deletions(-)
7711c0
7711c0
diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
7711c0
index a20ef91..de6c7bc 100644
7711c0
--- a/hw/scsi/scsi-disk.c
7711c0
+++ b/hw/scsi/scsi-disk.c
7711c0
@@ -648,12 +648,14 @@ static int scsi_disk_emulate_vpd_page(SCSIRequest *req, uint8_t *outbuf)
7711c0
         DPRINTF("Inquiry EVPD[Device identification] "
7711c0
                 "buffer size %zd\n", req->cmd.xfer);
7711c0
 
7711c0
-        outbuf[buflen++] = 0x2; /* ASCII */
7711c0
-        outbuf[buflen++] = 0;   /* not officially assigned */
7711c0
-        outbuf[buflen++] = 0;   /* reserved */
7711c0
-        outbuf[buflen++] = id_len; /* length of data following */
7711c0
-        memcpy(outbuf + buflen, str, id_len);
7711c0
-        buflen += id_len;
7711c0
+        if (id_len) {
7711c0
+            outbuf[buflen++] = 0x2; /* ASCII */
7711c0
+            outbuf[buflen++] = 0;   /* not officially assigned */
7711c0
+            outbuf[buflen++] = 0;   /* reserved */
7711c0
+            outbuf[buflen++] = id_len; /* length of data following */
7711c0
+            memcpy(outbuf + buflen, str, id_len);
7711c0
+            buflen += id_len;
7711c0
+        }
7711c0
 
7711c0
         if (s->qdev.wwn) {
7711c0
             outbuf[buflen++] = 0x1; /* Binary */
7711c0
-- 
7711c0
1.8.3.1
7711c0