From patchwork Mon Dec 11 15:16:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 10105419 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 1E3CE60360 for ; Mon, 11 Dec 2017 15:15:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EBEAB29601 for ; Mon, 11 Dec 2017 15:15:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DED8429704; Mon, 11 Dec 2017 15:15:32 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 C44CB29601 for ; Mon, 11 Dec 2017 15:15:31 +0000 (UTC) Received: from localhost ([::1]:53809 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOPnm-0007XP-U5 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 11 Dec 2017 10:15:30 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49682) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eOPmw-0006qP-94 for qemu-devel@nongnu.org; Mon, 11 Dec 2017 10:14:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eOPmv-0000JV-DQ for qemu-devel@nongnu.org; Mon, 11 Dec 2017 10:14:38 -0500 Received: from aserp2120.oracle.com ([141.146.126.78]:35122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eOPmp-0000CR-3y; Mon, 11 Dec 2017 10:14:31 -0500 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vBBFBr5B071643; Mon, 11 Dec 2017 15:14:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : in-reply-to : references; s=corp-2017-10-26; bh=rht4CzunH+aTZuoMOssNz1RZ/ZJ9CKg/Xjx69WAwzR4=; b=CqjTFesvlPjqWiPeUEJRLcuGXMFlyxRSVWAzZBRPuYAKNe9Ec7DpbzWs/vDcYM1bRSOC jQLDbIdZhUpW1ZXogdNYHUodYyp3+05KjcZQPfh2EawaVIKeiwhp6IuBcTb/kiQjjYH/ ZdMb4d+Vu0E9VcOE5TBCEU0dyO1RQFl4T4SE2wWKIcSoQdRGo7rhcMcx6x7s05kVqY/A 6+HlABoBiu58XihBjaoPKbjfD3HTRQITF1PISU/wuTEewpQHqRQGgnk7dhhg2kE/BpUA gsS6pEBSR7ZOYTx5Nn7K1Lkp77t3m5IIMcjZSZxCbV7r87Vh5Y5S4D/WQ6FjVYOM5OxV VA== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2esveu00sp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 11 Dec 2017 15:14:28 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id vBBFES3V013346 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 11 Dec 2017 15:14:28 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vBBFERos023804; Mon, 11 Dec 2017 15:14:28 GMT Received: from mhkanda-aus-1.us.oracle.com (/10.135.188.192) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 11 Dec 2017 07:14:27 -0800 From: Mark Kanda To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Mon, 11 Dec 2017 09:16:25 -0600 Message-Id: <773169891f9f2deb4cb7c4ef2655580dbe24c1d1.1513005190.git.mark.kanda@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: <52e6d742811f10dbd16e996e86cf375b9577c187.1513005190.git.mark.kanda@oracle.com> References: <52e6d742811f10dbd16e996e86cf375b9577c187.1513005190.git.mark.kanda@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8742 signatures=668644 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712110227 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 141.146.126.78 Subject: [Qemu-devel] [PATCH v2 2/2] virtio-blk: reject configs 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: martin.petersen@oracle.com, konrad.wilk@oracle.com, ameya.more@oracle.com, stefanha@redhat.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP virtio-blk logical block size should never be larger than physical block size because it doesn't make sense to have such configurations. QEMU doesn't have a way to effectively express this condition; the best it can do is report the physical block exponent as 0 - indicating the logical block size equals the physical block size. This is identical to commit 3da023b5827543ee4c022986ea2ad9d1274410b2 but applied to virtio-blk (instead of virtio-scsi). Signed-off-by: Mark Kanda Reviewed-by: Konrad Rzeszutek Wilk Reviewed-by: Ameya More Reviewed-by: Martin K. Petersen Reviewed-by: Stefan Hajnoczi --- hw/block/virtio-blk.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/block/virtio-blk.c b/hw/block/virtio-blk.c index fb59f57..36c7608 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -952,6 +952,13 @@ static void virtio_blk_device_realize(DeviceState *dev, Error **errp) } blkconf_blocksizes(&conf->conf); + if (conf->conf.logical_block_size > + conf->conf.physical_block_size) { + error_setg(errp, + "logical_block_size > physical_block_size not supported"); + return; + } + virtio_init(vdev, "virtio-blk", VIRTIO_ID_BLOCK, sizeof(struct virtio_blk_config));