cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-scsi-generic-Merge-block-max-xfer-len-in-INQUIRY-res.patch

34b321
From b3f427e4eb27091ca712f6c18e2e63a414dc4ce2 Mon Sep 17 00:00:00 2001
34b321
From: Fam Zheng <famz@redhat.com>
34b321
Date: Mon, 11 Jul 2016 05:33:37 +0200
34b321
Subject: [PATCH 4/7] scsi-generic: Merge block max xfer len in INQUIRY
34b321
 response
34b321
34b321
RH-Author: Fam Zheng <famz@redhat.com>
34b321
Message-id: <1468215219-30793-5-git-send-email-famz@redhat.com>
34b321
Patchwork-id: 71108
34b321
O-Subject: [RHEL-7.3 qemu-kvm PATCH 4/6] scsi-generic: Merge block max xfer len in INQUIRY response
34b321
Bugzilla: 1318199
34b321
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
34b321
RH-Acked-by: John Snow <jsnow@redhat.com>
34b321
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
34b321
The rationale is similar to the above mode sense response interception:
34b321
this is practically the only channel to communicate restraints from
34b321
elsewhere such as host and block driver.
34b321
34b321
The scsi bus we attach onto can have a larger max xfer len than what is
34b321
accepted by the host file system (guarding between the host scsi LUN and
34b321
QEMU), in which case the SG_IO we generate would get -EINVAL.
34b321
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
Message-Id: <1464243305-10661-3-git-send-email-famz@redhat.com>
34b321
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
34b321
(cherry picked from commit 063143d5b1fde0fdcbae30bc7d6d14e76fa607d2)
34b321
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
34b321
34b321
Conflicts:
34b321
	hw/scsi/scsi-generic.c
34b321
We don't have BlockBackend in downstream, use bdrv_get_max_transfer_length()
34b321
instead.
34b321
34b321
The context is different because we don't have fa0d653b0 (scsi-generic:
34b321
identify AIO callbacks more clearly).
34b321
34b321
Signed-off-by: Fam Zheng <famz@redhat.com>
34b321
---
34b321
 hw/scsi/scsi-generic.c | 11 +++++++++++
34b321
 1 file changed, 11 insertions(+)
34b321
34b321
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
34b321
index 3733d2c..6b0c1fe 100644
34b321
--- a/hw/scsi/scsi-generic.c
34b321
+++ b/hw/scsi/scsi-generic.c
34b321
@@ -207,6 +207,17 @@ static void scsi_read_complete(void * opaque, int ret)
34b321
                    (r->req.cmd.buf[1] & 31) == SAI_READ_CAPACITY_16) {
34b321
             s->blocksize = ldl_be_p(&r->buf[8]);
34b321
             s->max_lba = ldq_be_p(&r->buf[0]);
34b321
+        } else if (s->type == TYPE_DISK &&
34b321
+            r->req.cmd.buf[0] == INQUIRY &&
34b321
+            r->req.cmd.buf[2] == 0xb0) {
34b321
+            uint32_t max_xfer_len = bdrv_get_max_transfer_length(s->conf.bs);
34b321
+            if (max_xfer_len) {
34b321
+                stl_be_p(&r->buf[8], max_xfer_len);
34b321
+                /* Also take care of the opt xfer len. */
34b321
+                if (ldl_be_p(&r->buf[12]) > max_xfer_len) {
34b321
+                    stl_be_p(&r->buf[12], max_xfer_len);
34b321
+                }
34b321
+            }
34b321
         }
34b321
         bdrv_set_guest_block_size(s->conf.bs, s->blocksize);
34b321
 
34b321
-- 
34b321
1.8.3.1
34b321