From nobody Sun Feb 8 22:35:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1578505916; cv=none; d=zohomail.com; s=zohoarc; b=DZgKuT2iRsDHu2hEytfhuy2pyC7jhem7NT32keR4nBgoVTlaD/danFnABfr7VTH34VafbbrYjGYugVJEEONjMOI43o8pyzODFMdUN7ZWuLf0WxPQY1mQbr7tPq2l9wfGxJ1rHZOEtZRcgVCqKyqx30CEn02SJZ18zvU12c1uGhc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1578505916; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7obi6hyBg9iHOq68BveAS3HpKksoZeB2IapeD+aUG5E=; b=VEOxKZqSff6bovkY30XXgHyDQ3E3JKzIa82AL75eOwQVzNewmRsmpW575W9UFj+0oTI7mOKiVJ5/T4MA9HFxzNUobBNUzLaT9fc5bxL5R69cCZzVkZ3Xo5pKqT5xaR1WUhDNtIo9aJ9h2wMGvTTfrUwEpn7NhHMIDua3nHYbECU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1578505916799619.6545505582149; Wed, 8 Jan 2020 09:51:56 -0800 (PST) Received: from localhost ([::1]:47450 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipFUp-0006rd-15 for importer@patchew.org; Wed, 08 Jan 2020 12:51:55 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:48336) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ipFTL-0005SM-Tb for qemu-devel@nongnu.org; Wed, 08 Jan 2020 12:50:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ipFTK-00015t-Nv for qemu-devel@nongnu.org; Wed, 08 Jan 2020 12:50:23 -0500 Received: from fanzine.igalia.com ([178.60.130.6]:55161) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ipFTK-0000WN-2V; Wed, 08 Jan 2020 12:50:22 -0500 Received: from [213.99.255.143] (helo=perseus.local) by fanzine.igalia.com with esmtpsa (Cipher TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim) id 1ipFT1-0001HQ-NR; Wed, 08 Jan 2020 18:50:03 +0100 Received: from berto by perseus.local with local (Exim 4.92) (envelope-from ) id 1ipFSD-0000Dd-Ci; Wed, 08 Jan 2020 18:49:13 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=7obi6hyBg9iHOq68BveAS3HpKksoZeB2IapeD+aUG5E=; b=L1WHH9FwDvZ8jxGFAS1TjWgWB+hfQs7L+NLdpAkN552GzvCL5ZAq6AhX6EQWJgjTZZGPk9C5KxpLhYOdARzDQQiTRzZDXMiLbo/gVJfu6QbtFZcxfHpcC0cigq81dMSoHmV0pUibTF6FeBLjFhTYrPPvulEN62dHsegDQQzcsePPEFIymXUwijhZjFezSzXVfgdoZQpRmyT1qBxeoo3uVjDe5fVfHQ4+rHxjlSscJo154rxdfO0u4Tg4Oz7cxjb0Z6xR9c9QrMOjnNHhRJC0B3cNKhYCt93X7guhHtsmHHwMqyRCPPZR6GcfA+8t/eTTRn+TVld5aWTS+u2yhwfdCQ==; From: Alberto Garcia To: qemu-devel@nongnu.org Subject: [PATCH 3/3] qcow2: Use BDRV_SECTOR_SIZE instead of the hardcoded value Date: Wed, 8 Jan 2020 18:49:10 +0100 Message-Id: X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] X-Received-From: 178.60.130.6 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , Alberto Garcia , qemu-block@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This replaces all remaining instances in the qcow2 code. Signed-off-by: Alberto Garcia --- block/qcow2-cluster.c | 2 +- block/qcow2.c | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 932fc48919..777ca2d409 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -219,7 +219,7 @@ static int l2_load(BlockDriverState *bs, uint64_t offse= t, * Writes one sector of the L1 table to the disk (can't update single entr= ies * and we really don't want bdrv_pread to perform a read-modify-write) */ -#define L1_ENTRIES_PER_SECTOR (512 / 8) +#define L1_ENTRIES_PER_SECTOR (BDRV_SECTOR_SIZE / 8) int qcow2_write_l1_entry(BlockDriverState *bs, int l1_index) { BDRVQcow2State *s =3D bs->opaque; diff --git a/block/qcow2.c b/block/qcow2.c index e8ce966f7f..6427c75409 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2175,7 +2175,7 @@ static coroutine_fn int qcow2_co_preadv_task(BlockDri= verState *bs, offset, bytes, qiov, qiov_offset= ); =20 case QCOW2_CLUSTER_NORMAL: - if ((file_cluster_offset & 511) !=3D 0) { + if ((file_cluster_offset % BDRV_SECTOR_SIZE) !=3D 0) { return -EIO; } =20 @@ -2514,7 +2514,7 @@ static coroutine_fn int qcow2_co_pwritev_part( goto out_locked; } =20 - assert((cluster_offset & 511) =3D=3D 0); + assert((cluster_offset % BDRV_SECTOR_SIZE) =3D=3D 0); =20 ret =3D qcow2_pre_write_overlap_check(bs, 0, cluster_offset + offset_in_clu= ster, @@ -3283,7 +3283,8 @@ qcow2_co_create(BlockdevCreateOptions *create_options= , Error **errp) =20 /* Validate options and set default values */ if (!QEMU_IS_ALIGNED(qcow2_opts->size, BDRV_SECTOR_SIZE)) { - error_setg(errp, "Image size must be a multiple of 512 bytes"); + error_setg(errp, "Image size must be a multiple of %u bytes", + (unsigned) BDRV_SECTOR_SIZE); ret =3D -EINVAL; goto out; } @@ -3839,7 +3840,7 @@ qcow2_co_copy_range_from(BlockDriverState *bs, case QCOW2_CLUSTER_NORMAL: child =3D s->data_file; copy_offset +=3D offset_into_cluster(s, src_offset); - if ((copy_offset & 511) !=3D 0) { + if ((copy_offset % BDRV_SECTOR_SIZE) !=3D 0) { ret =3D -EIO; goto out; } @@ -3904,7 +3905,7 @@ qcow2_co_copy_range_to(BlockDriverState *bs, goto fail; } =20 - assert((cluster_offset & 511) =3D=3D 0); + assert((cluster_offset % BDRV_SECTOR_SIZE) =3D=3D 0); =20 ret =3D qcow2_pre_write_overlap_check(bs, 0, cluster_offset + offset_in_cluster, cur_bytes, true); @@ -3961,8 +3962,9 @@ static int coroutine_fn qcow2_co_truncate(BlockDriver= State *bs, int64_t offset, return -ENOTSUP; } =20 - if (offset & 511) { - error_setg(errp, "The new size must be a multiple of 512"); + if (offset % BDRV_SECTOR_SIZE) { + error_setg(errp, "The new size must be a multiple of %u", + (unsigned) BDRV_SECTOR_SIZE); return -EINVAL; } =20 --=20 2.20.1