From nobody Thu Dec 18 13:29:09 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1566231816; cv=none; d=zoho.com; s=zohoarc; b=K1g7t1hqrurV9pLMZLfZguxeDe9FnhamJPZH3DVxEBu1iAzFnb3Ku4SpqDqkU7GoxHfp7eRkyPlnF/S4uBsnBtq0QzHLfKik+C6j6gaEEyzlTa76lLQE9cQ37QS4ZTZntG/BqJWzehKvAr6gc82iXjmdmhHcMNu4qkw7uOiYBRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566231816; 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:ARC-Authentication-Results; bh=ZrS5X0z7Aii68xEol8b7ejq1Wk6aSDV3hLFlooycVSg=; b=KMVAi8Ys72iKT5Brwt+InDcQ7Ih4cdhl5eXcb6NT05tha3URvyclWJmO8Rz1Mfsgu2iOCtSEnVvQeD7SrPLrfOjIT6S6+eSw8mneUjkFfriWswLXPd/ExKTA0d1HNsm0vxfz6kZNMmEcpOEn1tUNhibQ/PyRN0t+qAebTPTEryM= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566231816579416.7075558892045; Mon, 19 Aug 2019 09:23:36 -0700 (PDT) Received: from localhost ([::1]:55258 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzkRT-0000Wb-0j for importer@patchew.org; Mon, 19 Aug 2019 12:23:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35470) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1hzkM0-00037u-6a for qemu-devel@nongnu.org; Mon, 19 Aug 2019 12:17:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hzkLz-0006Pj-0v for qemu-devel@nongnu.org; Mon, 19 Aug 2019 12:17:55 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56548) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hzkLw-0006Mo-MC; Mon, 19 Aug 2019 12:17:52 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 00158190C10B; Mon, 19 Aug 2019 16:17:51 +0000 (UTC) Received: from localhost (ovpn-204-64.brq.redhat.com [10.40.204.64]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C0581DE; Mon, 19 Aug 2019 16:17:51 +0000 (UTC) From: Max Reitz To: qemu-block@nongnu.org Date: Mon, 19 Aug 2019 18:17:15 +0200 Message-Id: <20190819161723.7746-10-mreitz@redhat.com> In-Reply-To: <20190819161723.7746-1-mreitz@redhat.com> References: <20190819161723.7746-1-mreitz@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Mon, 19 Aug 2019 16:17:52 +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] [PULL 09/17] vhdx: Fix .bdrv_has_zero_init() 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 , Peter Maydell , qemu-devel@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Fixed VHDX images cannot guarantee to be zero-initialized. If the image has the "fixed" subformat, forward the call to the underlying storage node. Reported-by: Stefano Garzarella Signed-off-by: Max Reitz Message-id: 20190724171239.8764-9-mreitz@redhat.com Reviewed-by: Maxim Levitsky Signed-off-by: Max Reitz --- block/vhdx.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/block/vhdx.c b/block/vhdx.c index a02d1c99a7..6a09d0a55c 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -2075,6 +2075,30 @@ static int coroutine_fn vhdx_co_check(BlockDriverSta= te *bs, return 0; } =20 +static int vhdx_has_zero_init(BlockDriverState *bs) +{ + BDRVVHDXState *s =3D bs->opaque; + int state; + + /* + * Check the subformat: Fixed images have all BAT entries present, + * dynamic images have none (right after creation). It is + * therefore enough to check the first BAT entry. + */ + if (!s->bat_entries) { + return 1; + } + + state =3D s->bat[0] & VHDX_BAT_STATE_BIT_MASK; + if (state =3D=3D PAYLOAD_BLOCK_FULLY_PRESENT) { + /* Fixed subformat */ + return bdrv_has_zero_init(bs->file->bs); + } + + /* Dynamic subformat */ + return 1; +} + static QemuOptsList vhdx_create_opts =3D { .name =3D "vhdx-create-opts", .head =3D QTAILQ_HEAD_INITIALIZER(vhdx_create_opts.head), @@ -2128,7 +2152,7 @@ static BlockDriver bdrv_vhdx =3D { .bdrv_co_create_opts =3D vhdx_co_create_opts, .bdrv_get_info =3D vhdx_get_info, .bdrv_co_check =3D vhdx_co_check, - .bdrv_has_zero_init =3D bdrv_has_zero_init_1, + .bdrv_has_zero_init =3D vhdx_has_zero_init, =20 .create_opts =3D &vhdx_create_opts, }; --=20 2.21.0