From nobody Sun Nov 9 17:55:50 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551289087204783.2627745359297; Wed, 27 Feb 2019 09:38:07 -0800 (PST) Received: from localhost ([127.0.0.1]:48128 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gz39b-0005Qc-1d for importer@patchew.org; Wed, 27 Feb 2019 12:37:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51644) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gz2wZ-0003kx-J0 for qemu-devel@nongnu.org; Wed, 27 Feb 2019 12:24:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gz2wY-0003ov-7D for qemu-devel@nongnu.org; Wed, 27 Feb 2019 12:24:31 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50246) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gz2wD-0003D4-VX; Wed, 27 Feb 2019 12:24:10 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0A94B3E2B0; Wed, 27 Feb 2019 17:23:36 +0000 (UTC) Received: from linux.fritz.box.com (ovpn-117-19.ams2.redhat.com [10.36.117.19]) by smtp.corp.redhat.com (Postfix) with ESMTP id 605AC17153; Wed, 27 Feb 2019 17:23:32 +0000 (UTC) From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 27 Feb 2019 18:22:46 +0100 Message-Id: <20190227172256.30368-11-kwolf@redhat.com> In-Reply-To: <20190227172256.30368-1-kwolf@redhat.com> References: <20190227172256.30368-1-kwolf@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Wed, 27 Feb 2019 17:23:36 +0000 (UTC) Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 10/20] qcow2: Prepare qcow2_co_block_status() for data file 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: kwolf@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Offset 0 cannot be assumed to mean an unallocated cluster any more. Instead, the cluster type needs to be checked. *file must refer to the data file instead of the image file if a valid offset is returned from qcow2_co_block_status(). Signed-off-by: Kevin Wolf --- block/qcow2.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2.c b/block/qcow2.c index 11ff5e0434..8dc6f21047 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1817,11 +1817,11 @@ static int coroutine_fn qcow2_co_block_status(Block= DriverState *bs, =20 *pnum =3D bytes; =20 - if (cluster_offset !=3D 0 && ret !=3D QCOW2_CLUSTER_COMPRESSED && + if ((ret =3D=3D QCOW2_CLUSTER_NORMAL || ret =3D=3D QCOW2_CLUSTER_ZERO_= ALLOC) && !s->crypto) { index_in_cluster =3D offset & (s->cluster_size - 1); *map =3D cluster_offset | index_in_cluster; - *file =3D bs->file->bs; + *file =3D s->data_file->bs; status |=3D BDRV_BLOCK_OFFSET_VALID; } if (ret =3D=3D QCOW2_CLUSTER_ZERO_PLAIN || ret =3D=3D QCOW2_CLUSTER_ZE= RO_ALLOC) { --=20 2.20.1