From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36438) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5oZd-0007YT-IM for qemu-devel@nongnu.org; Thu, 26 May 2016 02:15:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5oZc-0000XN-Ik for qemu-devel@nongnu.org; Thu, 26 May 2016 02:15:13 -0400 From: Fam Zheng Date: Thu, 26 May 2016 14:15:03 +0800 Message-Id: <1464243305-10661-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH 0/2] block: Expose host block dev I/O size limit in scsi-block/scsi-generic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Max Reitz , Paolo Bonzini , qemu-block@nongnu.org Host devices passed through as scsi-block or scsi-generic may have a compound maximum I/O limit (out of physical hardware limit, driver quirks and file system configuration, etc) that is presented in the sysfs entry. SG_IOs we issue should respect this. However the value is currently not discoverable by guest, because the vHBA (virtio-scsi) would present an fixed emulated limit, while the INQUIRY (vpd=0xb0, block limits page) response solely speaks for the LUN itself, not the host kernel. The issue is observed on scsi passthrough of host usb or dm-multipath disks, and it is not specific to certain device types. The proposed solution is collecting the host sysfs limit in raw-posix driver when a block device is used, and intercepting INQUIRY response to clip the max xfer len field. This fixes booting a SanDisk usb-key with an upstream kernel. The usb disk reports a nonsense large value in INQUIRY, while the host (usb quirk?) only allows 120KB. Fam Zheng (2): raw-posix: Fetch max sectors for host block device from sysfs scsi-generic: Merge block max xfer len in INQUIRY response block/raw-posix.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ hw/scsi/scsi-generic.c | 12 ++++++++++++ 2 files changed, 59 insertions(+) -- 2.8.2