thebeanogamer / rpms / qemu-kvm

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