From patchwork Mon Oct 16 20:17:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 10009905 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1D526601D5 for ; Mon, 16 Oct 2017 21:27:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0ED2F286E7 for ; Mon, 16 Oct 2017 21:27:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 030D0286EC; Mon, 16 Oct 2017 21:27:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B580286EB for ; Mon, 16 Oct 2017 21:27:21 +0000 (UTC) Received: from localhost ([::1]:35323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Cut-0006DR-VW for patchwork-qemu-devel@patchwork.kernel.org; Mon, 16 Oct 2017 17:27:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44045) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e4Bo7-00049o-5D for qemu-devel@nongnu.org; Mon, 16 Oct 2017 16:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e4Bo2-0008BD-Qs for qemu-devel@nongnu.org; Mon, 16 Oct 2017 16:16:15 -0400 Received: from aserp1040.oracle.com ([141.146.126.69]:50776) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e4Bo2-0008AP-JU for qemu-devel@nongnu.org; Mon, 16 Oct 2017 16:16:10 -0400 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v9GKG7rQ008584 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Oct 2017 20:16:08 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v9GKG73Z021538 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 16 Oct 2017 20:16:07 GMT Received: from abhmp0017.oracle.com (abhmp0017.oracle.com [141.146.116.23]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id v9GKG6SE002238; Mon, 16 Oct 2017 20:16:07 GMT Received: from mhkanda-aus-1.us.oracle.com (/10.135.188.192) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 16 Oct 2017 13:16:06 -0700 From: Mark Kanda To: qemu-devel@nongnu.org Date: Mon, 16 Oct 2017 15:17:04 -0500 Message-Id: <1508185024-5840-1-git-send-email-mark.kanda@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Source-IP: aserv0021.oracle.com [141.146.126.233] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 141.146.126.69 X-Mailman-Approved-At: Mon, 16 Oct 2017 17:26:45 -0400 Subject: [Qemu-devel] [PATCH] Reject virtio-scsi configurations with logical block size > physical block size X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: pbonzini@redhat.com, Mark Kanda , martin.petersen@oracle.com, konrad.wilk@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP With virtio-scsi, logical block size should never be larger than physical block size. From an ATA/SCSI perspective, it makes no sense to have the logical block size greater than the physical block size, and it cannot even be effectively expressed in the command set. The whole point of adding the physical block size to the ATA/SCSI command set was to communicate a desire for a larger block size (than logical), while maintaining backwards compatibility with legacy 512 byte block size. This was found by setting logical_block_size > physical_block_size in the QEMU command line, and discovering that it confuses Windows VMs - fsutil reports both physical and logical block sizes are equal to the logical size. Example QEMU option: -device scsi-hd,drive=drive-scsi0,id=disk1,bus=scsi.0, physical_block_size=512,logical_block_size=4096 Windows Server 2012 R2 VM: C:\Users\Administrator>fsutil fsinfo ntfsinfo F: ... Bytes Per Sector : 4096 Bytes Per Physical Sector : 4096 Bytes Per Cluster : 4096 Bytes Per FileRecord Segment : 4096 ... Signed-off-by: Mark Kanda Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Martin K. Petersen --- hw/scsi/scsi-disk.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c index 6e841fb..2a4f8c5 100644 --- a/hw/scsi/scsi-disk.c +++ b/hw/scsi/scsi-disk.c @@ -2329,6 +2329,14 @@ static void scsi_realize(SCSIDevice *dev, Error **errp) blkconf_serial(&s->qdev.conf, &s->serial); blkconf_blocksizes(&s->qdev.conf); + + if (s->qdev.conf.logical_block_size > + s->qdev.conf.physical_block_size) { + error_setg(errp, + "logical_block_size > physical_block_size not supported"); + return; + } + if (dev->type == TYPE_DISK) { blkconf_geometry(&dev->conf, NULL, 65535, 255, 255, &err); if (err) {