From patchwork Wed Dec 6 19:54:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Kanda X-Patchwork-Id: 845327 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="DenQilyS"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ysVMs5n4fz9s72 for ; Thu, 7 Dec 2017 07:19:53 +1100 (AEDT) Received: from localhost ([::1]:57600 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMgAZ-0005pE-7Y for incoming@patchwork.ozlabs.org; Wed, 06 Dec 2017 15:19:51 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42907) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMfjw-00030B-M0 for qemu-devel@nongnu.org; Wed, 06 Dec 2017 14:52:21 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMfjv-0001EX-Pa for qemu-devel@nongnu.org; Wed, 06 Dec 2017 14:52:20 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:47457) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eMfjq-00013Z-BY; Wed, 06 Dec 2017 14:52:14 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vB6Jpf3G027682; Wed, 6 Dec 2017 19:52:13 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=Kfi0yNpewZy3rfWHkvMZGywmoOV0NjOrE67tBac4yao=; b=DenQilyS9rIbN/oUUvhWA7lZJlv3enRgS0LllHH5X0+drpv24rq1sH+P8PET5p53W7jM efEls1Rp6QdYPu6tH2mizXk28iC6t1qNF5dgC5mRauAbDUwLNlB22Uj3HsUCslBdTSHf g+YVeOhnUaInNXxYeDSdp3+9mUZMNmPr1swok3y5dyJbk/FjQa1UZYNj+ZW0duayaEKj fvRqG132WHOBhqPKFGEyoikAMuzbgqim5bdUVM5nWHSz7KPYg2hisvpCEn7t9USZfXFw k21jIK4/nrQxMYhEqwrz3+3w1BIe4452L39CuKM75YIcNA2H+GgEAkBlBcGDohxAvZ/y pQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2130.oracle.com with ESMTP id 2epct9arp0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 06 Dec 2017 19:52:12 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vB6JqCpa020503 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 6 Dec 2017 19:52:12 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id vB6JqBJd017157; Wed, 6 Dec 2017 19:52:12 GMT Received: from mhkanda-aus-1.us.oracle.com (/10.135.188.192) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 06 Dec 2017 11:52:11 -0800 From: Mark Kanda To: qemu-block@nongnu.org, qemu-devel@nongnu.org Date: Wed, 6 Dec 2017 13:54:01 -0600 Message-Id: <0a69463200d64d81dc27898ff92ecd10b126d968.1512589016.git.mark.kanda@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: References: In-Reply-To: References: X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8737 signatures=668643 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1712060281 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 156.151.31.86 Subject: [Qemu-devel] [PATCH 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: Mark Kanda , martin.petersen@oracle.com, konrad.wilk@oracle.com, ameya.more@oracle.com, stefanha@redhat.com, karl.heubaum@oracle.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 002c56f..acfca78 100644 --- a/hw/block/virtio-blk.c +++ b/hw/block/virtio-blk.c @@ -949,6 +949,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));