From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446629; cv=none; d=zohomail.com; s=zohoarc; b=i8dC6GtTcGkJiYlbu6NbsPdREkOaXVZqbv6L8xMS45gbrNXbwjfOpGIkw7fRrTQ+FbaMvCnMi5Mf76TToGERfgNZmqWUzpTUEwsMTcYd5nkSaCkPL6tsFlIpx1+aW7OMYp+Y6eI/GNGXzp21VbcMhRuZEjRqL5IFFdMvZszOPw8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446629; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=AUPnthLnZv0HXOGLcjECWuJuRRQZL1kc6hOnrSo+zaA=; b=DaBh5KTzZnfbxpST8gc0GVYHTr+/zmUB6jhHEgjmuPm4w7yKEGuzp2mChGtDQ6GlV3TkAaCxQva58G6U65tO6M5fQFmDM02GkClNKe27Lss0/bEWjTX2VdlhVok9ZWy/WRHTH8TnrD6xaBntwyx10sHdNlyLKdHAy4A5snPSwF4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446629539839.5387092684421; Thu, 3 Sep 2026 07:43:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28ey-0002dz-QS; Thu, 03 Sep 2026 10:43:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28eq-0002c6-BE for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:17 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28eo-0003y4-2l for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:16 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-482fc3327fdso1618250f8f.2 for ; Thu, 03 Sep 2026 07:43:13 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446592; x=1789051392; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=AUPnthLnZv0HXOGLcjECWuJuRRQZL1kc6hOnrSo+zaA=; b=lDKeTulRFNCvNkz/xgMow6GJR6udW8wx8a+P+9wakASRdUNhXCdaQlI5YIR+uevsGu UGegSLKc7a2pcqx3MSKo/Ms2gyzSeHovN7REutOH3mLF7TpDllnk2omxzPUEz3s+T5zQ EDektBlr1SsKdw9jTQF39n0ZFp/ZisNxPsL6wCvk0OsF5HLDPXDT0qKMkcBt/M/cZJCX BG0oG8jdgu0iGIeGAlJUyVjGV/dPvh8hSQ8kcZQJrfH8LQZM1IcVKyaqpdMBE9dw0UqF iJD6tUv/q50fXdYtbzvLgV5ZZid8DvCY3hU88F2PJryXlvYWDP3h0shjimsopo+VOKnh OmgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446592; x=1789051392; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=AUPnthLnZv0HXOGLcjECWuJuRRQZL1kc6hOnrSo+zaA=; b=CsnGOIrUSYKAM1q9jCG1UIdBRvQf13M7p1puRhs+qLDKG2XQ3qJv3BKclsTpmJGkL8 Z7qcc4zOmZ9S1TA660kwr7XkZYccyrpo5CrEeCh3XqQ/PSrGIj4oPHTW6PrVGze89kJs bkTXkXPNrJy7NnaKhoizFPFKOckR0gxphSWQ/fLfWFL/8Psg9WI3IwPk8SbTrJa8xkyA 18mlmjyLkOI98tZqO6A9AKJHgyNbNJN3yD2HteLQh+r3vAMyUfMmYo89LoTkwtUtqQ4K IuUGc2kK+nAJt8ox4eNsULzaR7Z+rZfLtda4PiFjfauznquBNcVDb42ES7WmpnrJaJq9 n1Bg== X-Gm-Message-State: AFuF++lN52EQp6NkAKYxHWtdEbD3b0iVbdeq2cnsMof/NrDPfaL/SOB4 sSSPW48KlqlGZ5mzhbu91/prToSvSvZO76wx1wsKxZgmBNBWP9c3Vwe4PsNEDDymoUnQzj/3lJc 0MSjB X-Gm-Gg: AYBFou3weXuNofCPfd8sQXnlnjkZFOPfECjfkz2yDGlAvi6MgKYSGdScOdcFjM3w+TH 3HMK/caMR2cGcNIWr6rsss8Uksh/r0w+ZbmYUAXFoU+lU1/Agw73sGHdvQ5rax01d0huLkHZ2QG GOJmMMJOMdQk0BLxUkQry0W+QB9vTT/Eh19pmtThvg1P/K0BIvvI6T09qNhfMiDUyLH7FVSIier b28ikkbEBx25PCbOTpa1dyfyrRlrGsg2ulAkjiSBABbZWifAML8mFrg38ChpIZo7QdEgHmH4Wh6 S5bbdRfBBWWmFzo5/3UCKxkJQlwB03L4CZX6DmYbdK/UXUGQlaQIQmPmaTP3xlHalyvKRoYesfc 5UeTg285eJtWT1AymIvlXvscBV+O1Q5wZt8NxTVl603zSTiGpeNV4vJbmFaDF+v80KBEescNJwq KqjgexA75Lv4pdEES4CH1vF9Z/j2dcVJBPYzVjupiko8NnzJYWGIVJm3rJ X-Received: by 2002:a05:6000:2512:b0:47f:fb2e:f63d with SMTP id ffacd0b85a97d-48586069579mr1524464f8f.9.1788446591101; Thu, 03 Sep 2026 07:43:11 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v7 01/25] parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap() Date: Thu, 3 Sep 2026 16:41:19 +0200 Message-ID: <20260903144143.2328870-2-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=den@openvz.org; helo=mail-wr1-x430.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446631964158500 Content-Type: text/plain; charset="utf-8" From: Alexander Ivanov After used bitmap freeng s->used_bmap points to the freed memory. If we try to free used bitmap one more time it leads to double free error. Set s->used_bmap to NULL to exclude double free error. Cc: Stefan Hajnoczi Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Signed-off-by: Denis V. Lunev --- block/parallels.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/parallels.c b/block/parallels.c index 50748d1415..94692275c9 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -254,6 +254,7 @@ static void parallels_free_used_bitmap(BlockDriverState= *bs) BDRVParallelsState *s =3D bs->opaque; s->used_bmap_size =3D 0; g_free(s->used_bmap); + s->used_bmap =3D NULL; } =20 static int64_t coroutine_fn GRAPH_RDLOCK --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446649; cv=none; d=zohomail.com; s=zohoarc; b=Yz/KQWVuJxliuXAOxWFBJwli04Xb+3rNSGjjIoJblYd6X2e3r1C6ZNk9tc4nQQkXuFwLj9mxK8Kk1IVlI82o5JpOHoAl2A2d3Zl60fW604mon3KBSwu0o5KiFCjBr8bZdyn43l8toLYpjloUODWV4l3Ai37eE2rbn/Hymvc1YH0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446649; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Ge1jeswhVctr5Jsow25jpgxpoGxNOiJ1+3Iq4dhUSxM=; b=MJrdZd5SKfaB0xicAnxt6doUEllLSy4zh1raKRo6gtx/Cv3uz5PSB8njKw3pZDiaa2ZmjI6ks0NWQ8msEVncYTmQ1hUpS6JrmsK9Cb0B/HgEZ3w16zdv3P/JrFYEbeTQCZCxJzkHRfSXhQ1MPI0EaQsvL+3P6jdee0HoMrggrro= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446649201938.181007876076; Thu, 3 Sep 2026 07:44:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f4-0002g6-Dz; Thu, 03 Sep 2026 10:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28es-0002cj-Nb for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:18 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28er-0003yl-2U for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:18 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4995b0343c1so27643035e9.3 for ; Thu, 03 Sep 2026 07:43:15 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446595; x=1789051395; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Ge1jeswhVctr5Jsow25jpgxpoGxNOiJ1+3Iq4dhUSxM=; b=bW3oXd+hxg99A2efbeur9v0hH3uT5k51Dy4AM1O9RNWuddDh3dyoaodmDqBpEoAqk+ Bg9a+5RRXKUFc0jbbdWwzDNICWlH/sZBMIx0ifsFFrSAbPlZoUO5UxmtbFkuMeFsiejg I0Fws6QzhCPwEGUtD5/zQlj+aNv43MvNCcasYSzLoo3KirBviPM7sHyGxZO43wZwsHDt //F8ebgx0E1W3CMHasIqmWFh/c324/E+FM84kmOfcALcNlRdcs+8VXCevUylnoQ8i1ic s/Fu9FyE7YNI1UB/4jYBpTiE3CNEE60Voh19MPLWSn+7RniL4K2LqphEAUMApfqky38S UrWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446595; x=1789051395; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Ge1jeswhVctr5Jsow25jpgxpoGxNOiJ1+3Iq4dhUSxM=; b=ZTdfgPwU2I02QYaYuT3NkBqpv8jAE4RA4DW6ooAJVA7ECOQWbPWDgOw2MCa3UIg7U2 w2XWeOUjJuD6DMVV+o01Q+o5b90Nemj8MMtJfHzXysuYWPNSpgszAQByhNDsatDutVGo b78wI/2GHXGUQZoUc6nDN3Rxo2LB3K8g4qycYlwtHgKN7bT175gEumWusbTbPeea3io4 wFFQq/RMkTLGkjj1j3EZ5LcHW3ltRRG2Q7XgAlvYkvwocdlMTQAO0vMkwvOm0D/qfASJ wmY6XOZv5S2oK4grfn0Qd8WSyPDj551AfXnDeEeRIqLH+nK2T8EES274N4AIZVfuWmER dGYw== X-Gm-Message-State: AFuF++nsd8xl4OqQMGgyyeRF8qgsCYjjatSzIJYoV5DDxyF9x3ne7DxK YvfqLbTfeuuhqGDAWSe+0g+nl6quaDc725+bEw5C000awbvv4Q6Zjjdgd1+Z7zT1aASGRXEoAnb 7rtly X-Gm-Gg: AYBFou0xTRpwirHIvmjNS19xrnKE9fZdiAdEtYBwyb9QxwFKL7bilVHUR15AT59+lcS JvynmHuURGKmNWQfRxPWb6dRGHoNt1lP3VsA9fOqFlb/yE8JncO5Y4v8AuPM+GK2yVH+M5fmOGR 1JAgdQhV9ds/HxcqQi8isIzfzNsOICxRR31W//juNSwn+aKA+ZkTrd/G8aoavx5RBMGihQG08rS BREzmHVQ4RU5VWBuDSxJItkZ185dPJ+5XajU7Zt44DGGo9HJatf4WmhRYYY8neSE7gKzXhjZBBk 25b21hzcMClbLm1L9VSRRwDTFgXCHRIx7CpIJsESaOopCVC7nluT5VjNOfy56IR+em5VwCQKfL+ kffhiEeWBJNIdRp3DX9l79sshQXigVThfRrZpMpF367PqeLOSJBmLmo9k0kGSwPS03PEJBhzw6y CwO7GdalaPH3zjaGiFuAUZVh913TYLOR6m85IzeGYiQFGyYPi/QaBhqTmq X-Received: by 2002:a05:600c:8b88:b0:49c:e1cd:536 with SMTP id 5b1f17b1804b1-49ce584b899mr227465065e9.12.1788446594558; Thu, 03 Sep 2026 07:43:14 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 02/25] parallels: split inactivation out and add the activation counterpart Date: Thu, 3 Sep 2026 16:41:20 +0200 Message-ID: <20260903144143.2328870-3-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=den@openvz.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446651737158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev We are going to add parallels image extensions storage and need a separate function for the inactivation code, which parallels_close() carries inline today. Move it into parallels_inactivate() and register it as .bdrv_inactivate, so the image is written out when the node is inactivated and not only when it is closed. The condition guarding the old call moves inside, as the handler is now reached for any node: bdrv_inactivate_recurse() calls it and blockdev-set-active can ask for it at any time. There is nothing to write out for a node we can not write to, and trying turns a request which has nothing to do into "Failed to inactivate node: Operation not permitted". Clearing the in use flag now needs someone to set it again. parallels_open() is the only place doing that, and it does not run when a node is made active again, which would leave an image whose header says it was closed correctly while it is open for writing: a crash then looks like a clean shutdown and the repair on open is skipped. Add parallels_co_invalidate_cache(), the counterpart of the above, which arms the flag again and reports through errp when it can not. The flag may only be cleared once everything which can still fail has succeeded, as a failed inactivation leaves the node writable and the image has to keep saying so. The order is therefore the reverse of the code being moved: truncate first, write the header last and answer with the result of that write instead of ignoring it. The migration blocker stays, though its comment asks for it to go once an activate method exists. An activated node needs more than the in use flag to be correct, as the used cluster bitmap describes the image as it was before the handover. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 94692275c9..f02ad7a0be 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1481,6 +1481,41 @@ fail: return ret; } =20 +static int GRAPH_RDLOCK parallels_inactivate(BlockDriverState *bs) +{ + BDRVParallelsState *s =3D bs->opaque; + int ret; + + if (!(bs->open_flags & BDRV_O_RDWR) || (bs->open_flags & BDRV_O_INACTI= VE)) { + return 0; + } + + ret =3D bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, + PREALLOC_MODE_OFF, 0, NULL); + if (ret < 0) { + return ret; + } + + s->header->inuse =3D 0; + return parallels_update_header(bs); +} + +static void coroutine_fn GRAPH_RDLOCK +parallels_co_invalidate_cache(BlockDriverState *bs, Error **errp) +{ + BDRVParallelsState *s =3D bs->opaque; + int ret; + + if (!(bs->open_flags & BDRV_O_RDWR)) { + return; + } + + s->header->inuse =3D cpu_to_le32(HEADER_INUSE_MAGIC); + ret =3D parallels_update_header(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to mark the image in use"); + } +} =20 static void parallels_close(BlockDriverState *bs) { @@ -1488,14 +1523,7 @@ static void parallels_close(BlockDriverState *bs) =20 GRAPH_RDLOCK_GUARD_MAINLOOP(); =20 - if ((bs->open_flags & BDRV_O_RDWR) && !(bs->open_flags & BDRV_O_INACTI= VE)) { - s->header->inuse =3D 0; - parallels_update_header(bs); - - /* errors are ignored, so we might as well pass exact=3Dtrue */ - bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, - PREALLOC_MODE_OFF, 0, NULL); - } + parallels_inactivate(bs); =20 parallels_free_used_bitmap(bs); =20 @@ -1533,6 +1561,8 @@ static BlockDriver bdrv_parallels =3D { .bdrv_co_check =3D parallels_co_check, .bdrv_co_pdiscard =3D parallels_co_pdiscard, .bdrv_co_pwrite_zeroes =3D parallels_co_pwrite_zeroes, + .bdrv_co_invalidate_cache =3D parallels_co_invalidate_cache, + .bdrv_inactivate =3D parallels_inactivate, }; =20 static void bdrv_parallels_init(void) --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446629; cv=none; d=zohomail.com; s=zohoarc; b=maHyB4imfasX2JCek6sgtKGOQbWKoLhbNoLE0YHQykAiAYtvQFW0NaqJqrs8bqR2Zl/xn06gy8zeC+2Dag5LxoN8w8nLxgseY4A1YNcyZeQo7W0bEqTfIFwlkw7rWwMWS/rndWkUjynSjLdalFZZoorMSZm7KCgyn6UfZaiL+kk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446629; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=PTSvhPF/t9fH+un2rRT0I6FggMjWoGeZijLFp6youZ8=; b=ezBukcR1a1hZMma+PigsfOCLplbj4CxERsEijoFu6yXFzCMfjHm7TS1VljmVtQKPPmMaJS15P1RNm9h8fCmqn/q6UcrFKO+lXBGce854ICaN179slF8uwVtBBiMsV0d/mQzjfRDHzwgtYMmNHFQCSxsfXnkFpe/G28fWa6X+s1k= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446629530317.08359757514677; Thu, 3 Sep 2026 07:43:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f4-0002gC-DX; Thu, 03 Sep 2026 10:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28ev-0002dY-2J for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:22 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28es-0003zO-87 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:19 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-482e257a23aso1741018f8f.0 for ; Thu, 03 Sep 2026 07:43:17 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446597; x=1789051397; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=PTSvhPF/t9fH+un2rRT0I6FggMjWoGeZijLFp6youZ8=; b=TyMuoAYNqbOnLFV9xWTauDpQs5b4/hZi56bnwMM3BGzflc/ZvVjXvfjORvAHujitd4 YPaZiqrQw7rd5WhNRv2xnp9sFcRBZFbf8GtU1MGRwEtEbB201GbcvlGPGjqz1mNYtyjY PM60y+cUT/HnAKx/ZdQbQy1Yo08lfRimQZ2ybyzfxASFNmQdIgqHesCtM4QK/m2t39sx AqCptw9YI49xx2oHXzu/kdol/3HVqcxdASVL2WuxKXlR505d74/Fhh0ct0fz0jWdoqa1 iuwdbtdCbyEzzdM0+O/w2V0NXwgl3nrzT6HRlb0savbd/QjiwnrFSvrBaOxjZM0uXhVl g5tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446597; x=1789051397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=PTSvhPF/t9fH+un2rRT0I6FggMjWoGeZijLFp6youZ8=; b=gKB+Wg4igX0ySCoMzgck0ehvWm8IKP/wUbdELdGRAHx3CYD6gIYAhbyPpNmwTKLGg6 j1NFgPtNE4qZ1fWyW+PYiGltE05xqwgZLseYAcfUJqZhx62V9//6LKt6kV+V4fQ0TprF Bn72WnkqqtTDYe4kL1wRfAg7R2M9sK1CDDFLkX177TYRp4YzubBi+ShIj5Jt2fRjjqLI 46wv+/p/yhGSA3FtJBBE+mA1aXAGeyTRVCJIjkwb8yTS2TwFU6iuDJ3zIrhM3xzLQQ50 43op2nquR+c+INW2nN1QzYb3Rt7r2G1VOLgdjCDHz+6D9sTtm1MYAWBHzbF7VtrmjCuH FjZg== X-Gm-Message-State: AFuF++kH1U0oUCqp8OauX1z1PDfuveQURSgTn6BgXhavtD6R14fBZd2b 2dzkdkuJLr/6BPaMOtPF+L+dXEuRcGvvxWz+TvWo344zw4rcnhfLmL7gYDwJtrwRJWqJkICNh+b 3wsq/ X-Gm-Gg: AYBFou0f7WZ7fJEfn+L3AnAJpzCgUHv4XP9zRGD8DgHZMp3QlZRh/LtBTbY8NeVKrVS KYEtJ/K/PD7sn4ozKxCAWgPz8ccbepPyXIdjIM9w5VcvDkWS4hR2IL3gxCPPVh7iXqdLUPwDFK+ R8rq+om8A2MKFxq57crQCaTYkLwsCa9zYkYcMzfrCb5H0h9mrfJrkVFCcyp4vULMZGth2R3bDGy lKub4eWOnZtvdYM5bg61AsAHcSiu0XcGWHre4qnHy3CBF3Xs7DJ1B5Vud/GZjSyNDj+vOT+Psns Jun5pjb0mJAT4hUjoui0MCo2uloXKN7r8z/aoJl1g06cpq6iIUB0UI3iU7HzEmFJ4AQEvyAvi4O x+KRTuUpH3zBCeegCjd3Zk9hEok/EddmkbjM2+TGM7iFnw7iI4kj1jIWA+bXlNhn4YbY4ateblC Ofjcvwu8JjhY3dh3cUeKtJ4wsBjrhRmByq+ETm/7dnPxIoHKS5aVn1ApyeNv5x54MlYOI= X-Received: by 2002:a05:6000:25ca:b0:482:fe64:1717 with SMTP id ffacd0b85a97d-48488dfb16amr21047556f8f.7.1788446595590; Thu, 03 Sep 2026 07:43:15 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 03/25] iotests: cover inactivating a read-only node Date: Thu, 3 Sep 2026 16:41:21 +0200 Message-ID: <20260903144143.2328870-4-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=den@openvz.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446632016158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev A driver which writes something out on .bdrv_inactivate has nothing to write for a node it can not write to, and has to answer such a request with success rather than with the error its refused write produces. The test inactivates nodes in several ways and never a read-only one, so nothing caught that. Add a read-only node and take it through a deactivation and back. The case is generic, as every driver implementing the handler has to answer the same way. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/tests/inactive-node-nbd | 14 ++++++++++++++ tests/qemu-iotests/tests/inactive-node-nbd.out | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/tests/qemu-iotests/tests/inactive-node-nbd b/tests/qemu-iotest= s/tests/inactive-node-nbd index 664157bfd0..24242265b1 100755 --- a/tests/qemu-iotests/tests/inactive-node-nbd +++ b/tests/qemu-iotests/tests/inactive-node-nbd @@ -47,6 +47,7 @@ def node_is_active(_vm, node_name): return node['active'] =20 with iotests.FilePath('disk.img') as path, \ + iotests.FilePath('ro.img') as ro_path, \ iotests.FilePath('snap.qcow2') as snap_path, \ iotests.FilePath('snap2.qcow2') as snap2_path, \ iotests.FilePath('target.img') as target_path, \ @@ -58,6 +59,7 @@ with iotests.FilePath('disk.img') as path, \ iotests.log('Preparing disk...') iotests.qemu_img_create('-f', iotests.imgfmt, path, img_size) iotests.qemu_img_create('-f', iotests.imgfmt, target_path, img_size) + iotests.qemu_img_create('-f', iotests.imgfmt, ro_path, img_size) =20 iotests.qemu_img_create('-f', 'qcow2', '-b', path, '-F', iotests.imgfm= t, snap_path) @@ -70,6 +72,9 @@ with iotests.FilePath('disk.img') as path, \ 'active=3Doff') vm.add_blockdev(f'file,node-name=3Dtarget-file,filename=3D{target_path= }') vm.add_blockdev(f'{iotests.imgfmt},file=3Dtarget-file,node-name=3Dtarg= et-fmt') + vm.add_blockdev(f'file,node-name=3Dro-file,filename=3D{ro_path},read-o= nly=3Don') + vm.add_blockdev(f'{iotests.imgfmt},file=3Dro-file,node-name=3Dro-fmt,' + 'read-only=3Don') vm.add_blockdev(f'file,node-name=3Dsnap-file,filename=3D{snap_path}') vm.add_blockdev(f'file,node-name=3Dsnap2-file,filename=3D{snap2_path}') =20 @@ -289,6 +294,15 @@ with iotests.FilePath('disk.img') as path, \ iotests.log(qemu_io.cmd('map'), filters=3D[filter_qemu_io]) qemu_io.close() =20 + iotests.log('\n=3D=3D=3D Inactivating a read-only node =3D=3D=3D') + + # A driver which writes something out on inactivation has nothing to + # write for a node it can not write to, and must not fail the request + vm.qmp_log('blockdev-set-active', node_name=3D'ro-fmt', active=3DFalse) + iotests.log('ro-fmt active: %s' % node_is_active(vm, 'ro-fmt')) + vm.qmp_log('blockdev-set-active', node_name=3D'ro-fmt', active=3DTrue) + iotests.log('ro-fmt active: %s' % node_is_active(vm, 'ro-fmt')) + iotests.log('\n=3D=3D=3D Resuming VM activates all images =3D=3D=3D') vm.qmp_log('cont') =20 diff --git a/tests/qemu-iotests/tests/inactive-node-nbd.out b/tests/qemu-io= tests/tests/inactive-node-nbd.out index 0fb8c18d87..96af7608de 100644 --- a/tests/qemu-iotests/tests/inactive-node-nbd.out +++ b/tests/qemu-iotests/tests/inactive-node-nbd.out @@ -227,6 +227,14 @@ qemu-io: discard failed: Operation not permitted qemu-io: Failed to get allocation status: Operation not permitted =20 =20 +=3D=3D=3D Inactivating a read-only node =3D=3D=3D +{"execute": "blockdev-set-active", "arguments": {"active": false, "node-na= me": "ro-fmt"}} +{"return": {}} +ro-fmt active: False +{"execute": "blockdev-set-active", "arguments": {"active": true, "node-nam= e": "ro-fmt"}} +{"return": {}} +ro-fmt active: True + =3D=3D=3D Resuming VM activates all images =3D=3D=3D {"execute": "cont", "arguments": {}} {"return": {}} --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446799; cv=none; d=zohomail.com; s=zohoarc; b=CIybiQkmUatePF7L7Hc8FFKVFqdyyXKAY7pIaw49UWJaklngDl6qX7fOxBmCSkeRSCywdzSSu0yUUedYuOXWD+thjLPsw3PnUXg2T6KvKmqi+cQY+GfBbEhojMPBlQlxxoHCWj2ykIdR6BkBznsVZY0T4geRWAHUH3ZLh51pbVc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446799; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=gOCgb/8qYTx3Tvjv6qT01WmwOcfq9B2Xk9PXWdyz6VY=; b=fHFSC/RSd7BfjJ+nDn0v9acdz0YdkuCNjAOCRA3B1Ptsg1i0fV15PYoiXC+4Qu451VHnzbrMdzJbIfvBQq7cbFOHigBvwODnISfYMARiD0K6NKK/GoKrwdOlL4vlQtqjyI6A3yBRB5XyavcagDIIRGKRWQP2KJqizDAwZIaP1TE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178844679979769.03686799996376; Thu, 3 Sep 2026 07:46:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f6-0002j8-Sk; Thu, 03 Sep 2026 10:43:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28ev-0002dX-1L for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:22 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28es-0003zR-8l for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:19 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-484374f54d0so1542499f8f.3 for ; Thu, 03 Sep 2026 07:43:17 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446597; x=1789051397; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=gOCgb/8qYTx3Tvjv6qT01WmwOcfq9B2Xk9PXWdyz6VY=; b=YznJL2N3wiIuDJOb7eankpuwZQOoUuMilTenlIoHM1/vWXE1estpNTc3DvDlfrYSbV qDAAtg35UcvSv5ljDIoFsaqzUR6dyPu5UmjijHG39tm2RSw3Im2Z6zf/mNDWo4FtU7tX 5LAZOtRy7b5LatbDn+7NfcM4hFoqZEH0/H+gLtaWqWsDSL75x9TQr2UAdwjvYxR+KvLq dHoiKHtZeh8aCsbFfoKbRF2g/MnC/UyThI9tnFolMdHUi0BkB7kWd8My8ch51bTlpanR i2VyglMjahz3xRjsmmb9kMBMZfO1i+RhZZQe1cTOnZsQKPzNY2kE8lk1p27alp/HhaAM oqew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446597; x=1789051397; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=gOCgb/8qYTx3Tvjv6qT01WmwOcfq9B2Xk9PXWdyz6VY=; b=TqBNM2OvWtObQRiOwHzWv5zDwwpjzmmUbRpMzA97ESxyiBUKbPlkalmhHapoD38bhs X9c+SCK0xj5KD7Cp+gCjLxSl3KhwBIxONTO7iGRvNsdF7DwO0tcytchcpa8H43hK3NDY mwlm9Qtb+QDw0KzrfEUCzK8fUzJZ7V9KC6uQMp3Igg2ybxAzDRNYEFFjHNR8SzOkOSSB 0CTgjtjsdicV/x34bhZ1lRAH4oNEzvzSh13Q0sln54vAIEs/gM3+aoDNfhDaKO33c1tT ZIJlsiB8ju+DsshVrA8Et/Ik0BOn+Y8H/eZOe6eoxuxOZu/egmGJl+X5I2QWIfWv9de2 0JjA== X-Gm-Message-State: AFuF++nbLiHdPjGI+38qjeaPfazeeY4/gAz+wQqYfFrrgPyG7KrGsz9f 8lwjvLzjIENKtAmGdUYS6D1OAENv0oAUHyuYIC4YTqa/l9mDDFq7kbFtoVN5z8jUdBxvgSnFag8 iDXFU X-Gm-Gg: AYBFou1Xjjt6n8VBrJ02tkMx33suFx7TuHV/TrIVxlFEEjr1TLcxle3ZomipdtMeopQ lW8xkHFkW1QnDCeHFWl4PPB2v9zs/4+uPrN5iCeAV+Smxy2Hdz08yN1IHFunLMV7FFhZv95dBKk AMSeO5JX3x2D0tD+plZrqJniohkDjxEewkvXl8casgRSj0+LSkgu/0/f3uYRsdBy3Ppni/1ps8x nyf4hixwlqzABv5eJiP6MTyGDEH+BzCWaIbXBpdMj0ZuFp35oOMoI8WuxbuPZUvspv0eTcpVFEm Hit/bQ2tShh8gG3isHBEd0RTLTrI97mWSHGmET80X56Cp0XwZP+iLLFN708huQT4qKipUHGrflg 49VfTFNvSG/0qLbbIL6q2AYnIODaBYB33McVd8kdMuQME33kNGXzDV/L2iuclPKxi3AlHj2AaoU mCy5Dl38Ie/yAeoLluRi/a5qVTj6i9DJurQcXjWVNwoST1I8XnsUdsjOjI9A2D9k0JrMdM X-Received: by 2002:a05:6000:1a8c:b0:485:8330:64a with SMTP id ffacd0b85a97d-485833009demr7000064f8f.6.1788446596798; Thu, 03 Sep 2026 07:43:16 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v7 04/25] parallels: Make mark_used() a global function Date: Thu, 3 Sep 2026 16:41:22 +0200 Message-ID: <20260903144143.2328870-5-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=den@openvz.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446800603158500 Content-Type: text/plain; charset="utf-8" From: Alexander Ivanov We will need this function and a function for marking unused clusters (will be added in the next patch) in parallels-ext.c too. Let it be a global function parallels_mark_used(). Cc: Stefan Hajnoczi Signed-off-by: Alexander Ivanov Reviewed-by: Denis V. Lunev Signed-off-by: Denis V. Lunev --- block/parallels.c | 14 ++++++++------ block/parallels.h | 3 +++ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index f02ad7a0be..6f7a9911d7 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -187,8 +187,8 @@ static void parallels_set_bat_entry(BDRVParallelsState = *s, bitmap_set(s->bat_dirty_bmap, bat_entry_off(index) / s->bat_dirty_bloc= k, 1); } =20 -static int mark_used(BlockDriverState *bs, unsigned long *bitmap, - uint32_t bitmap_size, int64_t off, uint32_t count) +int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count) { BDRVParallelsState *s =3D bs->opaque; uint32_t cluster_index =3D host_cluster_index(s, off); @@ -241,7 +241,8 @@ static int GRAPH_RDLOCK parallels_fill_used_bitmap(Bloc= kDriverState *bs) continue; } =20 - err2 =3D mark_used(bs, s->used_bmap, s->used_bmap_size, host_off, = 1); + err2 =3D parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, 1); if (err2 < 0 && err =3D=3D 0) { err =3D err2; } @@ -375,7 +376,8 @@ allocate_clusters(BlockDriverState *bs, int64_t sector_= num, } } =20 - ret =3D mark_used(bs, s->used_bmap, s->used_bmap_size, host_off, to_al= locate); + ret =3D parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, to_allocate); if (ret < 0) { /* Image consistency is broken. Alarm! */ return ret; @@ -840,7 +842,7 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvChe= ckResult *res, continue; } =20 - ret =3D mark_used(bs, bitmap, bitmap_size, host_off, 1); + ret =3D parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); assert(ret !=3D -E2BIG); if (ret =3D=3D 0) { continue; @@ -900,7 +902,7 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvChe= ckResult *res, * considered, and the bitmap size doesn't change. This specifical= ly * means that -E2BIG is OK. */ - ret =3D mark_used(bs, bitmap, bitmap_size, host_off, 1); + ret =3D parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); if (ret =3D=3D -EBUSY) { res->check_errors++; goto out_repair_bat; diff --git a/block/parallels.h b/block/parallels.h index 423b2ad727..68077416b1 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -90,6 +90,9 @@ typedef struct BDRVParallelsState { Error *migration_blocker; } BDRVParallelsState; =20 +int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t count); + int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, Error **errp); --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446766; cv=none; d=zohomail.com; s=zohoarc; b=GK9LyiWgTT1IaqqTQpE92zAUpesDwalPr+4iCh2iEl/CE7NfIVO+7gmqjebn7sBscUMIlKJhpcbP5+C2WUOXUmlvfKpde1qlW0cXc2JnymDU74feUxO/0f6F2T2LTqWBaHCvJE8KbnDKOmB2IGcYYTaXzNAnN7kso74enUeqrxY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446766; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=DvqpQ/5WW7AkpDNQqqrysO6vi5pABEqrTUwHZBF/GFc=; b=NqsdFf9yU8orFSg7ODfIovFp0VoY68zfaB5HTTEa+Op16Wz/wF48OrJd6b74G2o0pb9ltcf7AxVYHtzfG3vvmVgzyBzxvgbxWnxUCHw/VqYM5h7tUaZUB4VQoNQqWihttD11YqfA29WZ3/Mn3HGBil+QiigO7kPQHhQUIN8g3ds= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446766453738.3303050944897; Thu, 3 Sep 2026 07:46:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f0-0002f1-Dn; Thu, 03 Sep 2026 10:43:26 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28ew-0002dk-Mj for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:22 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28et-0003zq-Gy for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:21 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-48441a2ba1bso1571409f8f.1 for ; Thu, 03 Sep 2026 07:43:19 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446598; x=1789051398; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=DvqpQ/5WW7AkpDNQqqrysO6vi5pABEqrTUwHZBF/GFc=; b=XFWTDFMwy1yCrH6zQ+gXh14Gl1DCL5Xk0BSZzHoNEmAAUUiL7mjpCAN2+HV1puZlGb B9tKXq1soJaoMDQwrZVHKYBCllYPzRzF/Gx99UTPI2N/3FTHwkuFBgSPSvVP4ShGZNkA dTkLXDldlPAUOFdOVMjRPqiCEJI1yRK4+IXgHMWjGeHwl2SUtA3+9+guEWishLw8AkLB Uy/miZeuZmAF8+Io9cgLX5bUmfJT/JJ4k/CGq9sASqxCWK+0bQKqIVWXYBMA1VPBi0hX CJF03m8AnYCPri/e+C9eW6dFZn0hI1lSA3r0aCvNYrrrk+2N7aB8Airy7zv8+aDwzn2z Xlqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446598; x=1789051398; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=DvqpQ/5WW7AkpDNQqqrysO6vi5pABEqrTUwHZBF/GFc=; b=qE8mI6zU1GUWeyuJ6UAoFLEMtuc79wrv+C8AaAP1IQ9MI0EN86u7Ohc4kP5qtOSdOO v9xruzPB6a/rdSnChh9vs+cdZc9/L7KW+7xer1/qplEm6X+8OeKbfwi86uQsVo6J90Qo XciplOXrWS2k/qmfx8HypQ0R4N+NcjD3TbnfbbBNwcvw66INDth8VQ//x+XibWZo9lwa odS2eVfGCSnts2bgp4zKfWhIWrkLpbXJNrLWHZpXNnQeAhULTr0nyt6z60llOBKQrr6W YEClzIxu2Xz53NEh0Je5Y1uqVAbxokyWEXnr9idLTacnQ0vpQICKklLus5nCbVVKbpNg eOew== X-Gm-Message-State: AFuF++lgjz4i59mH70Iq0swmK98on5qVw7OYQCx1Kbr1p6tblQhBK/TR lK8qJ8Z7TNPqFPQp9nPSkKjDIgJvzAlpZHNOjoX/IJy+KsF/XZGLkowRF0PmnulqRUylKi8QIVN w+edc X-Gm-Gg: AYBFou10Yf2eX21s6moYPhEtdwvBR2yjdeHnrKzJg6PR1hEHmZ55UipfMtyC3MDJZdW Ra7FNY4FbLnrXGewlhCSJIv71uI66+kpzAgfDYi30SlA0nR3kEzJNXnD2cQzW5KmqnTGic06wf2 NMBbqApgJteDevBaPjxKzy6+QxZw875rz0eF6gqrcW00v2P5uGNG7D2h6DiPA/j1IHcUugTBnjC YZhiOktNub34z6HyoGqDRhpJdhuqp4lqNkWu2SzG/5Bd11C8PK66ViPRMhAq/u9pIzqQa3fPuOP 7snUVzZI4vRQL3+YrEiz6bfm8Y/HzqXqromgTVyAstAkAcmoW1ecy+SZTE2Yy80fc/4yUDHHjxK 7/jkFzebZcj504JvZmE9yEPFco6OBBcB+pWWTiyygcsehaMryE6BSZAIhgr+BY0NwdnEw6UjOR8 lWBP8qhIhWHHSlSVCT9/XM0Ljf2FLP5XM5Znk/MQPSMQ45rPooXXwP+pbPSZO49BBSrEw= X-Received: by 2002:a05:6000:26d2:b0:482:c676:8d04 with SMTP id ffacd0b85a97d-48586083bf6mr1278729f8f.18.1788446597979; Thu, 03 Sep 2026 07:43:17 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 05/25] parallels: Limit search in parallels_mark_used to the last marked cluster Date: Thu, 3 Sep 2026 16:41:23 +0200 Message-ID: <20260903144143.2328870-6-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=den@openvz.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446768318158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev There is no necessity to search to the end of the bitmap. Limit the search area as cluster_index + count. Add cluster_end variable to avoid its calculation in a few places. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 6f7a9911d7..d537b0bb53 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -192,12 +192,14 @@ int parallels_mark_used(BlockDriverState *bs, unsigne= d long *bitmap, { BDRVParallelsState *s =3D bs->opaque; uint32_t cluster_index =3D host_cluster_index(s, off); + uint64_t cluster_end =3D (uint64_t)cluster_index + count; unsigned long next_used; - if ((uint64_t)cluster_index + count > bitmap_size) { + + if (cluster_end > bitmap_size) { return -E2BIG; } - next_used =3D find_next_bit(bitmap, bitmap_size, cluster_index); - if (next_used < (uint64_t)cluster_index + count) { + next_used =3D find_next_bit(bitmap, cluster_end, cluster_index); + if (next_used < cluster_end) { return -EBUSY; } bitmap_set(bitmap, cluster_index, count); --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446877; cv=none; d=zohomail.com; s=zohoarc; b=ijfNjcHq/JpW7HW9LkIurPatNBq69o3QGmyfYWv7PVDkBKO+H5en21wFMvvsKCW0BKlJDGS0reC5ijsjJaRXbnTba+T971BuDngFp5iXEhSY16wg7/COxt8sEWB7UvXNhaVDxEgVImK8TGMB38ZITtEV62eFs7SnMwrXK7Vr3yc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446877; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RXDsLBu8joIphrEfoyGx6K2aDXa33qspSB71iT/LF3I=; b=Twd9Che+iRHoc23BbWkxrigazOIT8yzhImx8qeeA6OaAfkz3ihirfh4M7P+YLWCwpo16fJZdCNeskZhlDtuKBtgx5Z922oFWSK0VfQaVB1+A81GQYrkVkyO6ome//8rwX1CEN5AWHKI+K+HTZpfXMsUmJ7FDtQI8LobQQ2Q8A7E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446877765686.6557558515443; Thu, 3 Sep 2026 07:47:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f7-0002lC-JP; Thu, 03 Sep 2026 10:43:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28ey-0002em-Tn for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:26 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28eu-00040C-RX for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:24 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-48442ea8f59so823791f8f.1 for ; Thu, 03 Sep 2026 07:43:20 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446599; x=1789051399; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=RXDsLBu8joIphrEfoyGx6K2aDXa33qspSB71iT/LF3I=; b=QKLfBxUuqIVklzGp5DLyLE+rxUG7xuRS1eEUpyPk/64xP21CEBA0cAn+GOErGOzyXB krLd2byjG6C8YCzTVMnN42RTYeUjJZyEIbQAkg9uUf6q6rQ2CR44AT4KMDr1A26X6+V9 oYdRI0euJeoJ8DAmVU2QS3JDNE3tuQN8/WPwZUK5zyJsr9b01GEgeFRdrlSVE8ssQsaE fhRtzBAHCJQv4OOwZFnygoaOFxuzhkam9zH50mBaRG3WLJqr9A+NJ5RlYX2phgfHjKYt SU8/0/CD9b6EWp5zNmjWj0hBDibH+H313sQMCD5Vju3VBBk6k3++UGg82l0fkcPUN49k tDCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446599; x=1789051399; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=RXDsLBu8joIphrEfoyGx6K2aDXa33qspSB71iT/LF3I=; b=aEFMg+LREZQMWot2YKmiWbhiF2uz5ZN7pwilnSljorEUpmZnjcaqeexEw20PZHi4AT lI8W+3NYbsJpyDtf2fZNbUkZDHqXZfPfMzsQOsc4WD+jD1O9nsC+nsqDQZ7IEVw6ZPPa jRPyUsLt7p+k0Hc1siJS4EfyKYCccOYpejf65JFbejhWSFQkF1n1mvDegx5QekZOrqLg hnJmrnJhVJMVfUyAs2UqqHKiS1p1P5UMP0bINCw8qATEUEcneFXIFsUs7e2v3H1cVZ/n vVJMYeoH238q3bwkjABEoSQXrC3L4iPL8kL/hy0FW+4lhBSUvBg1P+yYQEE3RdiSZF8U BXfw== X-Gm-Message-State: AFuF++mo56MjBErfr1vd3rl8jGhlkWEsDY9rx0R9TYQ+7+AYIPu8fLEC ES20dJed4EmEfGo3WZxzdnYwQOFf+GVQzWUKsuF4c3spxBKcd8K1w78ZjtXhUsm1NxpGz79F3ef E1g4k X-Gm-Gg: AYBFou15T8X9tgl6r0ZSDw/k+QjIfWZfLyA3jHOBAbfjLDGZgG2x//FAfr5+ZMyKQgo HX2E9KKZoTJDQX0Yw1+XBIT2dSyjBEKTJzDFv8skuCuBZYa4wP7kUbByMIRdmls857824x+JXmd 8KqiJKItmaiP8FpBMLuMbNnRS9OOfYcA1VHQHPnYAV3x5Qr9XCzuMFhVAyTJgpdGB2vSlf3q/dI PpdBekSMQbZM+/vyy7lJ2s0++e5NVmgC6w5vxCAEOlISfzmcU4sHshhXPIhMeV6u/6AJ4NToOME vB82JEH0tJFg2+3tyWVSFN6R6+ltCD8ByLHysAYuofjgqE54uBxekBnUCiSxt5ppd7PVtWlqPp7 0sc6CQpTmzc271sJFaUxJIqNl8YQBmHFXBVi75HnYKQSNhOqSOWNujNUWQ1pG4IfRpQ5RuX7jYe wGR2WZBj6L3mtHaKtsSvfu6Bx47qZTmTVlSfZALTjBdQ== X-Received: by 2002:a05:600c:a41a:b0:49c:f13d:ffe9 with SMTP id 5b1f17b1804b1-49cf13e05b7mr33534495e9.13.1788446599324; Thu, 03 Sep 2026 07:43:19 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 06/25] parallels: Move host clusters allocation to a separate function Date: Thu, 3 Sep 2026 16:41:24 +0200 Message-ID: <20260903144143.2328870-7-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=den@openvz.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446879245158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev For parallels images extensions we need to allocate host clusters without any connection to BAT. Move host clusters allocation code to parallels_allocate_host_clusters(). This function can be called not only from coroutines so all the *_co_* functions were replaced by corresponding wrappers. Add parallels_mark_unused(), the helper releasing an area in the used bitmap, as the new function needs it to undo an allocation. The size of the request and the size of the area preallocated for it live in two variables here, where the code being moved kept them in one. The used bitmap has to grow by the latter, as it is what tells the allocator how far the image reaches: counting only the requested clusters hides the preallocated tail, so the next allocation starts over at the end it knows about and preallocates the very same space again. data_end has to grow past an allocation which lands in the space preallocated by an earlier one as well, not only past one which appends to the image. The field marks the end of the payload for the truncation on inactivation, so an allocation which leaves it behind is cut off the image the moment the node is closed, and the data written into it is lost. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels.c | 145 +++++++++++------- block/parallels.h | 5 + tests/qemu-iotests/tests/parallels-checks | 34 ++++ tests/qemu-iotests/tests/parallels-checks.out | 17 ++ 4 files changed, 145 insertions(+), 56 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index d537b0bb53..c96bed5ed3 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -206,6 +206,25 @@ int parallels_mark_used(BlockDriverState *bs, unsigned= long *bitmap, return 0; } =20 +int parallels_mark_unused(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t coun= t) +{ + BDRVParallelsState *s =3D bs->opaque; + uint32_t cluster_index =3D host_cluster_index(s, off); + uint64_t cluster_end =3D (uint64_t)cluster_index + count; + unsigned long next_unused; + + if (cluster_end > bitmap_size) { + return -E2BIG; + } + next_unused =3D find_next_zero_bit(bitmap, cluster_end, cluster_index); + if (next_unused < cluster_end) { + return -EINVAL; + } + bitmap_clear(bitmap, cluster_index, count); + return 0; +} + /* * Collect used bitmap. The image can contain errors, we should fill the * bitmap anyway, as much as we can. This information will be used for @@ -260,42 +279,21 @@ static void parallels_free_used_bitmap(BlockDriverSta= te *bs) s->used_bmap =3D NULL; } =20 -static int64_t coroutine_fn GRAPH_RDLOCK -allocate_clusters(BlockDriverState *bs, int64_t sector_num, - int nb_sectors, int *pnum) +int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, + int64_t *clusters) { - int ret =3D 0; BDRVParallelsState *s =3D bs->opaque; - int64_t i, pos, idx, to_allocate, first_free, host_off; - - pos =3D block_status(s, sector_num, nb_sectors, pnum); - if (pos > 0) { - return pos; - } - - idx =3D sector_num / s->tracks; - to_allocate =3D DIV_ROUND_UP(sector_num + *pnum, s->tracks) - idx; - - /* - * This function is called only by parallels_co_writev(), which will n= ever - * pass a sector_num at or beyond the end of the image (because the bl= ock - * layer never passes such a sector_num to that function). Therefore, = idx - * is always below s->bat_size. - * block_status() will limit *pnum so that sector_num + *pnum will not - * exceed the image end. Therefore, idx + to_allocate cannot exceed - * s->bat_size. - * Note that s->bat_size is an unsigned int, therefore idx + to_alloca= te - * will always fit into a uint32_t. - */ - assert(idx < s->bat_size && idx + to_allocate <=3D s->bat_size); + int64_t first_free, next_used, host_off, prealloc_clusters; + int64_t bytes, prealloc_bytes; + uint32_t new_usedsize; + int ret =3D 0; =20 first_free =3D find_first_zero_bit(s->used_bmap, s->used_bmap_size); if (first_free =3D=3D s->used_bmap_size) { - uint32_t new_usedsize; - int64_t bytes =3D to_allocate * s->cluster_size; - bytes +=3D s->prealloc_size * BDRV_SECTOR_SIZE; - host_off =3D s->data_end * BDRV_SECTOR_SIZE; + prealloc_clusters =3D *clusters + s->prealloc_size / s->tracks; + bytes =3D *clusters * s->cluster_size; + prealloc_bytes =3D prealloc_clusters * s->cluster_size; =20 /* * We require the expanded size to read back as zero. If the @@ -303,33 +301,29 @@ allocate_clusters(BlockDriverState *bs, int64_t secto= r_num, * force the safer-but-slower fallocate. */ if (s->prealloc_mode =3D=3D PRL_PREALLOC_MODE_TRUNCATE) { - ret =3D bdrv_co_truncate(bs->file, host_off + bytes, - false, PREALLOC_MODE_OFF, - BDRV_REQ_ZERO_WRITE, NULL); + ret =3D bdrv_truncate(bs->file, host_off + prealloc_bytes, fal= se, + PREALLOC_MODE_OFF, BDRV_REQ_ZERO_WRITE, NU= LL); if (ret =3D=3D -ENOTSUP) { s->prealloc_mode =3D PRL_PREALLOC_MODE_FALLOCATE; } } if (s->prealloc_mode =3D=3D PRL_PREALLOC_MODE_FALLOCATE) { - ret =3D bdrv_co_pwrite_zeroes(bs->file, host_off, bytes, 0); + ret =3D bdrv_pwrite_zeroes(bs->file, host_off, prealloc_bytes,= 0); } if (ret < 0) { return ret; } =20 - new_usedsize =3D s->used_bmap_size + bytes / s->cluster_size; + new_usedsize =3D s->used_bmap_size + prealloc_bytes / s->cluster_s= ize; s->used_bmap =3D bitmap_zero_extend(s->used_bmap, s->used_bmap_siz= e, new_usedsize); s->used_bmap_size =3D new_usedsize; } else { - int64_t next_used; next_used =3D find_next_bit(s->used_bmap, s->used_bmap_size, first= _free); =20 /* Not enough continuous clusters in the middle, adjust the size */ - if (next_used - first_free < to_allocate) { - to_allocate =3D next_used - first_free; - *pnum =3D (idx + to_allocate) * s->tracks - sector_num; - } + *clusters =3D MIN(*clusters, next_used - first_free); + bytes =3D *clusters * s->cluster_size; =20 host_off =3D s->data_start * BDRV_SECTOR_SIZE; host_off +=3D first_free * s->cluster_size; @@ -341,14 +335,63 @@ allocate_clusters(BlockDriverState *bs, int64_t secto= r_num, */ if (s->prealloc_mode =3D=3D PRL_PREALLOC_MODE_FALLOCATE && host_off < s->data_end * BDRV_SECTOR_SIZE) { - ret =3D bdrv_co_pwrite_zeroes(bs->file, host_off, - s->cluster_size * to_allocate, 0); + ret =3D bdrv_pwrite_zeroes(bs->file, host_off, bytes, 0); if (ret < 0) { return ret; } } } =20 + if (host_off + bytes > s->data_end * BDRV_SECTOR_SIZE) { + s->data_end =3D (host_off + bytes) / BDRV_SECTOR_SIZE; + } + + ret =3D parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, + host_off, *clusters); + if (ret < 0) { + /* Image consistency is broken. Alarm! */ + return ret; + } + + return host_off; +} + +static int64_t coroutine_fn GRAPH_RDLOCK +allocate_clusters(BlockDriverState *bs, int64_t sector_num, + int nb_sectors, int *pnum) +{ + int ret =3D 0; + BDRVParallelsState *s =3D bs->opaque; + int64_t i, pos, idx, to_allocate, host_off; + + pos =3D block_status(s, sector_num, nb_sectors, pnum); + if (pos > 0) { + return pos; + } + + idx =3D sector_num / s->tracks; + to_allocate =3D DIV_ROUND_UP(sector_num + *pnum, s->tracks) - idx; + + /* + * This function is called only by parallels_co_writev(), which will n= ever + * pass a sector_num at or beyond the end of the image (because the bl= ock + * layer never passes such a sector_num to that function). Therefore, = idx + * is always below s->bat_size. + * block_status() will limit *pnum so that sector_num + *pnum will not + * exceed the image end. Therefore, idx + to_allocate cannot exceed + * s->bat_size. + * Note that s->bat_size is an unsigned int, therefore idx + to_alloca= te + * will always fit into a uint32_t. + */ + assert(idx < s->bat_size && idx + to_allocate <=3D s->bat_size); + + host_off =3D parallels_allocate_host_clusters(bs, &to_allocate); + if (host_off < 0) { + return host_off; + } + + *pnum =3D MIN(*pnum, (idx + to_allocate) * s->tracks - sector_num); + /* * Try to read from backing to fill empty clusters * FIXME: 1. previous write_zeroes may be redundant @@ -365,33 +408,23 @@ allocate_clusters(BlockDriverState *bs, int64_t secto= r_num, =20 ret =3D bdrv_co_pread(bs->backing, idx * s->tracks * BDRV_SECTOR_S= IZE, nb_cow_bytes, buf, 0); - if (ret < 0) { - qemu_vfree(buf); - return ret; + if (ret =3D=3D 0) { + ret =3D bdrv_co_pwrite(bs->file, host_off, nb_cow_bytes, buf, = 0); } =20 - ret =3D bdrv_co_pwrite(bs->file, s->data_end * BDRV_SECTOR_SIZE, - nb_cow_bytes, buf, 0); qemu_vfree(buf); if (ret < 0) { + parallels_mark_unused(bs, s->used_bmap, s->used_bmap_size, + host_off, to_allocate); return ret; } } =20 - ret =3D parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, - host_off, to_allocate); - if (ret < 0) { - /* Image consistency is broken. Alarm! */ - return ret; - } for (i =3D 0; i < to_allocate; i++) { parallels_set_bat_entry(s, idx + i, host_off / BDRV_SECTOR_SIZE / s->off_multiplier); host_off +=3D s->cluster_size; } - if (host_off > s->data_end * BDRV_SECTOR_SIZE) { - s->data_end =3D host_off / BDRV_SECTOR_SIZE; - } =20 return bat2sect(s, idx) + sector_num % s->tracks; } diff --git a/block/parallels.h b/block/parallels.h index 68077416b1..493c89e976 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -92,6 +92,11 @@ typedef struct BDRVParallelsState { =20 int parallels_mark_used(BlockDriverState *bs, unsigned long *bitmap, uint32_t bitmap_size, int64_t off, uint32_t count); +int parallels_mark_unused(BlockDriverState *bs, unsigned long *bitmap, + uint32_t bitmap_size, int64_t off, uint32_t coun= t); + +int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, + int64_t *clusters); =20 int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index d2a08049d9..99af4c5f52 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -301,6 +301,40 @@ echo "$(peek_file_le "$TEST_IMG" $VICTIM_OFFSET 4)" echo "=3D=3D data reads back correctly =3D=3D" { $QEMU_IO -r -c "read -P 0x88 0 $SMALL_CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 = | _filter_qemu_io | _filter_testdir =20 +# Clear image +_make_test_img $((64 * 1024 * 1024)) + +echo "=3D=3D TEST REUSE OF PREALLOCATED SPACE =3D=3D" + +echo "=3D=3D write 16 clusters, preallocating 16 of them at a time =3D=3D" +opts=3D(--image-opts "driver=3D$IMGFMT,file.filename=3D$TEST_IMG,prealloc-= size=3D16M") +for i in $(seq 0 15); do + opts+=3D(-c "write -P 0x11 $(($i * $CLUSTER_SIZE)) $CLUSTER_SIZE") +done +# Die before close(), which would truncate the preallocated tail away +opts+=3D(-c "sigraise $(kill -l KILL)") +orig_io_options=3D$QEMU_IO_OPTIONS +QEMU_IO_OPTIONS=3D$QEMU_IO_OPTIONS_NO_FMT +echo "clusters written: `$QEMU_IO "${opts[@]}" 2>&1 | grep -c '^wrote'`" +QEMU_IO_OPTIONS=3D$orig_io_options + +echo "=3D=3D the space preallocated first must have been handed out since = =3D=3D" +file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` +echo "clusters behind the header: $(($file_size / $CLUSTER_SIZE - 1))" + +# Clear image +_make_test_img $SIZE + +echo "=3D=3D the second cluster comes from the space preallocated for the = first =3D=3D" +{ $QEMU_IO -c "write -P 0x11 0 $CLUSTER_SIZE" \ + -c "write -P 0x22 $CLUSTER_SIZE $CLUSTER_SIZE" \ + "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir + +echo "=3D=3D both of them survive the close =3D=3D" +{ $QEMU_IO -r -c "read -P 0x11 0 $CLUSTER_SIZE" \ + -c "read -P 0x22 $CLUSTER_SIZE $CLUSTER_SIZE" \ + "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index c33f3852a8..51eb3f1ef1 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -182,4 +182,21 @@ wrote 512/512 bytes at offset 0 =3D=3D data reads back correctly =3D=3D read 512/512 bytes at offset 0 512 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D67108864 +=3D=3D TEST REUSE OF PREALLOCATED SPACE =3D=3D +=3D=3D write 16 clusters, preallocating 16 of them at a time =3D=3D +clusters written: 16 +=3D=3D the space preallocated first must have been handed out since =3D=3D +clusters behind the header: 17 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D the second cluster comes from the space preallocated for the first = =3D=3D +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D both of them survive the close =3D=3D +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) *** done --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446732; cv=none; d=zohomail.com; s=zohoarc; b=e8lDAe3GA+csahBHPGo4MPn114gl060fW5pOnbmp71tWt8Axx/ysuG6kSX1GHNYyiMz1dvpvRizUnkY3QYFcYeLPzDRkmomwhWf41KGPnykHY3NPEsmDED8Z73smoFZ0PRFw/9GjI+x0wQpejh4lELs1p5bSnJQr8GD/l5cGvfY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446732; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=MvawrBNstr38t9qdVqlJQ3pT802/IPUF8hZaymEalgQ=; b=Ot13S+qgHlH2q8DlyTtiNQmS2nyzxJFNKzt/XZfOacDhhMQG4nBs3aM2noGoG0+06B1spILXygpeupxJizsBdlYS+3x86bJNYhxnkElp4eDlkgvUWfK6DUz2vZ36x1H7p2h4fWcZ/Dkm/jeiEh7swSxAw0kgD0cAATOti2piFUQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446732313885.8925617051052; Thu, 3 Sep 2026 07:45:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fB-0002pg-5Q; Thu, 03 Sep 2026 10:43:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28ey-0002en-UD for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:26 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28ew-00040d-EL for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:24 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-49b8eeb3ff2so22543875e9.2 for ; Thu, 03 Sep 2026 07:43:21 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446600; x=1789051400; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=MvawrBNstr38t9qdVqlJQ3pT802/IPUF8hZaymEalgQ=; b=k6Ps9wE9x8/eNi16YNyyx3YPHs9LZxjXhUIzo23NoYOvOKvQsY0F2HcmxYhurWHOI8 qu7B1yjQw6r35Q9jMPOdkjeHvqOR7ZSYgthlVsCIthIPrsozVsYPoq2FcDDnKlFi13WQ IX823OxrDzDpN7cpXqLNyRR5n9mbvZLuR5Yrv2sz6Cp9OHwQMojShXoZ5gIWr384k7dA TJqZxWHxh/yc+e7NQKy/1NhtgTt/54rcUJq8pSKgt11//GzHgU4odgmr9YaaZjIibmjJ VPfqmBFx+0glpii1p1RjodmMd4+mCRSoF9rdGQkQxS22BrScdY/TFxbVYsDb8QcW2iar eUOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446600; x=1789051400; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=MvawrBNstr38t9qdVqlJQ3pT802/IPUF8hZaymEalgQ=; b=dRHB1fvHzGAGFrFBZ+s/CkFJnpi+4hKzWtfkExCSe7bdfauGDLOht/Vdzvr9Iv7JfO 1aOaaFnOyLRIQH7QK5aHVNic9rN8D+i8v30e3KyxGLNCIkmdiRvTIGNV5ebYh0YY7Y/7 8FdqeQMeNs4wg2+uZPhiFmAqwnuVbykrwZLKe9fHCoGY/FKKo1NxCtaaxDboJlxIKtM0 mwoZnqMYuEw+d/XXU2sBwxDCERw+xZnPUrkqnppv7iY+f/6dhd8Rnko97lqJKwNK3Ou7 5A3OHcinw8ByR1/yJyCVaZL0RZCS0po68EfS+t+Cra7LgkfwjZnWtodqAs5D0j3SvwMv TukQ== X-Gm-Message-State: AFuF++kMuJv+kknLzvPhp8v5s12naFTMzlQJrlTeyed8D4kZTXF1roVa Zw4nUd8K5DDBO9OED43vCB8JJVM4gktNdFHgy9cRbDd8tOg54+07A06qIbI22wfPGvBglwqFy5E fB//L X-Gm-Gg: AYBFou2eBoh5NOaTyD4MxS0S4PlpjAgdq68jGGH3zjz/fHg1F53mlZjSW582jLhHhhS wXfQ6BAarVZG8N11WOKTK7znPXy7U6ykZqCaeZV21riCbFncb34CYnT6O+6OslHL5hJCKtsWZlt tckZQS85eV1YmMU5uPY1sTg1lurqerwgqAD/SauEmic9ffDbgF6/pFgaCd7uBuG6EIxGV5lunmM wBXNstWjCS3q/UlyKAmkEHD4rJZ8M9qTo+uwYtEeAM7qDgwR5yQWDeCHoibA1/0Ok1DSC+IctOA y9io2l+UL1DZ8Wz4l/hHWgFJH6vFlAx2X+vToztk/5XStqWvUJ3FwRqfAmiCkdAK7IJWureTs3t k11edg0o1AjrDcHM73FKiZgkgRfPJx68LDXVt1ijIHAwOmd/jxNQMaFh/aHcuNhad8Z+p4EJ0GD gCYcEsGrDkGJEFI876OsMgHada9oLMiNbja55lWZo6oh/OduBGnpgfVBXV67J0cLBJ+2zk X-Received: by 2002:a05:600c:8b2c:b0:495:6e68:5df2 with SMTP id 5b1f17b1804b1-49ce5829cc9mr266427565e9.12.1788446600381; Thu, 03 Sep 2026 07:43:20 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 07/25] parallels: do not let the check die on what it is meant to report Date: Thu, 3 Sep 2026 16:41:25 +0200 Message-ID: <20260903144143.2328870-8-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=den@openvz.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446734211158501 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev parallels_check_duplicate() sizes its local bitmap by the end of the payload and asserts that every BAT entry fits into it. An entry pointing at a cluster which runs past the end of the image file does not fit, so a plain 'qemu-img check' on such an image dies: qemu-img: block/parallels.c:843: parallels_check_duplicate: Assertion `ret !=3D -E2BIG' failed. A repairing check survives by accident, as parallels_check_outside_image() clears the entry before the duplicate check gets to see it. There is nothing for the duplicate check to do with such a cluster anyway, as the corruption has already been reported, so skip it. The answer parallels_mark_used() gives has to stay out of ret, which is what the function returns once the loop is over. -EBUSY for the duplicate this function exists to find is left in ret whenever the last allocated BAT entry is the duplicated one and the check is not repairing. 'qemu-img check' then ends with ERROR duplicate offset in BAT entry 1 qemu-img: Check failed: Device or resource busy and prints no summary at all, so the corruption it just found is reported as a failure to look. Keep the answer in a variable of its own, as the only errors worth returning from here are the I/O ones, and those leave the loop where they happen. The tests write two clusters and damage the second entry, one by cutting the cluster in half so that it no longer fits the file, one by pointing it at the first cluster. Fixes: a398275e88 ("parallels: create mark_used() helper which sets bit in = used bitmap") Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels.c | 12 ++++--- tests/qemu-iotests/tests/parallels-checks | 33 ++++++++++++++++++ tests/qemu-iotests/tests/parallels-checks.out | 34 +++++++++++++++++++ 3 files changed, 74 insertions(+), 5 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index c96bed5ed3..cacf23143b 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -872,14 +872,16 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvC= heckResult *res, buf =3D qemu_blockalign(bs, s->cluster_size); =20 for (i =3D 0; i < s->bat_size; i++) { + int used; + host_off =3D bat2sect(s, i) << BDRV_SECTOR_BITS; if (host_off =3D=3D 0) { continue; } =20 - ret =3D parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); - assert(ret !=3D -E2BIG); - if (ret =3D=3D 0) { + used =3D parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); + if (used =3D=3D 0 || used =3D=3D -E2BIG) { + /* parallels_check_outside_image() reports the -E2BIG one */ continue; } =20 @@ -937,8 +939,8 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvChe= ckResult *res, * considered, and the bitmap size doesn't change. This specifical= ly * means that -E2BIG is OK. */ - ret =3D parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); - if (ret =3D=3D -EBUSY) { + used =3D parallels_mark_used(bs, bitmap, bitmap_size, host_off, 1); + if (used =3D=3D -EBUSY) { res->check_errors++; goto out_repair_bat; } diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index 99af4c5f52..cf90eaf152 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -335,6 +335,39 @@ echo "=3D=3D both of them survive the close =3D=3D" -c "read -P 0x22 $CLUSTER_SIZE $CLUSTER_SIZE" \ "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir =20 +# Clear image +_make_test_img $SIZE + +echo "=3D=3D TEST A CLUSTER WHICH RUNS PAST THE END OF THE FILE =3D=3D" + +echo "=3D=3D write two clusters =3D=3D" +{ $QEMU_IO -c "write -P 0x11 0 $CLUSTER_SIZE" \ + -c "write -P 0x22 $CLUSTER_SIZE $CLUSTER_SIZE" \ + "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir + +echo "=3D=3D cut the second one in half =3D=3D" +file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` +truncate -s $((file_size - CLUSTER_SIZE / 2)) "$TEST_IMG" + +echo "=3D=3D the check completes and reports the cluster =3D=3D" +_check_test_img + +# Clear image +_make_test_img $SIZE + +echo "=3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D" + +echo "=3D=3D write two clusters =3D=3D" +{ $QEMU_IO -c "write -P 0x11 0 $CLUSTER_SIZE" \ + -c "write -P 0x22 $CLUSTER_SIZE $CLUSTER_SIZE" \ + "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir + +echo "=3D=3D point the second entry at the first cluster =3D=3D" +poke_file "$TEST_IMG" "$(($BAT_OFFSET + 4))" "\x01\x00\x00\x00" + +echo "=3D=3D the check completes and reports the duplicate =3D=3D" +_check_test_img + # success, all done echo "*** done" rm -f $seq.full diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index 51eb3f1ef1..645c4b3679 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -199,4 +199,38 @@ read 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 1048576/1048576 bytes at offset 1048576 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D TEST A CLUSTER WHICH RUNS PAST THE END OF THE FILE =3D=3D +=3D=3D write two clusters =3D=3D +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D cut the second one in half =3D=3D +=3D=3D the check completes and reports the cluster =3D=3D +ERROR cluster 1 is outside image +ERROR space leaked at the end of the image 524288 + +1 errors were found on the image. +Data may be corrupted, or further writes to the image may corrupt it. + +1 leaked clusters were found on the image. +This means waste of disk space, but no harm to data. +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D +=3D=3D write two clusters =3D=3D +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D point the second entry at the first cluster =3D=3D +=3D=3D the check completes and reports the duplicate =3D=3D +ERROR space leaked at the end of the image 1048576 +ERROR duplicate offset in BAT entry 1 + +1 errors were found on the image. +Data may be corrupted, or further writes to the image may corrupt it. + +1 leaked clusters were found on the image. +This means waste of disk space, but no harm to data. *** done --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446639; cv=none; d=zohomail.com; s=zohoarc; b=ccoaun+ODdAxjD8KFhpiHStmWcJVD4bb0q/jioQW4dMH213oQM8t0xwOECOXg+0jWSwD8ypIMRNO3tcdIyO8S9n/gqakggdMugslNskbMBVNQD4A2RpqaG0d6CRG5WYP4RWEQcwFfD68dhLNIAW+qCHJZm4ttrmwyYQvxDiEp5c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446639; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=c9H56BOI6x1HNNI7/8WusEwmBUtaW++scE8GWB5zaTo=; b=Y5+cgMg5yzq2wNixVwcEljKU1NjanbgRteroVKkCvi13UYz2FEyOWVOS6FHOB+DJyNFZdQvV6SZmS/9zaVmbIU408Uo6sg/m4n1hCp18ZlsHG+XQOds0hlHyfujPvF0VmdN+Eu/ZPZSs9HBIYmwaLAm1i7dlwq9qMO3UXNDpNG4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446639705305.38101269412346; Thu, 3 Sep 2026 07:43:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f8-0002mZ-Oz; Thu, 03 Sep 2026 10:43:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f0-0002fc-QI for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:27 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28ew-00040v-W0 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:25 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-495437bb891so9079965e9.1 for ; Thu, 03 Sep 2026 07:43:22 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446601; x=1789051401; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=c9H56BOI6x1HNNI7/8WusEwmBUtaW++scE8GWB5zaTo=; b=aDZX0W6wl2CMlSZ9egE2TNeBvZSC2wMWEFgCUZ24HWwtPZq+hQMCFW4zbnlVy8a6dH BbfG5GggaM4vVzz70MdNFsrqYDFre5oPYe0PDMSm4snumT6HgI+D37RarR1f8B+YXPnS iyVFBDCQy4DYvWmAu2C3xoH+kXXevJEoTgbH2UvE3cU0Gn2YQy98uMynS3pomedBeSWN LJ94nzieyzV7L2e2sPEBR/VWb11RSAEVb+R3D9riBON5NX5GEqgLl/P6iBY3F4AkqkUS DcEvCYhxdIytQEmBigYozeWhxMlNdgPY/2QJ4jBKL0tEZdJF6Ne48p6XNhmLaauw2VmF pGsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446601; x=1789051401; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=c9H56BOI6x1HNNI7/8WusEwmBUtaW++scE8GWB5zaTo=; b=lSVNIP9GXGgdWb7uGusOIYBOaTmFdvksa3XG0jlj/TGvJQw8e+Lj9oBbaljiKM4nEC mn/jk6zXutlON1iZR2upoJROQsMOhTkvLL4RDXaXD8YuWa4vZ6MNiUqFz4cWcBKDg1Op 4KSENSOo6yVDSEK83XgXb5Lt/Ss967Ao+9NYyGsSiH8ZvC0HiNHIvIfKTlXtkgHrJmG5 kAn/kKDW6ZDnsC641mtfD8hbOgzb/erk6zZ8uJPYczCWgpne27lgHUypt2aRA+A+RDe+ tk1hwqJmlV8R+CxJUPVVgYr+unOqq+LXPf9rY0tUUdI9QJh8v2WWqY/R79wgHJDtVbk4 zmEQ== X-Gm-Message-State: AFuF++lFdvpRFL3+NjDwEbb8XwBqeY4bv1dz4WsuIXNzg1xBUEG7OtqI pWeZ8+D5WuEmASRkOGF2k8e7y+e8vVCHirIX56bWDbj2NrZXUzVyF32pov/OUD8tfgId6QHoDXs DIsqG X-Gm-Gg: AYBFou0dQkxn7ATMeETae5B4YXSVacE2ZeCvcEXLWkouFpH8BtRkHzk+xZVKfYYzdXw MYDW0TFujBR+qmsS3mGRGO4jFXwdsJ4dtQWVAcFtH+nnWFmSbeSIADVePpyjkU+eRPSVEMe+rNU WoqkeUz1MI9qAzoA66bAK0NYC0UIVVUWQIe0M6uwqIkkhza2S18rYWdUZX6PpSyfm9dQYA9NKts R/bxWitymyf4r9DgrAsB4BxCM2zQlWBQhP+XrgMmM7x5y6+/H8oakZgUQUIR+RwmCxvFz6jWtGP 6ESkJWI71JNZYlAf9TFjSx6bVnVspdJt9aP+BGZZKu7XfB/IDhHlM9Ntt3noNj8MoGQOMm6D1b/ Qx0ba9AjPSOxL3zvnRhTLN/Nv2y6yrsLCP+LBhYtPzfucI1inOn3gS26WvPu0FdNFybN5IJG/06 hKkALjtT1XK0R9OiMxqBPI7T7fpNQGV9xjyd2huXa7ORd9QXPZUkEL7Qww X-Received: by 2002:a05:600c:4255:b0:49c:f13d:ffee with SMTP id 5b1f17b1804b1-49cf13e05f4mr29385085e9.18.1788446601570; Thu, 03 Sep 2026 07:43:21 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v7 08/25] parallels: Create used bitmap even if checks needed Date: Thu, 3 Sep 2026 16:41:26 +0200 Message-ID: <20260903144143.2328870-9-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=den@openvz.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446641621158500 Content-Type: text/plain; charset="utf-8" From: Alexander Ivanov All the checks were fixed to work with used bitmap. Create used bitmap in parallels_open() even if need_check is true. Cc: Stefan Hajnoczi Signed-off-by: Alexander Ivanov Signed-off-by: Denis V. Lunev --- block/parallels.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index cacf23143b..307e90ec71 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1476,13 +1476,11 @@ static int parallels_open(BlockDriverState *bs, QDi= ct *options, int flags, } } =20 - if (!need_check) { - ret =3D parallels_fill_used_bitmap(bs); - if (ret =3D=3D -ENOMEM) { - goto fail; - } - need_check =3D need_check || ret < 0; /* These are correctable err= ors */ + ret =3D parallels_fill_used_bitmap(bs); + if (ret =3D=3D -ENOMEM) { + goto fail; } + need_check =3D need_check || ret < 0; /* These are correctable errors = */ =20 /* * We don't repair the image here if it's opened for checks. Also we d= on't --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446638; cv=none; d=zohomail.com; s=zohoarc; b=bBKOeMsInppieLc8pQ5icFk4evPnQXu2BpsiHYcSmR8P+RATqyL3rztFSn5H/t0AVENW9a0Ydqs5wDuR9jH0TqJIi85yrIRl6M7LqvNRy6phMN4DZkEgsaFpAnYoRy08KrIGn8vMCm67Fnf9dxU/1/rDyvuHXlGP7t8ScOztYG8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446638; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=sLKHeTr+qaxkryYy6sSzyAc/KU6ezMFM//A19UpNHH4=; b=ZfNJJWpzfG/HQUoQ2pJaWikMIPOpdLwrJguE77DfVYKUgIlBnhI7NKkBy63PmsO3btgqIA2h9jscnzDMFo4AC8hhR1YPUHdTNvq+MP1WrvFYflue9DvPvl28DxL1QDbqwEfHupyZTaKbRuAg2g7eY/qOxeF43QGwmXRekNWhIAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446638609295.26553322351253; Thu, 3 Sep 2026 07:43:58 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f4-0002gF-EW; Thu, 03 Sep 2026 10:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f0-0002fe-VK for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:27 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28ey-00041Q-LK for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:26 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-47ddf7b09e5so2349560f8f.1 for ; Thu, 03 Sep 2026 07:43:23 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446603; x=1789051403; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sLKHeTr+qaxkryYy6sSzyAc/KU6ezMFM//A19UpNHH4=; b=Fwf1ZXGORpaxhJblIL3E/HxU3gdh01mUryWIjgSow6CNNvsqW2MHFISgsTvSdV6veD ePVyju28uH9CWLBVVKZxQrsPP0ep0ouxi/wvHtSNrmsa9V7CjltgPhd3IA66TlausB1Q 7TfbfNZiipOfjmrfSohVGX1v6ePtvgqeNH0XshvKnKIR7WclhMCIzK6e9yHL6OEwj3dp fAKTKLXnErxEwAsCtiI2tgCVvl3ut+z2BF8KlwJ70K/6jkSprJ/QuggzIXNSF5wW42fk pI17QrpffJglUkX0zTJaG4NIsbycFzfQlAAYC7bxm6i9Lc6ZNvutHG9Q6xxh7VFn9hrr +chQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446603; x=1789051403; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sLKHeTr+qaxkryYy6sSzyAc/KU6ezMFM//A19UpNHH4=; b=jyKE2F8hvPjBFvMSTCA9FOpHkZLZSLa/XS/Pzs4hNN9asUuWmZcZlcH62gPfhtgs// t3a97Z5fLaOPA9A6pmoS99pN07atpT48HlarMyYiTj9+o4lxQbt29EIZCmdNL5WYhs1T cJE7HCXeUZ7B5lJKIuWMbLjhj/34cUR01SQzlgAvGbDtN6CuWMmSkrNFlPOysSuHWQuF 0ksBiy8yY1zdODbTD0VAFJMzf6/FOmBQkv17yU3ffAEW0zpBLMr72KdHTL0BXqiYrkE4 yuNCiMHvLXo5ZGpD4H3vnHedkQzCPNKZOJk824/svk8ZwZihw0UQfkK8kqFQORBrYhE7 0Nog== X-Gm-Message-State: AFuF++nVYB5aUcxUAmvugUVqk+R87l/2KN0B5j04Nym1qbJmFNoWeW2+ Uq1hB5jkc/dZXmxUf9IRpImM/sUwKI52QL8zFd2bobgnsqKoE+453+5HDBytRpvl5YoDzDglXgc FIAtk X-Gm-Gg: AYBFou2EBFIEZb1JW5qZSc+EgP1GfN7ItFa315lhzNP9PS0SZopTGTlm254iLV8XZFb DThAJU1ETiDZPD1ke6ICbaIFuThP2jx2fHEG9nOtcHDafm6JjqEcl8ZZrCe5fm4nD8+uRoCr3bd t49txUQo+X2AJ7WV2C6h93M5xUEYMCfmOo9VIOgqNw+zi6Wpkfu8mJOeqHtp/bHI/PVgx/09sV3 B9SJ1Qp0DfLoIuFFhUudmX2u+u8DYjbz0TuS8FvPir1oYekJzr1GZ4XWpL+86LuMMoeKCgZN6tq zKKqvbCo3ClnwKT4C36xSKeL+eqtne8RQABtbgnbfVZ5CZCNkEkMO0xDI50hpiIEUFxJwv2+ez5 rJsakoCCkMTIvREJcAtf+n9ymEGQslLPc+PhTQbmTdGxLaoPVgtKxPSnkCfeZlLRtJVYv0Hq4ay V0fpWtJG+0iJi1KEjcwh473CTtw8j4uFvTVNmqhFmdF2L8mSJZl+ezk0PA X-Received: by 2002:adf:f24f:0:b0:485:7c48:a899 with SMTP id ffacd0b85a97d-4858606d916mr1278836f8f.13.1788446602579; Thu, 03 Sep 2026 07:43:22 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 09/25] parallels: Drop unused clusters at the end of the image Date: Thu, 3 Sep 2026 16:41:27 +0200 Message-ID: <20260903144143.2328870-10-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=den@openvz.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446639469158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev On an image closing there can be unused clusters in the end of the image. Since we have used bitmap, they can be found without a leak check, so parallels_check_unused_clusters() answers both questions: inactivation asks it to truncate them away, and the leak check asks it how much there is. A repairing leak check truncates the file, so the used bitmap is recreated afterwards, as it would no longer comply to it. The helper answers with the size of the leak, which is a byte count and does not belong in an int. parallels_inactivate() keeps it in an int64_t and reports only a failure, as a leak of 2 GiB or more would otherwise look like one and fail the inactivation of an image which was truncated just fine. A BAT entry pointing at a cluster which does not fit the file makes the used bitmap reach further than the file does, and that difference is not a leak of negative size. parallels_check_outside_image() reports it as corruption on its own, so answer with no leak at all rather than -EINVAL, which would fail the whole check before the duplicate check and the statistics ever run. Repairing such an entry clears it from the BAT, and the used bitmap has to follow the way parallels_check_data_off() already makes it follow a repaired data_off. Otherwise it keeps a bit for a cluster the image no longer has, and 'qemu-img check -r all' leaves the space behind it untouched instead of truncating it away. Rebuilding the used bitmap after the truncation fails with -EBUSY or -E2BIG on a BAT which points a cluster twice or out of the image. parallels_open() calls those correctable and repairs them, so they must not abort the check that is meant to do the repairing. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels.c | 131 +++++++++++++----- tests/qemu-iotests/tests/parallels-checks | 11 ++ tests/qemu-iotests/tests/parallels-checks.out | 22 ++- 3 files changed, 126 insertions(+), 38 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 307e90ec71..2be7c20338 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -750,6 +750,7 @@ parallels_check_outside_image(BlockDriverState *bs, Bdr= vCheckResult *res, BDRVParallelsState *s =3D bs->opaque; uint32_t i; int64_t off, high_off, size, data_start_off; + bool fixed =3D false; =20 size =3D bdrv_co_getlength(bs->file->bs); if (size < 0) { @@ -771,6 +772,7 @@ parallels_check_outside_image(BlockDriverState *bs, Bdr= vCheckResult *res, if (fix & BDRV_FIX_ERRORS) { parallels_set_bat_entry(s, i, 0); res->corruptions_fixed++; + fixed =3D true; } continue; } @@ -779,6 +781,17 @@ parallels_check_outside_image(BlockDriverState *bs, Bd= rvCheckResult *res, } } =20 + if (fixed) { + int err; + + parallels_free_used_bitmap(bs); + err =3D parallels_fill_used_bitmap(bs); + if (err =3D=3D -ENOMEM) { + res->check_errors++; + return err; + } + } + if (high_off =3D=3D 0) { res->image_end_offset =3D s->data_end << BDRV_SECTOR_BITS; } else { @@ -786,51 +799,96 @@ parallels_check_outside_image(BlockDriverState *bs, B= drvCheckResult *res, s->data_end =3D res->image_end_offset >> BDRV_SECTOR_BITS; } =20 + return 0; } =20 +static int64_t GRAPH_RDLOCK +parallels_check_unused_clusters(BlockDriverState *bs, bool truncate) +{ + BDRVParallelsState *s =3D bs->opaque; + int64_t leak, file_size, end_off =3D 0; + int ret; + + file_size =3D bdrv_getlength(bs->file->bs); + if (file_size < 0) { + return file_size; + } + + if (s->used_bmap_size > 0) { + end_off =3D find_last_bit(s->used_bmap, s->used_bmap_size); + if (end_off =3D=3D s->used_bmap_size) { + end_off =3D 0; + } else { + end_off =3D (end_off + 1) * s->cluster_size; + } + } + + end_off +=3D s->data_start * BDRV_SECTOR_SIZE; + + /* + * A cluster in use behind the end of the file is corruption which + * parallels_check_outside_image() reports on its own. There is no + * leaked space to reclaim behind it, and nothing to truncate. + */ + if (end_off >=3D file_size) { + return 0; + } + + leak =3D file_size - end_off; + if (!truncate) { + return leak; + } + + ret =3D bdrv_truncate(bs->file, end_off, true, PREALLOC_MODE_OFF, 0, N= ULL); + if (ret) { + return ret; + } + + parallels_free_used_bitmap(bs); + ret =3D parallels_fill_used_bitmap(bs); + if (ret =3D=3D -ENOMEM) { + return ret; + } + + return leak; +} + static int coroutine_fn GRAPH_RDLOCK parallels_check_leak(BlockDriverState *bs, BdrvCheckResult *res, BdrvCheckMode fix, bool explicit) { BDRVParallelsState *s =3D bs->opaque; - int64_t size; - int ret; + int64_t leak, count, size; + + leak =3D parallels_check_unused_clusters(bs, fix & BDRV_FIX_LEAKS); + if (leak < 0) { + res->check_errors++; + return leak; + } + if (leak =3D=3D 0) { + return 0; + } =20 size =3D bdrv_co_getlength(bs->file->bs); if (size < 0) { res->check_errors++; return size; } + res->image_end_offset =3D size; =20 - if (size > res->image_end_offset) { - int64_t count; - count =3D DIV_ROUND_UP(size - res->image_end_offset, s->cluster_si= ze); - if (explicit) { - fprintf(stderr, - "%s space leaked at the end of the image %" PRId64 "\n= ", - fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", - size - res->image_end_offset); - res->leaks +=3D count; - } - if (fix & BDRV_FIX_LEAKS) { - Error *local_err =3D NULL; + if (!explicit) { + return 0; + } =20 - /* - * In order to really repair the image, we must shrink it. - * That means we have to pass exact=3Dtrue. - */ - ret =3D bdrv_co_truncate(bs->file, res->image_end_offset, true, - PREALLOC_MODE_OFF, 0, &local_err); - if (ret < 0) { - error_report_err(local_err); - res->check_errors++; - return ret; - } - if (explicit) { - res->leaks_fixed +=3D count; - } - } + count =3D DIV_ROUND_UP(leak, s->cluster_size); + fprintf(stderr, + "%s space leaked at the end of the image %" PRId64 "\n", + fix & BDRV_FIX_LEAKS ? "Repairing" : "ERROR", leak); + res->leaks +=3D count; + + if (fix & BDRV_FIX_LEAKS) { + res->leaks_fixed +=3D count; } =20 return 0; @@ -849,7 +907,10 @@ parallels_check_duplicate(BlockDriverState *bs, BdrvCh= eckResult *res, bool fixed =3D false; =20 /* - * Create a bitmap of used clusters. + * Create a bitmap of used clusters. Please note that this bitmap is n= ot + * related to used_bmap field in BDRVParallelsState and is created onl= y for + * local usage. + * * If a bit is set, there is a BAT entry pointing to this cluster. * Loop through the BAT entries, check bits relevant to an entry offse= t. * If bit is set, this entry is duplicated. Otherwise set the bit. @@ -1521,16 +1582,16 @@ fail: static int GRAPH_RDLOCK parallels_inactivate(BlockDriverState *bs) { BDRVParallelsState *s =3D bs->opaque; - int ret; + int64_t leak; =20 if (!(bs->open_flags & BDRV_O_RDWR) || (bs->open_flags & BDRV_O_INACTI= VE)) { return 0; } =20 - ret =3D bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, true, - PREALLOC_MODE_OFF, 0, NULL); - if (ret < 0) { - return ret; + leak =3D parallels_check_unused_clusters(bs, true); + if (leak < 0) { + error_report("Failed to truncate image: %s", strerror(-leak)); + return leak; } =20 s->header->inuse =3D 0; diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index cf90eaf152..c9dcd715ac 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -352,6 +352,17 @@ truncate -s $((file_size - CLUSTER_SIZE / 2)) "$TEST_I= MG" echo "=3D=3D the check completes and reports the cluster =3D=3D" _check_test_img =20 +echo "=3D=3D nothing can be reclaimed behind it =3D=3D" +_check_test_img -r leaks +echo "file size: `stat --printf=3D"%s" "$TEST_IMG"`" + +echo "=3D=3D a full repair drops the entry and truncates the image =3D=3D" +_check_test_img -r all +echo "file size: `stat --printf=3D"%s" "$TEST_IMG"`" + +echo "=3D=3D the first cluster survived =3D=3D" +{ $QEMU_IO -c "read -P 0x11 0 $CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 | _filter= _qemu_io | _filter_testdir + # Clear image _make_test_img $SIZE =20 diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index 645c4b3679..6699848996 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -209,13 +209,29 @@ wrote 1048576/1048576 bytes at offset 1048576 =3D=3D cut the second one in half =3D=3D =3D=3D the check completes and reports the cluster =3D=3D ERROR cluster 1 is outside image -ERROR space leaked at the end of the image 524288 =20 1 errors were found on the image. Data may be corrupted, or further writes to the image may corrupt it. +=3D=3D nothing can be reclaimed behind it =3D=3D +ERROR cluster 1 is outside image =20 -1 leaked clusters were found on the image. -This means waste of disk space, but no harm to data. +1 errors were found on the image. +Data may be corrupted, or further writes to the image may corrupt it. +file size: 2621440 +=3D=3D a full repair drops the entry and truncates the image =3D=3D +Repairing cluster 1 is outside image +Repairing space leaked at the end of the image 524288 +The following inconsistencies were found and repaired: + + 1 leaked clusters + 1 corruptions + +Double checking the fixed image now... +No errors were found on the image. +file size: 2097152 +=3D=3D the first cluster survived =3D=3D +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 =3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D =3D=3D write two clusters =3D=3D --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446681; cv=none; d=zohomail.com; s=zohoarc; b=JexZYJHvf8S2agVyao1dPhZ+P0lkDomFTIMvmyZ/VNvHWjQOrUlVaOa0BbNDlYLFEoRgQo4QMT8cKpztg8bh5ZLVVqnvgQ8R1078GesGeS/voLCSqSCNXyV6VsSnDsBXs8HKoBPb4tRVweJWch5tyCThNmtE+Sxt1vvkYtW4nck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446681; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=kJQhdOKNjR/0ShebFeeadPAu9Q3JSbfvQxQRJTWAOqo=; b=cKXlbk3qhBkz8c0/onkbH2bGYj8WeqCMpzYvEiDPfDnqaBE6bgw/L9NDHkttYwMByeouZwYWnzMQ5aRCSXJIh9Cu4tVNfmJ9WGSzgnqWmbVpVBOqhkk3CUjCmanjYzWGkTGlI5c0nJ9myPmjNPurUlfAFx8b/zHAc1TDkTLilSg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446680973240.5923393370258; Thu, 3 Sep 2026 07:44:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fG-0002vI-3i; Thu, 03 Sep 2026 10:43:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f2-0002gD-MJ for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:29 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f0-00041h-GM for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:28 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-49b8f86c6deso15924995e9.0 for ; Thu, 03 Sep 2026 07:43:25 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446604; x=1789051404; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=kJQhdOKNjR/0ShebFeeadPAu9Q3JSbfvQxQRJTWAOqo=; b=RZg/FO9p2Cq249A9pCcubu9RHvESgXksOVRXuzVOs2ZVo9zndOaYzvj7zJlPIde9/F S6d8sLoZCalTgUZwlpORF47lb1RsajPqk+h3C33czTZIZg8wf69V2hOx1YnuPwyWgILD QfA50Rba0jB1HLz8AcRRzQlg52KFuIOWiQyhLkVSoCu18HPMg8HMqdGwcneyQ2Rqxo6t 2mPXkAuta/lZWniFxHU7oRZxFmX7eIkPRSGLMfonxum9JaGlPyBCAkK1F9jYO8S1qTCx tbNi1W0CaCQ4v2Vjn6SrUOrLVdl+cDW9bKheTDnZbUzkosO7NCFlI3Td3eFchICs2vrI EDvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446604; x=1789051404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=kJQhdOKNjR/0ShebFeeadPAu9Q3JSbfvQxQRJTWAOqo=; b=HxZNEAEhMHu91WF4Mkb4FWxTV+fZZXhG+y13nj3o/paCpwCiaHPPak+3AJ2SzT7dg1 bDuTrYbgev0b342p3btp1VAEBH1S/j0RiauUiW2x3sOVOySH9b53Yu73vfOFpHIhSg6G 0Tlko9lGBD1+Pb8ZJIbW6teoLYAPT0MVEv1Tis3FJu0YE1ewtwM0I/Xva8D6BXWWT1G8 91Hy6lAADeglYbOKt7ieK4HmJ4OgU7CJsqWHOO9Ylr2wY8fUInWW0ehIG+BZfqR2DECT VwSQIowXmbCfHmpNTY6nkzBrxCqnrsQRBSBTMoTMruYjhLBRNbzRyfM3pLsrOeTEaHrn lsQg== X-Gm-Message-State: AFuF++n+lvEgKOyMbq2mI4Dx7EBYu+X3On//oIvIT5SlM4277eKhDhTs fO56pnG2YlRwExdUQieabKg5j3FBwGCx0zSjucmhZ3Vm9di0qtoAf5EvjKHlXv9SENYG8wlx2em sxh81 X-Gm-Gg: AYBFou1R6ZlNXZ/GOhqlgygCt28xkmL3HQQnkBPgvrDcsXnZ/4W6VdGH9BV4z4+hzzX eP5GR0bsbARlvbCClawzYR16yiz98UtCKdO1PiPCojwK28gaUS0H+HN7rgs0wz6CIpUxuPXHIv4 HXjg762KqcXEDKZPOjssFGb6zROmakJWuszWwBXuYaHu7evQB/PXHfZE5iY/G7FI6cZBTbbdM+E ujjEdDU8u+gMw3zuGm8p0CG9QRiePxxtAmSgiw/3N3cRfFOXY5Sbc+RXsg1MqiOropDiSvzNVlQ 657n0Eo6mTlvCfqV997S6EepZyRfjwGHdbzxCScYKz8mZSJRjd6lL2xOD0YGN27J8VdJRkYBJhk hjPi/uaNBk0jq1sblzcijmNfxiJW5WyIY59bL+WCcQE/NCE0TMEyu07WHVPvifUNzNsJIVS81/1 sLRPUHspKmohO6DjI+DeuhwcM/g2qx7/EIb+kvhJ8YpC4qR8S5Tc9T/spB X-Received: by 2002:a05:600c:4592:b0:496:c1f3:e8f8 with SMTP id 5b1f17b1804b1-49ce5828104mr209531355e9.7.1788446603652; Thu, 03 Sep 2026 07:43:23 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 10/25] parallels: Remove unnecessary data_end field Date: Thu, 3 Sep 2026 16:41:28 +0200 Message-ID: <20260903144143.2328870-11-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=den@openvz.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446681622158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Since we have used bitmap, field data_end in BDRVParallelsState is redundant and can be removed. Add parallels_data_end() helper and remove data_end handling. The two are not equivalent, which is why this comes before the Format Extension is stored. data_end is the highest extent seen in the BAT, while the helper derives the end of the payload from the image file. A cluster which belongs to the image without being referenced by the BAT, as the Format Extension and its bitmap data clusters are, stays invisible to the field: parallels_allocate_host_clusters() appends at data_end, so it would hand out an offset which is already occupied and parallels_mark_used() would refuse it with -EBUSY, failing the guest write. seek_to_sector() validates a BAT entry against data_end, so it becomes a user of the new helper, which suits that check better as well: a cluster has to live inside the image file, while the field could grow to whatever extent a corrupted BAT entry claimed. The BAT scan in parallels_open() no longer tracks the maximum extent, but it keeps rejecting entries below data_start or beyond the end of the file, so need_check is still set when an entry is out of bounds. Nothing is accumulated any more, so the scan stops at the first such entry. high_off in parallels_check_outside_image() only fed the image_end_offset which the helper now provides, so it goes away with the field. The bdrv_pwrite_zeroes() of the branch which reuses a hole goes as well. It was guarded by data_end, and it is redundant: the space was already fallocated when the image grew over it. The 'bytes' variable goes with it, as the used bitmap grows by the preallocated size rather than the requested one. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels.c | 57 +++++++++++++---------------------------------- block/parallels.h | 1 - 2 files changed, 15 insertions(+), 43 deletions(-) diff --git a/block/parallels.c b/block/parallels.c index 2be7c20338..ace79ad968 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -116,6 +116,13 @@ static uint32_t bat_entry_off(uint32_t idx) return sizeof(ParallelsHeader) + sizeof(uint32_t) * idx; } =20 +static int64_t parallels_data_end(BDRVParallelsState *s) +{ + int64_t data_end =3D s->data_start * BDRV_SECTOR_SIZE; + data_end +=3D s->used_bmap_size * s->cluster_size; + return data_end; +} + static int64_t seek_to_sector(BDRVParallelsState *s, int64_t sector_num) { uint32_t index, offset; @@ -130,7 +137,8 @@ static int64_t seek_to_sector(BDRVParallelsState *s, in= t64_t sector_num) } =20 cluster_off =3D bat2sect(s, index); - if (cluster_off < s->data_start || cluster_off + s->tracks > s->data_e= nd) { + if (cluster_off < s->data_start || + cluster_off + s->tracks > parallels_data_end(s) >> BDRV_SECTOR_BIT= S) { /* Cluster is outside of the image file or overlaps the header. */ return -1; } @@ -284,15 +292,14 @@ int64_t GRAPH_RDLOCK parallels_allocate_host_clusters= (BlockDriverState *bs, { BDRVParallelsState *s =3D bs->opaque; int64_t first_free, next_used, host_off, prealloc_clusters; - int64_t bytes, prealloc_bytes; + int64_t prealloc_bytes; uint32_t new_usedsize; int ret =3D 0; =20 first_free =3D find_first_zero_bit(s->used_bmap, s->used_bmap_size); if (first_free =3D=3D s->used_bmap_size) { - host_off =3D s->data_end * BDRV_SECTOR_SIZE; + host_off =3D parallels_data_end(s); prealloc_clusters =3D *clusters + s->prealloc_size / s->tracks; - bytes =3D *clusters * s->cluster_size; prealloc_bytes =3D prealloc_clusters * s->cluster_size; =20 /* @@ -323,27 +330,9 @@ int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(= BlockDriverState *bs, =20 /* Not enough continuous clusters in the middle, adjust the size */ *clusters =3D MIN(*clusters, next_used - first_free); - bytes =3D *clusters * s->cluster_size; =20 host_off =3D s->data_start * BDRV_SECTOR_SIZE; host_off +=3D first_free * s->cluster_size; - - /* - * No need to preallocate if we are using tail area from the above - * branch. In the other case we are likely re-using hole. Prealloc= ate - * the space if required by the prealloc_mode. - */ - if (s->prealloc_mode =3D=3D PRL_PREALLOC_MODE_FALLOCATE && - host_off < s->data_end * BDRV_SECTOR_SIZE) { - ret =3D bdrv_pwrite_zeroes(bs->file, host_off, bytes, 0); - if (ret < 0) { - return ret; - } - } - } - - if (host_off + bytes > s->data_end * BDRV_SECTOR_SIZE) { - s->data_end =3D (host_off + bytes) / BDRV_SECTOR_SIZE; } =20 ret =3D parallels_mark_used(bs, s->used_bmap, s->used_bmap_size, @@ -749,7 +738,7 @@ parallels_check_outside_image(BlockDriverState *bs, Bdr= vCheckResult *res, { BDRVParallelsState *s =3D bs->opaque; uint32_t i; - int64_t off, high_off, size, data_start_off; + int64_t off, size, data_start_off; bool fixed =3D false; =20 size =3D bdrv_co_getlength(bs->file->bs); @@ -759,7 +748,6 @@ parallels_check_outside_image(BlockDriverState *bs, Bdr= vCheckResult *res, } data_start_off =3D s->data_start << BDRV_SECTOR_BITS; =20 - high_off =3D 0; for (i =3D 0; i < s->bat_size; i++) { off =3D bat2sect(s, i) << BDRV_SECTOR_BITS; if (off =3D=3D 0) { @@ -774,10 +762,6 @@ parallels_check_outside_image(BlockDriverState *bs, Bd= rvCheckResult *res, res->corruptions_fixed++; fixed =3D true; } - continue; - } - if (high_off < off) { - high_off =3D off; } } =20 @@ -792,14 +776,7 @@ parallels_check_outside_image(BlockDriverState *bs, Bd= rvCheckResult *res, } } =20 - if (high_off =3D=3D 0) { - res->image_end_offset =3D s->data_end << BDRV_SECTOR_BITS; - } else { - res->image_end_offset =3D high_off + s->cluster_size; - s->data_end =3D res->image_end_offset >> BDRV_SECTOR_BITS; - } - - + res->image_end_offset =3D parallels_data_end(s); return 0; } =20 @@ -1466,8 +1443,7 @@ static int parallels_open(BlockDriverState *bs, QDict= *options, int flags, } =20 s->data_start =3D data_start; - s->data_end =3D s->data_start; - if (s->data_end < (s->header_size >> BDRV_SECTOR_BITS)) { + if (s->data_start < (s->header_size >> BDRV_SECTOR_BITS)) { /* * There is not enough unused space to fit to block align between = BAT * and actual data. We can't avoid read-modify-write... @@ -1530,10 +1506,7 @@ static int parallels_open(BlockDriverState *bs, QDic= t *options, int flags, if (sector < data_start || sector + s->tracks > file_nb_sectors) { /* Cluster is outside of the image file or overlaps the header= . */ need_check =3D true; - continue; - } - if (sector + s->tracks > s->data_end) { - s->data_end =3D sector + s->tracks; + break; } } =20 diff --git a/block/parallels.h b/block/parallels.h index 493c89e976..eb90aeea81 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -79,7 +79,6 @@ typedef struct BDRVParallelsState { unsigned int bat_size; =20 int64_t data_start; - int64_t data_end; uint64_t prealloc_size; ParallelsPreallocMode prealloc_mode; =20 --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446708; cv=none; d=zohomail.com; s=zohoarc; b=LD5g5HACkXVLzArX8kfdeIqOBwr/6ICVF2i35Xujp8DRdhzrUzydVTOCg1DcI9djrZsImofahJPlLAQbdNp+lvw7Etv/bSK6r3cAQUH0OCinecrgh1q61lqjM9YeglDLtbLTaMete5j3CDz7XSGwL94lzLeRzDt4ulzLbf8m9Q4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446708; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Cf1yI1aREIxDxkefBceSwViRa1AdWX44R35eLRi8QFs=; b=bVWDGoRwnm/QMIirffKKWH0i4OQGXNJA/9h88T0ZUPsA/jfgRBf7bI//jk/UQSXLEZqUXthkO5fGBm2edk+ySBCdzRnvTRzxugkbMin49O5oUINyBJyqRE6g5ImRSLrK/nRcu7bOSKre6SIndtfc2kUeIeOmuILNO7crfFUeBuc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446708955556.5557277915507; Thu, 3 Sep 2026 07:45:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fE-0002tw-Je; Thu, 03 Sep 2026 10:43:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f3-0002gJ-4W for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:30 -0400 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f0-00042Q-Ga for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:28 -0400 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-4858595f997so177965f8f.1 for ; Thu, 03 Sep 2026 07:43:25 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446605; x=1789051405; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=Cf1yI1aREIxDxkefBceSwViRa1AdWX44R35eLRi8QFs=; b=ey1CP4Myb8aTxovvSg+7wvUBJqSb2NvFEO3psi74IIkyF624w+cpPmk84E0iPZQoTz QV6a1G944uTI1E1plWmX7dP61Fl+6+n4jTQmgbWp7lPJSKa7aOLZVp9QmSWEkMUx0eBv o/4wXkVJ59liBir1265COGMOCIiOObBFXAIpZb1q6E7Yc2MrACvRzGixWbSv5w+G7AMd 9rKQIF9UIjHeN13LoTetaOOUZsMesytdxER4Q0vCFPtffPrCSNipJwNUp/KVkYcDXics 84e58mgV/z0v/vJUI5qkNyUcfQpTj7Tnppv87Yd9lTe02UhP90fwnMvmcNv2hHJvhU+Q 6Y1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446605; x=1789051405; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=Cf1yI1aREIxDxkefBceSwViRa1AdWX44R35eLRi8QFs=; b=B4q9gaUMwbnanQQCMDcRuHaqU4Sx+5oOFiYhb2cTAuEzqR9nG3hnjo3L/Q0OzZZWDK esuNnahy0muLp9OpPhLXD3kohpd3nFUjRjja5pa/TjbPtN5qhfakDsOHzGEVqjlU/iTu Cc9tK0jQ6Gi9GA4rPzbHZpRIXCmsMyL1+JMz8dMXAV1nhCS2KQgGL1piMqPBYEmENcoK lxKfRmPKJVC+Iby6Pxl4ZNw1HbHjWQf7TCs3B5wzGiMbgzmELGxM0gbnG7b3xFqcx2X4 NmovY92FZw1O78Px+hZcPtxmSqurrdL5zyvlqkZEj4tE01Y9CUyuwJ3mbWydR1LR2F2T y57g== X-Gm-Message-State: AFuF++lix7yk7OLBK8vOwbeDUtUgQop2w5uv0g9pscZUDXCoxQv5k7J4 zy7TdTopgey6EkJ21nuaH5dXJR3TrIKaJK8E+47A/4tk/aPBhApgqP3nXceVJ2nVwoltwPbRTmX 97MEc X-Gm-Gg: AYBFou13S/Wc9QUKcVG+XRXWO+tidE0umvwQ/TuvYbcJZT6oJeKB703Ji1Z7JPYnuZi 8M7G3uv0wwobISFi0hYd6esG0JnnJTSXkTvoCpgfy730h/HLCYkJ5ilQgiI3XeaYT0cr7p4xGIv g7Lm3uOTVXVMA65n0yHWn4rpH0lgpoLzBuR5Lg0x/HLTA9GoR15WUHFwdsvUN+RpPObTSMAvTCS hgB/Wh/tz8QOA8N3TDvEz5lrbY6qYB1Rd2qs5taUb9xzBvh2tavsB+Yx8Wi7F2b7cbRs3BoNtyD bwRA5DuKqjUzJYytP3HvAI3HjVRfItxxUFhHVbGbbyXFAF2xQ4lR0+5LSSxAl5AayQb9W720OPe 52nZ1zufN3eMcCo5/w92Q/PfVkJ95XqSpTy/zEPiQcSuTKyaaoJBprPvwxMqtCu/aMf8tiBWqvI wD8+cXJ13yXOhqTEmjHW93NPjnTzDCaSF5mu4L+bSXM3EtYQ/255iGb3Yt X-Received: by 2002:a5d:5d0c:0:b0:483:ca4a:4ce0 with SMTP id ffacd0b85a97d-48488e0396cmr25721153f8f.4.1788446604714; Thu, 03 Sep 2026 07:43:24 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 11/25] parallels: Add dirty bitmaps saving Date: Thu, 3 Sep 2026 16:41:29 +0200 Message-ID: <20260903144143.2328870-12-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::436; envelope-from=den@openvz.org; helo=mail-wr1-x436.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446710036158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Dirty bitmaps can be loaded now, but there is no way to save them. Add code for dirty bitmap storage. A bitmap which can not be stored is refused when it is created, by parallels_co_can_store_new_dirty_bitmap(), as at store time there is nowhere left to report it to: it would be dropped while the command which asked to persist it still succeeded. The format identifies a bitmap by a UUID, so a name which does not parse as one is refused, and so is one whose L1 table does not fit the Format Extension cluster next to the feature headers of the bitmaps already stored and the end of features marker. The hook and the store path share the size arithmetic. Losing a bitmap on an I/O error is still possible, and it used to be silent. Report it through errp and answer -EINVAL from parallels_inactivate(), the way qcow2_inactivate() does, giving up before the in use flag is cleared: the inactivation failed, the node stays writable, and the next open must not be told that the image was closed correctly. The extension is rebuilt as a whole and written to freshly allocated clusters on every store, and its clusters are deliberately absent from used_bmap, which is what lets the space of the copy read at open time be reused. parallels_check_unused_clusters() derives the end of the payload from used_bmap alone, though, so it would report the extension as a leak and 'qemu-img check -r leaks' would truncate it away while the header still points at it. Remember where the extension ends in s->ext_end and use it as a lower bound for the end of the payload. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 295 +++++++++++++++++++++++++++++++++++++++++- block/parallels.c | 12 ++ block/parallels.h | 7 + 3 files changed, 312 insertions(+), 2 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 21f54e4e3e..a0e2be395f 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -24,6 +24,7 @@ */ =20 #include "qemu/osdep.h" +#include "qemu/error-report.h" #include "qapi/error.h" #include "block/block-io.h" #include "block/block_int.h" @@ -96,8 +97,9 @@ parallels_load_bitmap_data(BlockDriverState *bs, const ui= nt64_t *l1_table, if (entry =3D=3D 1) { bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count, fals= e); } else { - ret =3D bdrv_pread(bs->file, entry << BDRV_SECTOR_BITS, - s->cluster_size, buf, 0); + int64_t host_off =3D entry << BDRV_SECTOR_BITS; + + ret =3D bdrv_pread(bs->file, host_off, s->cluster_size, buf, 0= ); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read bitmap data cluster"); @@ -105,6 +107,7 @@ parallels_load_bitmap_data(BlockDriverState *bs, const = uint64_t *l1_table, } bdrv_dirty_bitmap_deserialize_part(bitmap, buf, offset, count, false); + s->ext_end =3D MAX(s->ext_end, host_off + s->cluster_size); } } ret =3D 0; @@ -328,6 +331,8 @@ int parallels_read_format_extension(BlockDriverState *b= s, =20 assert(ext_off > 0); =20 + s->ext_end =3D ext_off + s->cluster_size; + ext_cluster =3D qemu_try_blockalign(bs->file->bs, s->cluster_size); if (!ext_cluster) { error_setg(errp, "Failed to allocate the Format Extension cluster"= ); @@ -347,3 +352,289 @@ out: =20 return ret; } + +static uint64_t parallels_bitmap_l1_size(uint32_t cluster_size, uint64_t b= ytes, + uint32_t granularity) +{ + uint64_t granules =3D DIV_ROUND_UP(bytes, granularity); + + return DIV_ROUND_UP(granules, (uint64_t)cluster_size * 8); +} + +static uint64_t parallels_bitmap_feature_size(uint64_t l1_size) +{ + return l1_size * sizeof(uint64_t) + sizeof(ParallelsFeatureHeader) + + sizeof(ParallelsDirtyBitmapFeature); +} + +static int GRAPH_RDLOCK parallels_save_bitmap(BlockDriverState *bs, + BdrvDirtyBitmap *bitmap, + uint8_t **buf, int *buf_size, + GArray *clusters, Error **er= rp) +{ + BDRVParallelsState *s =3D bs->opaque; + ParallelsFeatureHeader *fh; + ParallelsDirtyBitmapFeature *bh; + uint64_t *l1_table, l1_size, granularity, limit, idx; + int64_t bm_size, ser_size, offset, buf_used; + int64_t alloc_size =3D 1; + const char *name; + uint8_t *bm_buf; + QemuUUID uuid; + int ret =3D 0; + + if (!bdrv_dirty_bitmap_get_persistence(bitmap) || + bdrv_dirty_bitmap_inconsistent(bitmap)) { + return 0; + } + + name =3D bdrv_dirty_bitmap_name(bitmap); + ret =3D qemu_uuid_parse(name, &uuid); + if (ret < 0) { + error_setg(errp, "Can't save dirty bitmap: ID parsing error: '%s'", + name); + return ret; + } + + bm_size =3D bdrv_dirty_bitmap_size(bitmap); + granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + limit =3D bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bi= tmap); + ser_size =3D bdrv_dirty_bitmap_serialization_size(bitmap, 0, bm_size); + l1_size =3D DIV_ROUND_UP(ser_size, s->cluster_size); + + /* The end of features marker has to fit behind the feature as well */ + buf_used =3D parallels_bitmap_feature_size(l1_size); + if (buf_used + (int64_t)sizeof(*fh) > *buf_size) { + error_setg(errp, "Can't save dirty bitmap %s: it needs %" PRId64 + " bytes of the Format Extension cluster, %d bytes are l= eft", + name, buf_used, *buf_size); + return -ENOSPC; + } + + fh =3D (ParallelsFeatureHeader *)*buf; + bh =3D (ParallelsDirtyBitmapFeature *)(*buf + sizeof(*fh)); + l1_table =3D (uint64_t *)((uint8_t *)bh + sizeof(*bh)); + + fh->magic =3D cpu_to_le64(PARALLELS_DIRTY_BITMAP_FEATURE_MAGIC); + fh->data_size =3D cpu_to_le32(l1_size * 8 + sizeof(*bh)); + + bh->l1_size =3D cpu_to_le32(l1_size); + bh->size =3D cpu_to_le64(bm_size >> BDRV_SECTOR_BITS); + bh->granularity =3D cpu_to_le32(granularity >> BDRV_SECTOR_BITS); + memcpy(bh->id, &uuid, sizeof(uuid)); + + bm_buf =3D qemu_try_blockalign(bs->file->bs, s->cluster_size); + if (!bm_buf) { + error_setg(errp, "Can't save dirty bitmap %s: allocation error", n= ame); + ret =3D -ENOMEM; + goto fail; + } + + offset =3D 0; + while ((offset =3D bdrv_dirty_bitmap_next_dirty(bitmap, offset, + bm_size)) >=3D 0) { + int64_t cluster_off, end, write_size; + + idx =3D offset / limit; + + offset =3D QEMU_ALIGN_DOWN(offset, limit); + end =3D MIN(bm_size, offset + limit); + write_size =3D bdrv_dirty_bitmap_serialization_size(bitmap, offset, + end - offset); + assert(write_size <=3D s->cluster_size); + + bdrv_dirty_bitmap_serialize_part(bitmap, bm_buf, offset, end - off= set); + if (write_size < s->cluster_size) { + memset(bm_buf + write_size, 0, s->cluster_size - write_size); + } + + cluster_off =3D parallels_allocate_host_clusters(bs, &alloc_size); + if (cluster_off <=3D 0) { + ret =3D cluster_off < 0 ? cluster_off : -ENOSPC; + error_setg_errno(errp, -ret, "Can't save dirty bitmap %s: clus= ter " + "allocation error", name); + goto fail; + } + + ret =3D bdrv_pwrite(bs->file, cluster_off, s->cluster_size, bm_buf= , 0); + if (ret < 0) { + parallels_mark_unused(bs, s->used_bmap, s->used_bmap_size, + cluster_off, 1); + error_setg_errno(errp, -ret, "Can't save dirty bitmap %s: IO e= rror", + name); + goto fail; + } + + l1_table[idx] =3D cpu_to_le64(cluster_off >> BDRV_SECTOR_BITS); + s->ext_end =3D MAX(s->ext_end, cluster_off + s->cluster_size); + g_array_append_val(clusters, cluster_off); + offset =3D end; + } + + *buf_size -=3D buf_used; + *buf +=3D buf_used; + qemu_vfree(bm_buf); + return 0; + +fail: + /* Hand the clusters of the half written bitmap back to the allocator = */ + for (idx =3D 0; idx < l1_size; idx++) { + uint64_t entry =3D le64_to_cpu(l1_table[idx]); + + if (entry > 1) { + parallels_mark_unused(bs, s->used_bmap, s->used_bmap_size, + entry << BDRV_SECTOR_BITS, 1); + } + } + + /* Leave nothing behind a reader could take for a complete feature */ + memset(fh, 0, buf_used); + qemu_vfree(bm_buf); + return ret; +} + +void GRAPH_RDLOCK +parallels_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **err= p) +{ + BDRVParallelsState *s =3D bs->opaque; + BdrvDirtyBitmap *bitmap; + ParallelsFormatExtensionHeader *eh; + int remaining =3D s->cluster_size - sizeof(*eh); + uint8_t *buf, *pos; + int64_t header_off, alloc_size =3D 1; + g_autoptr(GArray) clusters =3D g_array_new(false, false, sizeof(int64_= t)); + g_autofree uint8_t *hash =3D NULL; + Error *bitmap_err =3D NULL; + size_t hash_len =3D 0; + int ret; + guint i; + + s->header->ext_off =3D 0; + s->ext_end =3D 0; + + if (!bdrv_has_named_bitmaps(bs)) { + return; + } + + buf =3D qemu_try_blockalign0(bs->file->bs, s->cluster_size); + if (!buf) { + error_setg(errp, "Can't save dirty bitmaps: allocation error"); + return; + } + + eh =3D (ParallelsFormatExtensionHeader *)buf; + pos =3D buf + sizeof(*eh); + + eh->magic =3D cpu_to_le64(PARALLELS_FORMAT_EXTENSION_MAGIC); + + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { + Error *local_err =3D NULL; + + /* + * The extension is written as a whole, so a bitmap which does not + * make it must not take with it the ones which did. + */ + if (parallels_save_bitmap(bs, bitmap, &pos, &remaining, clusters, + &local_err) < 0) { + error_propagate(&bitmap_err, local_err); + } + } + + if (pos =3D=3D buf + sizeof(*eh)) { + /* Not a single bitmap made it, so there is nothing to point at */ + goto end; + } + + header_off =3D parallels_allocate_host_clusters(bs, &alloc_size); + if (header_off <=3D 0) { + ret =3D header_off < 0 ? header_off : -ENOSPC; + error_setg_errno(errp, -ret, + "Can't save dirty bitmaps: cluster allocation err= or"); + goto end; + } + g_array_append_val(clusters, header_off); + + ret =3D qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_MD5, + (const char *)(buf + sizeof(*eh)), + s->cluster_size - sizeof(*eh), + &hash, &hash_len, NULL); + if (ret < 0 || hash_len !=3D sizeof(eh->check_sum)) { + error_setg(errp, "Can't save dirty bitmaps: hash error"); + goto end; + } + memcpy(eh->check_sum, hash, hash_len); + + ret =3D bdrv_pwrite(bs->file, header_off, s->cluster_size, buf, 0); + if (ret < 0) { + error_setg_errno(errp, -ret, "Can't save dirty bitmaps: IO error"); + goto end; + } + + s->header->ext_off =3D cpu_to_le64(header_off / BDRV_SECTOR_SIZE); + s->ext_end =3D MAX(s->ext_end, header_off + s->cluster_size); +end: + for (i =3D 0; i < clusters->len; i++) { + parallels_mark_unused(bs, s->used_bmap, s->used_bmap_size, + g_array_index(clusters, int64_t, i), 1); + } + + /* A bitmap which was dropped only matters if the rest went through */ + error_propagate(errp, bitmap_err); + qemu_vfree(buf); +} + +bool coroutine_fn parallels_co_can_store_new_dirty_bitmap(BlockDriverState= *bs, + const char *name, + uint32_t granula= rity, + Error **errp) +{ + BDRVParallelsState *s =3D bs->opaque; + BdrvDirtyBitmap *bitmap; + uint64_t needed, available; + QemuUUID uuid; + + if (bdrv_find_dirty_bitmap(bs, name)) { + error_setg(errp, "Bitmap already exists: %s", name); + return false; + } + + if (qemu_uuid_parse(name, &uuid) < 0) { + error_setg(errp, "Bitmap name must be a UUID to be stored in a " + "parallels image: %s", name); + return false; + } + + /* + * One L1 entry covers a cluster worth of serialized bits, and every + * bitmap of the image shares the Format Extension cluster with the + * feature headers and the end of features marker. + */ + needed =3D parallels_bitmap_feature_size( + parallels_bitmap_l1_size(s->cluster_size, + bs->total_sectors << BDRV_SECTOR_BITS, + granularity)); + + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { + if (!bdrv_dirty_bitmap_get_persistence(bitmap)) { + continue; + } + + needed +=3D parallels_bitmap_feature_size( + parallels_bitmap_l1_size(s->cluster_size, + bdrv_dirty_bitmap_size(bitmap), + bdrv_dirty_bitmap_granularity(bitmap)= )); + } + + needed +=3D sizeof(ParallelsFeatureHeader); + + available =3D s->cluster_size - sizeof(ParallelsFormatExtensionHeader); + if (needed > available) { + error_setg(errp, "Bitmap %s with granularity %" PRIu32 " does not = fit " + "into the Format Extension cluster: every bitmap of the= " + "image would need %" PRIu64 " bytes of it, %" PRIu64 " = are " + "available", name, granularity, needed, available); + return false; + } + + return true; +} diff --git a/block/parallels.c b/block/parallels.c index ace79ad968..a9464d5352 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -802,6 +802,7 @@ parallels_check_unused_clusters(BlockDriverState *bs, b= ool truncate) } =20 end_off +=3D s->data_start * BDRV_SECTOR_SIZE; + end_off =3D MAX(end_off, s->ext_end); =20 /* * A cluster in use behind the end of the file is corruption which @@ -1555,12 +1556,21 @@ fail: static int GRAPH_RDLOCK parallels_inactivate(BlockDriverState *bs) { BDRVParallelsState *s =3D bs->opaque; + Error *err =3D NULL; int64_t leak; =20 if (!(bs->open_flags & BDRV_O_RDWR) || (bs->open_flags & BDRV_O_INACTI= VE)) { return 0; } =20 + parallels_store_persistent_dirty_bitmaps(bs, &err); + if (err !=3D NULL) { + error_reportf_err(err, "Lost persistent bitmaps during " + "inactivation of node '%s': ", + bdrv_get_device_or_node_name(bs)); + return -EINVAL; + } + leak =3D parallels_check_unused_clusters(bs, true); if (leak < 0) { error_report("Failed to truncate image: %s", strerror(-leak)); @@ -1634,6 +1644,8 @@ static BlockDriver bdrv_parallels =3D { .bdrv_co_pwrite_zeroes =3D parallels_co_pwrite_zeroes, .bdrv_co_invalidate_cache =3D parallels_co_invalidate_cache, .bdrv_inactivate =3D parallels_inactivate, + .bdrv_co_can_store_new_dirty_bitmap =3D + parallels_co_can_store_new_dirty_bitmap, }; =20 static void bdrv_parallels_init(void) diff --git a/block/parallels.h b/block/parallels.h index eb90aeea81..4684ba2890 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -79,6 +79,8 @@ typedef struct BDRVParallelsState { unsigned int bat_size; =20 int64_t data_start; + /* Exclusive end of the Format Extension, which is absent from used_bm= ap */ + int64_t ext_end; uint64_t prealloc_size; ParallelsPreallocMode prealloc_mode; =20 @@ -100,5 +102,10 @@ int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(= BlockDriverState *bs, int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, Error **errp); +void GRAPH_RDLOCK +parallels_store_persistent_dirty_bitmaps(BlockDriverState *bs, Error **err= p); +bool coroutine_fn GRAPH_RDLOCK +parallels_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *= name, + uint32_t granularity, Error **errp= ); =20 #endif --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446757; cv=none; d=zohomail.com; s=zohoarc; b=HnLVQb2qTEH5ClXp7LJqUui2ErjmBKxqNdM5RxaQG9ZRtl3URYObCpzDEdkfkWOkK8+BuS8bQCK6lFMJ5lZvlCYB+uUUG1IteOEMeX6IMJ39TLx9oIAoancm2+vd2asmPW9oGMP+J+CLcOqVH0+1f7AwLnUKjDdLVvBi7tDJocs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446757; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=oMU0rRkqJ/vpKM9oem0Tv9koaS7lHqSrp/84fAD5rYg=; b=cygfBaT+lpDjgdXiCll9M+NnHD6SMqkwilfboQu/9KBwjhqw3IhxXBXybKa/kleIYHNtySwpPd4wH6yK+yg1jJnD2c07kw+fZIwi32mVf1w4GCCYff6cnHzHf6SNKKuDtpom3Bpc38/vHQwAA9TrU2yEEjA9S1zlw/Zo8CoSvGc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178844675748382.05443023122564; Thu, 3 Sep 2026 07:45:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f8-0002lt-1g; Thu, 03 Sep 2026 10:43:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f5-0002hJ-71 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:32 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f2-00042v-Er for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:30 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-47ddf7b09e5so2349614f8f.1 for ; Thu, 03 Sep 2026 07:43:27 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446606; x=1789051406; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=oMU0rRkqJ/vpKM9oem0Tv9koaS7lHqSrp/84fAD5rYg=; b=WKnt3K1+2VaD1KgC+SuxZ2xuUrcsWeoVcJ1YxNsAMHww/ndymwxYeOc+4vqpSl1Qe1 DoHO8V+LG7hUpQfqWWs6yQHtTbxHlX1aDlyMyJkb02rnvom9IQ6IMqN9FxLZwZ0ZXZ3b 7IQHxi32RZw5Nh+8s8TKr/rNH29ypIQTBgIbY76o4NSf7sd4uVAjbS6nZo3QqXyTZuXM oC3aPcn+PN5fHpvgSo942ozwzOaRAkVnGYyEncH0mC8vRSc7R7IieKHVR4AqVdGMJBfj TUVDZG3o2idXvhEZ5oFqxNpIgiNnIrP9ENJlJjUwjfnOTnJkqUekqbTqhKfHiekQGVAJ nvVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446606; x=1789051406; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=oMU0rRkqJ/vpKM9oem0Tv9koaS7lHqSrp/84fAD5rYg=; b=FhsTuyQ/wRFH5m1g2xLdoP+nwBWo8ZfWYdgzlBFQ5MUxNsHR17JcqG7mqM84lBEbrY jZzXWFGbeiHrWRn9Ov64+RtK94gYY2kPmQpwrrQTRaUoWhZxzL+tpYEqVbVcwHHPf2L+ 7gg6vbM8jWgcQN24Q7d2hcemi2tXC4eTdZM/csiO+Lg9RPpiEBNfC3lLw5R35MaWoalc 9T2jVS8229tlkaJni3+NCxnaZrmpDzUxq2RbgUrPx1FzYYWvVyf7GLyP1ABU+ZrskzNO 9/fusn0bs/l1CSIhE1rAVWWwpeNDCj33NjGkLSd2MnKUvZAdrb6yhgMFBkCRBxM14BHI NDEg== X-Gm-Message-State: AFuF++lF21xqXcHp3VR5XZ3CaWcYQwl+LaFwTzYJNWhGzNGQTENHozmv JugeTOSJDPpQ79H8DUoPf6NUlPnUzNi1lBdsKDKy+3vbfiRKRqKLegg5V6BAoQ7fxyhSXOr5K3j IrXBs X-Gm-Gg: AYBFou2aO5DzMTGb6uco1GHW1DzcWViLeDaij1WA43uhY5AVCAoJIDZPlcUvw66TtH2 rLGDey7clmUGrxlTH6/IuekT+kej8u51CwG3Akd8Knw9m8yVu9Phz596VuBhCGfsXgrBSuN6MOc Q4LmBwng/JQA4lvTJEKWGFKoBH+/If9zz3meeEam2C1HUvQuR/YdfAwT8BDfv9/Uf/rq9f0gwoP YWGKNeK30EuZtrm327Z5HuU3iUCz68SAOgvUF0AslihF6hr48FnSol5DlP8pZdVeEFVRTr4xvE7 yoMntH2SEvtz4skZkJi/skJ+VcdtmpxIzB46x7WH9JKbJwwYZjot3/AY+73sJHzpCo2jgSbR2cW krLXTMkKFxbU8AfcQIbQvdwJZ9xxrp2i1bsYlifjkepj2eErCCI+fju7nnMGWrsDqOpPov+ciJN PzidVDy8aqA3/T9WVrJZh9bBmnG1BbMD93DG5WpLoQq6meyAUT9Y0Wp4si X-Received: by 2002:a5d:59c7:0:b0:484:40b0:ef30 with SMTP id ffacd0b85a97d-48586028ca9mr1804455f8f.6.1788446605876; Thu, 03 Sep 2026 07:43:25 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 12/25] parallels: Let image extensions work in RW mode Date: Thu, 3 Sep 2026 16:41:30 +0200 Message-ID: <20260903144143.2328870-13-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=den@openvz.org; helo=mail-wr1-x434.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446758399158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Saving extensions is supported now, so we can let them work in read-write mode as well. The bounds check rejecting a Format Extension outside the image file used to sit in the read-only branch of the condition. Perform it unconditionally, as the extension is now read in both modes. A loaded bitmap was marked read-only unconditionally, guarded by an assert that the image is not writable. Mark it so for a read-only node only, as qcow2_load_dirty_bitmaps() does, or the next inactivation fails with "No write access". The condition is read-only alone rather than the full write access qcow2 asks about, as an inactive node can become writable later and parallels has no path which would clear the flag again. Mark the bitmap persistent as well, or it disappears from the image the first time it is written out. An unreadable extension must not keep the image shut. Its clusters are deliberately left free for reuse, so a guest write may have landed on them, and every qemu up to this one ignores the extension in read-write mode and truncates the file to the end of the payload on close, leaving ext_off pointing past the end of the file. Both refuse an image whose payload is perfectly fine, in either mode, with no way back through qemu-img check or convert. So do not ask the in use flag, ask whether what the header points at is an extension at all: an offset outside the file, a wrong magic or a wrong checksum all say that it is not, whoever left it behind, so drop it with a warning and forget where it ended, which lets the leak check reclaim the space. Behind the checksum the extension says what its writer meant it to say, so a feature this driver does not implement, or a bitmap it can not parse, keeps the image shut as before. Only an image which was not closed correctly gives up its extension there, as its bitmaps predate every write which followed the last inactivation. Reading a bitmap allocates a cluster sized buffer with the aborting qemu_blockalign(), and parallels_open() lets a cluster reach almost 2 GiB. That is reachable through every open now, so allocate it the way the storing side does and align it to bs->file. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 24 ++++++++----- block/parallels.c | 35 +++++++++++-------- .../qemu-iotests/tests/parallels-read-bitmap | 18 ++++++++-- .../tests/parallels-read-bitmap.out | 12 +++++-- 4 files changed, 60 insertions(+), 29 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index a0e2be395f..e89c489730 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -74,7 +74,11 @@ parallels_load_bitmap_data(BlockDriverState *bs, const u= int64_t *l1_table, uint8_t *buf =3D NULL; uint64_t i; =20 - buf =3D qemu_blockalign(bs, s->cluster_size); + buf =3D qemu_try_blockalign(bs->file->bs, s->cluster_size); + if (!buf) { + error_setg(errp, "Failed to allocate a bitmap data cluster"); + return -ENOMEM; + } limit =3D bdrv_dirty_bitmap_serialization_coverage(s->cluster_size, bi= tmap); for (i =3D 0, offset =3D 0; i < l1_size; ++i, offset +=3D limit) { uint64_t count, entry; @@ -210,9 +214,9 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *da= ta, size_t data_size, } } =20 - /* We support format extension only for RO parallels images. */ - assert(!(bs->open_flags & BDRV_O_RDWR)); - bdrv_dirty_bitmap_set_readonly(bitmap, true); + if (!(bs->open_flags & BDRV_O_RDWR)) { + bdrv_dirty_bitmap_set_readonly(bitmap, true); + } =20 return bitmap; =20 @@ -226,7 +230,7 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, Error **errp) { BDRVParallelsState *s =3D bs->opaque; - int ret; + int ret =3D -EINVAL; int remaining =3D s->cluster_size; uint8_t *pos =3D ext_cluster; ParallelsFormatExtensionHeader eh; @@ -243,12 +247,12 @@ parallels_parse_format_extension(BlockDriverState *bs= , uint8_t *ext_cluster, error_setg(errp, "Wrong parallels Format Extension magic: 0x%" PRI= x64 ", expected: 0x%llx", eh.magic, PARALLELS_FORMAT_EXTENSION_MAGIC); + ret =3D -ENOENT; goto fail; } =20 - ret =3D qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_MD5, (char *)pos, remaini= ng, - &hash, &hash_len, errp); - if (ret < 0) { + if (qcrypto_hash_bytes(QCRYPTO_HASH_ALGO_MD5, (char *)pos, remaining, + &hash, &hash_len, errp) < 0) { goto fail; } =20 @@ -256,6 +260,7 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, memcmp(hash, eh.check_sum, sizeof(eh.check_sum)) !=3D 0) { error_setg(errp, "Wrong checksum in Format Extension header. Forma= t " "extension is corrupted."); + ret =3D -ENOENT; goto fail; } =20 @@ -301,6 +306,7 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, if (!bitmap) { goto fail; } + bdrv_dirty_bitmap_set_persistence(bitmap, true); bitmaps =3D g_slist_append(bitmaps, bitmap); break; =20 @@ -319,7 +325,7 @@ fail: } g_slist_free(bitmaps); =20 - return -EINVAL; + return ret; } =20 int parallels_read_format_extension(BlockDriverState *bs, diff --git a/block/parallels.c b/block/parallels.c index a9464d5352..90b7f7c8de 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1454,25 +1454,30 @@ static int parallels_open(BlockDriverState *bs, QDi= ct *options, int flags, =20 if (ph.ext_off) { int64_t ext_off =3D le64_to_cpu(ph.ext_off); + Error *ext_err =3D NULL; =20 - if (flags & BDRV_O_RDWR) { - /* - * It's unsafe to open image RW if there is an extension (as we - * don't support it). But parallels driver in QEMU historically - * ignores the extension, so print warning and don't care. - */ - warn_report("Format Extension ignored in RW mode"); - } else if (ext_off + s->tracks > file_nb_sectors) { - error_setg(errp, "Invalid image: Format Extension is outside t= he " - "image file"); - ret =3D -EINVAL; - goto fail; + if (ext_off + s->tracks > file_nb_sectors) { + ret =3D -ENOENT; + error_setg(&ext_err, "Format Extension is outside the image fi= le"); } else { - ret =3D parallels_read_format_extension( - bs, ext_off << BDRV_SECTOR_BITS, errp); - if (ret < 0) { + ret =3D parallels_read_format_extension(bs, + ext_off << BDRV_SECTOR_B= ITS, + &ext_err); + } + if (ret =3D=3D -ENOENT) { + s->ext_end =3D 0; + warn_reportf_err(ext_err, "Dropping the Format Extension of no= de " + "'%s', which does not look like one: ", + bdrv_get_device_or_node_name(bs)); + } else if (ret < 0) { + if (!s->header_unclean) { + error_propagate(errp, ext_err); goto fail; } + s->ext_end =3D 0; + warn_reportf_err(ext_err, "Dropping the Format Extension of no= de " + "'%s', which was not closed correctly: ", + bdrv_get_device_or_node_name(bs)); } } =20 diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-read-bitmap index 5cbef25018..6990926d60 100755 --- a/tests/qemu-iotests/tests/parallels-read-bitmap +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -121,8 +121,16 @@ def report(name): log(f'qemu-img died with signal {-exc.returncode}') return =20 - log('image opened' if res.returncode =3D=3D 0 - else iotests.filter_testfiles(res.stdout).strip()) + out =3D iotests.filter_generated_node_ids( + iotests.filter_testfiles(res.stdout)) + if res.returncode !=3D 0: + log(out.strip()) + return + + log('image opened') + for line in out.splitlines(): + if 'warning' in line: + log(line.strip()) =20 =20 def check(name, ext, tracks=3D1): @@ -148,6 +156,12 @@ check('wrong extension magic', check('wrong extension checksum', extension(feature(0, 0), checksum=3DFalse)) =20 +# An older qemu truncates the extension cluster away on close. +with open(crafted, 'wb') as img: + img.write(parallels_header(1, SECTORS, SECTORS, EXT_SECTOR)) + img.truncate(EXT_SECTOR * 512) +report('extension cut off the end of the file') + check('unknown feature', extension(feature(BITMAP_MAGIC ^ 1, 0))) =20 check('feature flags set', extension(feature(0, 0, flags=3D1))) diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap.out b/tests/qem= u-iotests/tests/parallels-read-bitmap.out index 3b3f90c8de..13b10af5a4 100644 --- a/tests/qemu-iotests/tests/parallels-read-bitmap.out +++ b/tests/qemu-iotests/tests/parallels-read-bitmap.out @@ -8,9 +8,14 @@ Kill NBD server --- well-formed extension image opened --- wrong extension magic -qemu-img: Could not open 'TEST_DIR/PID-crafted': Wrong parallels Format Ex= tension magic: 0xab234cef23dcea86, expected: 0xab234cef23dcea87 +image opened +qemu-img: warning: Dropping the Format Extension of node 'NODE_NAME', whic= h does not look like one: Wrong parallels Format Extension magic: 0xab234ce= f23dcea86, expected: 0xab234cef23dcea87 --- wrong extension checksum -qemu-img: Could not open 'TEST_DIR/PID-crafted': Wrong checksum in Format = Extension header. Format extension is corrupted. +image opened +qemu-img: warning: Dropping the Format Extension of node 'NODE_NAME', whic= h does not look like one: Wrong checksum in Format Extension header. Format= extension is corrupted. +--- extension cut off the end of the file +image opened +qemu-img: warning: Dropping the Format Extension of node 'NODE_NAME', whic= h does not look like one: Format Extension is outside the image file --- unknown feature qemu-img: Could not open 'TEST_DIR/PID-crafted': Unknown feature: 0x20385f= ae252cb34b --- feature flags set @@ -30,7 +35,8 @@ qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid = bitmap granularity 4294 --- bitmap L1 entry overflows qemu-img: Could not open 'TEST_DIR/PID-crafted': Failed to read bitmap dat= a cluster: Input/output error --- cluster_size beyond the file size -qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid image: Format Ext= ension is outside the image file +image opened +qemu-img: warning: Dropping the Format Extension of node 'NODE_NAME', whic= h does not look like one: Format Extension is outside the image file --- bitmap serialization coverage overflow image opened --- bitmap spanning two L1 entries --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446685; cv=none; d=zohomail.com; s=zohoarc; b=YYvIJMi5leGGhizRpN2u84F+i4s92a/t3NE20tu0q5yI1lNHVsOOi43ywkL0MhdCKG2F9BBeTCe3iuowe78YUABoV/WPwnG/LcZXJJMk2nABFmL5p1oaMBj7YL+hZNPF+WJ/WXvjm+r02aAttTOLH/czdEotgz0OR5XAt3kZm6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446685; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=vF+6ndrGLXKQZTWxC6EFwxN5nkIplvn1xYCLbrS7Iiw=; b=fo4aWPkdG98qXle6nCB3OpoEsFJgjfg9ulrf/2Me3GLgoz0VFwcajRK2Qv/kj2UEB5GjP2ngPwAmc9LDBiflzLu/GFd+rqUnUwducNYGG9YSsVNMh24gsDcsQcnJCOLGDkO6KRD/60Q0ExgWVBZ7+YeYWsYcJrMb1HfmcQ35n50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446685490315.4299855791106; Thu, 3 Sep 2026 07:44:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f9-0002mo-0z; Thu, 03 Sep 2026 10:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f6-0002j2-NN for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:32 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f2-00043U-MC for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:31 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4998b5a63e2so25167715e9.1 for ; Thu, 03 Sep 2026 07:43:28 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446607; x=1789051407; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=vF+6ndrGLXKQZTWxC6EFwxN5nkIplvn1xYCLbrS7Iiw=; b=qIVdV4OKlQW34rGD5ibC87A02fhGYwWRg1qgi7Ey+8v+lZPN8ws/QSSN6n6ToZ6gJG +oNF5pimNC1+cphmJCQ1Nbd8ad4Sw4ouTh/bQnNOWOMqJbKr4+9himslRRdEMHQwz9Y9 RLzT4FYaqMm8XiyzA/JVbilHf6BtPtM9BWg5tpWCTP1X3XWljbQpe6XGggaF5nvnz3+b R+tc198qvaZyywuqsYfPrHIT/EATwkDCpmD9NcaVCheAE6Fnh8g/Vms5fs4QXrVzrRsh c3vmWlkSAhO7d9BCPaQQ7fHB+8MPwfgP9SgKAvEsKDfA9iOoY354IueoYEUkElWxnzUn 3ytQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446607; x=1789051407; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=vF+6ndrGLXKQZTWxC6EFwxN5nkIplvn1xYCLbrS7Iiw=; b=Y71eITo7kjeO8IkbfdaW6gnH+3q5gBqQKdBcfKg5vajiRPaumkUI1DradsU+kUDtnS svT2tVOzuayL4OjXmOjvuZ5CCZ4h4c+rE/NMNtUiENYhujKcKycvdsroHACrUhGJKEZ+ 4e4yWl8G3SVlavHibg+gqEFFR+AD5XXBetZtSBSA28zOPkVStuKwQiSbgGRThbmuaIcC Ft7ywsp0yw4ViysDnT3PBjFnX6+Z6TF/841hxS0uQ42oBcVFuaHCYOAXEkupPRF7opEu cAUAgRC00Iyo++OR0MZJXXqYdpQD0ZZvEGy2Apf5u+C2o/aU6C3FD/XTuzrAyOHKmlsX /pjw== X-Gm-Message-State: AFuF++lAsXsviQgI+PeYkbcJ2JULF4PK8Q3EZG9bm8JSRoHK0ddqOpbE sF56zRMJfbRxjjxcaP/555KqCQ+Ow2q9RLvJBCFNSopkQjGQU/wf/Pu3Sx3rMNKR7WaIT8bJ4B6 UGG/H X-Gm-Gg: AYBFou34FPiFlp8al8RRL/tyaHFesl4Np7Gx81FaaP0G50x+NvXBonk2S6k5aX6vVcG cfg7GU4Sr2Zi/uT5JZFOYbOlwoP4wT1jxgttTA3WC/3/9pf2SM7+gNj4GZ/XB0/uHUpYEw2vzxJ rvGMFE3+ehVW0H2CZ942AKnb1n1RwCv2f28DsVlkJZNK1cMy2NWo5/dq2RlPMiJ6Bl8JWct5DtQ 2HWIeuOsraytdmkxlMCxuia27FGSxP28CRUsy5SaFpX5uJVY5uO2ZRHlye36RaPQC3z/LQcH/SE hoA2yzjK7FvYpiUt/raNkrAnsbiaOC+fxae9Zv8/Vy7+L6yF2X2dLPmpowG0fGRKD8+jlGnW0pY ywxgKr40rx4X0PQns0MEWA+wetavbN2dtrqNKtg2rLGHh306qnrqwQukL4aSAfLaTy1wW9JHJi1 rofcYHyPxMLzE7kc4j3vVKETk1U++Ew5k27KRChzcnHRsL9AsMfnWZ/VHpgfUPIE639cOm X-Received: by 2002:a05:600c:3f08:b0:49b:d45:703e with SMTP id 5b1f17b1804b1-49cf5bbdbb1mr11054945e9.8.1788446607048; Thu, 03 Sep 2026 07:43:27 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 13/25] parallels: Handle L1 entries equal to one Date: Thu, 3 Sep 2026 16:41:31 +0200 Message-ID: <20260903144143.2328870-14-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=den@openvz.org; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446687632158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev If all the bits in a dirty bitmap cluster are ones, the cluster shouldn't be written. Instead the corresponding L1 entry should be set to 1. Ask bdrv_dirty_bitmap_next_zero() for a clean bit in the range the entry covers, and store the marker when there is none. Two things have to match the region rather than the cluster which serializes it: the search is bounded by the end of the region, as a count and not as an offset, and a missing clean bit is the answer we are looking for rather than a reason to give up. A dirty run is not a substitute for either. Its length says nothing about the region it lies in, so comparing it to the cluster size marks a chunk as all ones when only a cluster worth of it is dirty, and treating "no clean bit at all" as a failure leaves the entry at zero, which says the whole chunk is clean. Both directions are silent: a full disk overwrite comes back as a completely clean bitmap, and a single dirty cluster comes back as everything the entry covers being dirty. An incremental backup driven by the first one copies nothing. The marker goes through cpu_to_le64() like the cluster offsets below it, as the loading side reads the table with ldq_le_p(). The serialization moved behind the check, as there is nothing to write when the marker is stored. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index e89c489730..6a889d86fa 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -439,12 +439,20 @@ static int GRAPH_RDLOCK parallels_save_bitmap(BlockDr= iverState *bs, offset =3D 0; while ((offset =3D bdrv_dirty_bitmap_next_dirty(bitmap, offset, bm_size)) >=3D 0) { - int64_t cluster_off, end, write_size; + int64_t cluster_off, end, write_size, first_zero; =20 idx =3D offset / limit; =20 offset =3D QEMU_ALIGN_DOWN(offset, limit); end =3D MIN(bm_size, offset + limit); + + first_zero =3D bdrv_dirty_bitmap_next_zero(bitmap, offset, end - o= ffset); + if (first_zero < 0) { + l1_table[idx] =3D cpu_to_le64(1); + offset =3D end; + continue; + } + write_size =3D bdrv_dirty_bitmap_serialization_size(bitmap, offset, end - offset); assert(write_size <=3D s->cluster_size); --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446713; cv=none; d=zohomail.com; s=zohoarc; b=P0WnxBnMonqInw/M9KB30FSdGVJSlpe69OB5z74b0Ye1M/DEaPmDxM2YtahIeWvf0Uhu7Uwgsm1rXZbeZoYgxego2/hJB8k3+k2HNq2b70nt2JMpgmpA+pABfb/y9Va60qUoNwhCnyvcIjI82VeIe3qkrT86zOnUHElR/z5rjE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446713; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mGHyHtBjiaIzmCNt57RsevzZuH4XsgPjyN0SdYM+JtQ=; b=QdKp+YzZ9ack+XyuK2+Hiwcy3eXD2ydQ+YULXjpb0PhTrVEbLwir48DNs4DbwNDCqGeUuJSg5l4pS+G8p+KR/UBQzhrO47dfyYFUOAUuQShoFsawPL8AyvuMkO8A+OCuEm44Zjg8dELGlLG42hd1lK3BZ4ZnfwsPpz44C6CFSYg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446713525151.4273057875049; Thu, 3 Sep 2026 07:45:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f9-0002oH-Q6; Thu, 03 Sep 2026 10:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f6-0002j7-P0 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:32 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f3-00043q-Is for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:32 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-49b8eeb3ff2so22545375e9.2 for ; Thu, 03 Sep 2026 07:43:29 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446608; x=1789051408; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=mGHyHtBjiaIzmCNt57RsevzZuH4XsgPjyN0SdYM+JtQ=; b=m5RhOWR/mD90D/6RYfTEBh1iFQZutIaS/zK/vaQETRriR511TDoVGhQvVSvPX8wywh i3AdZ4yzwrTggwS6IzI6pfin4RbifTi9WWfvSraIivcmrKJrezMLUyqNZ+AQPZTS3p5U lTse+CKKD7mBucPdih4ouw1hNvVs3Hxw3INrfq3tNz41uQkVNJyZtTaTFXk/uHe2zfwZ HTY4A2lKzhJ6Wm4NIQHM3oOlgEDk9zgGMzPum4Nod0I6buUX9hmnwyyNozZOVXiWGQ+G SSWcHIS+GVLU4fv3vcFqpMRWpIRm/ktMy7AFNHdPlIaaxRFFhpcp1xa8cfJSIrMquMgi 19TA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446608; x=1789051408; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=mGHyHtBjiaIzmCNt57RsevzZuH4XsgPjyN0SdYM+JtQ=; b=Ff47fkWhbG4kCuaEuze1Avr4lRV9f9uGQaAtDBcpbbZ5Xd+sJyI/sva23zON85Jw7J Ip8eSSfyGu0oxq7xk0jHMTNgO7PoPQa4SKU0hmxMFUvOwcqxSERNPZc2n8xl7QhyBwMh avp5x/Owxxu+Nd4CZn4XYr5iFVXvie4r2hUUPolNnVcLtHsRn8Lx/GrZh1cRvMXETSjL DPLeV+00cmNNpT27Sd8Fi+vyiumbuANB6WOUuLPMaXjUxvvNhZzzqlvVk4sZDt+uhQDc qMVwltsBCB3cQq7V2WKmUV2nUbOt3/VO9WIWiCAQGpDw0CkAQ92DsQuYOIg7BrTqndyu Ojbg== X-Gm-Message-State: AFuF++ki1KI5W4BAJAiyiQuW0R5JNRH5jclcBYHYd2GcvuvgPd/xis3Q PWSZRG2WSmIBmU7zhV5bO+sK99NLK6dEZ+2D4QcNUmJSjJ1J+vjaUYOM8kQps+8+w5NogfGeznc XdzCj X-Gm-Gg: AYBFou20dI2yXKwZUerqrVHEiTqeYXHzjNC8w5An5/jj7xyPIG04TLN3wlk1ZwZanSa wYVTr64EfeoGjV4eobBjegkD294m45f7lywrMg2n3KRutxBL91mxaGGYEWTeA+jPAG4GwGNJUMI 6eTJCucqw7aGxncqnZ/LQdfw+8Ddvi3BtwVOZYQPwUe3gpUyaEYSh9pw4dCD2QTGghSFZPYh8MR pz1zOsXE5zg1GReMGs9csXIm97qLD7i1IV0i7eUA3NFm6OO3S77+k9NZ91f5xKafi/qF2L2hNdP G1Q6x1qMZ9j1HL4whcnMDMxvq7CqACjLoMT7Xr0XIeWRuZ99cMOAM8ZtC/heJQf5y4pvRj2hUDb 9nSCwEWxye5vJFGDKjgrRvLWtKUkNsi9ql0tyZUMYS+bkZaihOVWUtHVVNscA4TsGR+rL6hIkZz kyzvpTgS5DZiXkxagEL6NTvquhG7dXMd4YAALqWcF1MkwRIIQGzbAiMLZl X-Received: by 2002:a05:600c:6217:b0:49c:f3dd:e166 with SMTP id 5b1f17b1804b1-49cf3dde195mr67253335e9.13.1788446608111; Thu, 03 Sep 2026 07:43:28 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 14/25] iotests: cover the Format Extension against the leak check Date: Thu, 3 Sep 2026 16:41:32 +0200 Message-ID: <20260903144143.2328870-15-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=den@openvz.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446716077158501 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev The Format Extension and the bitmap data clusters it points to are absent from used_bmap, so the leak check has to be told about them through s->ext_end or it reports the space they occupy as leaked and 'qemu-img check -r leaks' truncates it away while the header still points at it. The leak coverage in parallels-checks grows a persistent bitmap, dirtied one granule at a time so that parallels_save_bitmap() stores a bitmap data cluster rather than the all ones L1 entry and the extension spans two clusters. It asserts that neither is a leak, that a genuine leak appended after them is still reported and repaired, that the bitmap and the guest data survive the repair, and that dropping the bitmap makes the space reclaimable. Without s->ext_end the check reports two leaked clusters where there should be none. A name which is not a UUID is covered there too, as the refusal belongs to the same command. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/tests/parallels-checks | 48 +++++++++++++++++++ tests/qemu-iotests/tests/parallels-checks.out | 35 ++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index c9dcd715ac..6f60fda62b 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -362,6 +362,54 @@ echo "file size: `stat --printf=3D"%s" "$TEST_IMG"`" =20 echo "=3D=3D the first cluster survived =3D=3D" { $QEMU_IO -c "read -P 0x11 0 $CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 | _filter= _qemu_io | _filter_testdir +_make_test_img $SIZE + +echo "=3D=3D TEST FORMAT EXTENSION IS NOT LEAKED SPACE =3D=3D" + +BITMAP=3Db2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 + +echo "=3D=3D a name which is not a UUID can not be stored, so refuse it = =3D=3D" +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" bitmap0 2>&1 | _filter_testd= ir + +echo "=3D=3D add a persistent dirty bitmap =3D=3D" +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_testd= ir + +# A dirty run shorter than a cluster is stored as a bitmap data cluster +# instead of the all-ones L1 entry, so the extension spans two clusters. +echo "=3D=3D dirty a single granule of the bitmap =3D=3D" +{ $QEMU_IO -c "write -P 0x11 0 65536" "$TEST_IMG"; } 2>&1 | _filter_qemu_i= o | _filter_testdir + +file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` +echo "file size: $file_size" + +echo "=3D=3D the extension and its bitmap data are not a leak =3D=3D" +_check_test_img + +echo "=3D=3D extend image by 1 cluster =3D=3D" +fallocate -xl $((file_size + CLUSTER_SIZE)) "$TEST_IMG" + +echo "=3D=3D a real leak is still reported =3D=3D" +_check_test_img + +echo "=3D=3D repair reclaims the leak only =3D=3D" +_check_test_img -r leaks + +file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` +echo "file size: $file_size" + +echo "=3D=3D the bitmap survived the repair =3D=3D" +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_testd= ir + +echo "=3D=3D data survived the repair =3D=3D" +{ $QEMU_IO -r -c "read -P 0x11 0 65536" "$TEST_IMG"; } 2>&1 | _filter_qemu= _io | _filter_testdir + +echo "=3D=3D dropping the bitmap makes the space reclaimable again =3D=3D" +$QEMU_IMG bitmap --remove -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_te= stdir + +file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` +echo "file size: $file_size" + +_check_test_img =20 # Clear image _make_test_img $SIZE diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index 6699848996..d40f865868 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -233,6 +233,41 @@ file size: 2097152 read 1048576/1048576 bytes at offset 0 1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D TEST FORMAT EXTENSION IS NOT LEAKED SPACE =3D=3D +=3D=3D a name which is not a UUID can not be stored, so refuse it =3D=3D +qemu-img: Operation add on bitmap bitmap0 failed: Bitmap name must be a UU= ID to be stored in a parallels image: bitmap0 +=3D=3D add a persistent dirty bitmap =3D=3D +=3D=3D dirty a single granule of the bitmap =3D=3D +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +file size: 4194304 +=3D=3D the extension and its bitmap data are not a leak =3D=3D +No errors were found on the image. +=3D=3D extend image by 1 cluster =3D=3D +=3D=3D a real leak is still reported =3D=3D +ERROR space leaked at the end of the image 1048576 + +1 leaked clusters were found on the image. +This means waste of disk space, but no harm to data. +=3D=3D repair reclaims the leak only =3D=3D +Repairing space leaked at the end of the image 1048576 +The following inconsistencies were found and repaired: + + 1 leaked clusters + 0 corruptions + +Double checking the fixed image now... +No errors were found on the image. +file size: 4194304 +=3D=3D the bitmap survived the repair =3D=3D +qemu-img: Operation add on bitmap b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 fai= led: Bitmap already exists: b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 +=3D=3D data survived the repair =3D=3D +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D dropping the bitmap makes the space reclaimable again =3D=3D +file size: 2097152 +No errors were found on the image. +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 =3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D =3D=3D write two clusters =3D=3D wrote 1048576/1048576 bytes at offset 0 --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446676; cv=none; d=zohomail.com; s=zohoarc; b=c/3EE4cXMfow5oau5Lfi7afyjz8I0nnJrVrPPGq1GOLHCawPNb2mI1DZiCMkDdyKWf1osBZSt/4GHfV+aQMdsmHAJO4tu/XLgyzUbQ1K7e9+nsVGQRBQZSZsup8P3+ClNB68R36jrwwamuxD02agR/5KDdSBNmIG5o1LplLAlCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446676; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=9jfZ0sib9Q6CuIrjV7feNJ39M8KHkevHDagQkapzRWc=; b=dwUGRiuF5yC/ajilUurqSv09dI0U++qYiQ50RwWqH+089asIXHLGkDbnW4Oy0PvDhr8a+Ly3eTRnV8YzpkI4wTOyuEkKoN3pXFeaEb/pKbHxajQm/x/K79alP9vNw6zWHYwzCfgxizuDcEY9CVhz9iF4uGVtvdGVoerxVykQWXc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 178844667690823.919233078915795; Thu, 3 Sep 2026 07:44:36 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28f9-0002n6-2d; Thu, 03 Sep 2026 10:43:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f6-0002jL-RU for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:32 -0400 Received: from mail-wr1-x429.google.com ([2a00:1450:4864:20::429]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f4-00044H-MW for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:32 -0400 Received: by mail-wr1-x429.google.com with SMTP id ffacd0b85a97d-482e257a23aso1741186f8f.0 for ; Thu, 03 Sep 2026 07:43:30 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446609; x=1789051409; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=9jfZ0sib9Q6CuIrjV7feNJ39M8KHkevHDagQkapzRWc=; b=bspXF3O+fyt66YyQJprt7Dvsv/LqmyFclLfg5uCX83FdlZvF9B8ZIovepV9bnD43sk OQGjiyt+TGnonOdNx8APOKbQ/A2aO4KodFg10VZWZxF8IWK0t+UlmyeGgu1LAPza/0U3 cZgbAU2MYZ7dhMb5MjrIwVV8FQxoRfPlRrxq50epPffuRHBQC8tkjOHTlY9/wDhNZcsO VeQSAwx+31sdMSzZxYDG4U6z96esMNTgZ/n98joE0xhLLEK8xDT7jGr4RSSm6tl5ezIP o9FhKCX+YGAaDVvLXJiB8tNsIyt4vj3Bc2R6T3jfX4AZ9YYY53Fpby4Z9aNUPaMeO3og cUaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446609; x=1789051409; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=9jfZ0sib9Q6CuIrjV7feNJ39M8KHkevHDagQkapzRWc=; b=SjGXGCJWGEWMMMLp3XCUnjP1LnmyjzJiDgQmHfFNeTPWdYeNNbSeWW2cMhO2Da+mT/ MYDsr/wHAeQS8xnadzfinAc11VQ3tZBJFHja4CqzpdeHQn2qIHEkUeAWe8Uv3FJGMYjq f/l26wc46TnHJu7oGENvz8KLicATocHrr41H1PfNWm6UMJqTbB5smo7lvUUI09Bfy8LS kN8J9HAA9HxynYLvWBtnektVlmOTGBWjhnN+skyXLJ4pb8QhfGMDO9T+EVpnxsvfFl2y A+R4RfyMg0GWwZB+Hs4Y+yVZQgS+1ZIKGGkLVDHYzSX6TTJRm+WtSDTe/4cO4CC8ml2S JwBQ== X-Gm-Message-State: AFuF++kT/E8GjgyJoxcJUCt3B5JQdBg8omF16j1sTj8l0KnygTY6bKKJ qsRp0pVyNW17w/8ryy0OCFx7wfalSW0zFGefYy5MANkomgVGxk2QehwyiKNTJmys3xb9U0c9+Ni RE5uF X-Gm-Gg: AYBFou3To7XyDqdgBtu0T0epSemmHrqHPj06stLBJ/hcaNcDNzjkAwHWmAmCLWtavpM ZlkyLHFjJ1lClBUlYC1WKvTPDmuzcd48Y5CyTSjn0cZ3KIJiqWiQ7cL1J/kVd70hikV99Ns3h4k WlSWsqBTCliMJeEUzG0Ii96UAzzeScKxDC2gnlczOTp4o76bxWmBx87vi+78DEjyJsi1SwnjTxq //KCGQSkT3mpS2aEemBbnZibQTcTRRl1fKOBCIRc3jf4ejA39idziOU29nDOVBxlOGdZufXKGUt qpCd0vN0DymjjHWz45Sx414pWDH81imVXr4p2vmasXZs3Ci3VUGjGW2vNBjvsMkgMCyySWBKtrW yl4rkNldEZ+d3M7h3pbWKbEWVGSHjNstsDfGobBJfIbIqRABtrhYH9WNs1ZbLyhwudz8ROahhGm 0A9ubHdFj8rTk/W23VJhE7fmhBZh/XiPLHRlG56AAHKWAH5bzHmIu6jt25 X-Received: by 2002:a05:6000:4698:b0:485:4277:fbab with SMTP id ffacd0b85a97d-4854277fc83mr17049675f8f.27.1788446609090; Thu, 03 Sep 2026 07:43:29 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 15/25] iotests: run the persistent dirty bitmap test on parallels Date: Thu, 3 Sep 2026 16:41:33 +0200 Message-ID: <20260903144143.2328870-16-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::429; envelope-from=den@openvz.org; helo=mail-wr1-x429.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446677606158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev parallels stores persistent dirty bitmaps now, so test 165 applies to it as well. The bitmap name is the only format specific bit: parallels keeps it as the UUID identifying the bitmap in the image, so a name like 'bitmap0' is rejected on store. test_reopen_rw is skipped, as parallels has no bdrv_reopen_prepare() and blockdev-reopen fails with "does not support reopening files". Skipped cases do not show up in the reference output, so 165.out stays as it is. test_persistent covers what the series adds: it dirties the bitmap, records its hash, restarts the VM twice and compares the hash again, which passes only if the bitmap survives both the store on inactivation and the load on open. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/165 | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/tests/qemu-iotests/165 b/tests/qemu-iotests/165 index 8fc79daae1..13b784fcc6 100755 --- a/tests/qemu-iotests/165 +++ b/tests/qemu-iotests/165 @@ -27,6 +27,12 @@ from iotests import qemu_img disk =3D os.path.join(iotests.test_dir, 'disk') disk_size =3D 0x40000000 # 1G =20 +# parallels stores a bitmap name as the UUID identifying it in the image +if iotests.imgfmt =3D=3D 'parallels': + bitmap_name =3D 'b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45' +else: + bitmap_name =3D 'bitmap0' + # regions for qemu_io: (start, count) in bytes regions1 =3D ((0x0fff00, 0x10000), (0x200000, 0x100000)) @@ -50,12 +56,12 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): =20 def getSha256(self): result =3D self.vm.qmp('x-debug-block-dirty-bitmap-sha256', - node=3D'drive0', name=3D'bitmap0') + node=3D'drive0', name=3Dbitmap_name) return result['return']['sha256'] =20 def checkBitmap(self, sha256): result =3D self.vm.qmp('x-debug-block-dirty-bitmap-sha256', - node=3D'drive0', name=3D'bitmap0') + node=3D'drive0', name=3Dbitmap_name) self.assert_qmp(result, 'return/sha256', sha256); =20 def writeRegions(self, regions): @@ -65,7 +71,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): =20 def qmpAddBitmap(self): self.vm.qmp('block-dirty-bitmap-add', node=3D'drive0', - name=3D'bitmap0', persistent=3DTrue) + name=3Dbitmap_name, persistent=3DTrue) =20 def test_persistent(self): self.vm =3D self.mkVm() @@ -100,6 +106,8 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): =20 self.vm.shutdown() =20 + # parallels has no bdrv_reopen_prepare() yet + @iotests.skip_for_formats(('parallels',)) def test_reopen_rw(self): self.vm =3D self.mkVm() self.vm.launch() @@ -115,7 +123,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): assert sha256_1 !=3D sha256_2 # Otherwise, it's not very interesti= ng. =20 self.vm.cmd('block-dirty-bitmap-clear', node=3D'drive0', - name=3D'bitmap0') + name=3Dbitmap_name) =20 # Start with regions1 =20 @@ -152,7 +160,7 @@ class TestPersistentDirtyBitmap(iotests.QMPTestCase): =20 =20 if __name__ =3D=3D '__main__': - iotests.main(supported_fmts=3D['qcow2'], + iotests.main(supported_fmts=3D['qcow2', 'parallels'], supported_protocols=3D['file'], unsupported_imgopts=3D['compat'], require_hmp=3DTrue) --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446741; cv=none; d=zohomail.com; s=zohoarc; b=N9g/RuplQbQ1xD760xgc/sZFeCS00B1a07L4XnTqIOxD8xK/oMebVvTL+x5x99kt+RyvsePn7WG5cgyHE7f1TTvc+/VHpHEK/SKmd8fvqnoZqVuEzn2pGeCTT4URIvsJZGOulvcqSzHiJ2dENNblOeoXZI6Ifw/rL3i1Zx4VkKI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446741; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=y+iZAgzaoiObj44pBZTJ06CwchhMM20VAZVaSA9mDmA=; b=Qkk2F1FHECahFbPDok6SGMpOzs7yBWec/Ye1mjsUUkTfhr7vWm3CIxW6jk+3dp+6KRT40+XEXAHlfqzsfQR61iHEhdNjULB7UphQUi3pL5oohGtvu8JaoU6gs+XpdZjBlEiYkvilKrvfj8GT9DKj/z4oJaZvFEmcpDgcDSRruRk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446741526664.5765188816576; Thu, 3 Sep 2026 07:45:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fB-0002pf-3g; Thu, 03 Sep 2026 10:43:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f8-0002mN-JL for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:34 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f6-00044o-AX for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:34 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-482e067e908so2162475f8f.2 for ; Thu, 03 Sep 2026 07:43:31 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446610; x=1789051410; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=y+iZAgzaoiObj44pBZTJ06CwchhMM20VAZVaSA9mDmA=; b=NmtPjQXNoAyZvawbQJyQ3rxsQdX8JN9j0vipAZhOkVX2Ugc6bUt2Kf1BX9IPeMoxPV /khp7eDvsL68y+qGKTOE4Unfi0pgVeIQrbkWvow3cPuZaY5CMB6jI+IE+Y5po7ybZQZv jPRr0FHph2PHRgGgTw3bZbn6F+clBarZpsI1Fh7X7mxGrzDEydfgYoWHjbkCsuod8RiV gLcdOUAuYtEV/nPo9J1dQjb3cqRjxrXc66WXdXuWs+aycl7i63YISKqZKR3Un/lBwhGz wZTg0yW7l0JUvF2VFwsH15oVswLN6nflxyMGHlaLjoDpthvTWbqs1350gI5ccuvt/hkX Puxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446610; x=1789051410; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=y+iZAgzaoiObj44pBZTJ06CwchhMM20VAZVaSA9mDmA=; b=i1VcQLbLip5ZTPs70cxyW5We90hmvYSsa++520vKTOC4PQ1nHo1gk7mDJR5EYDaCLi a0TYAWhXoGK6L/eK+JpjG4aHUuWWfARA7NOT/Nisfv3mADuZotfmXfj3kMUZ9TBmPkQA 6gLE4mVrd/kDIIUM2DbWaevKTJa847P/lRsJaXsB7umd8fuTw1tnYQOx0nlcmBvtjjid R5MULs6qbsDMRyCFhxixRCaMw0oUD5KiDA8p5KLkmMaA//wDvqU/xOxIJmz2Fxl5v4KT a0friMQluz3DjQ+9P/m/iT/t8FIOrXuD9mMyA8snmN3uFFTpkSgeRgrxpPX85jUlIbJA 9dnQ== X-Gm-Message-State: AFuF++l8kftizgpdwVguR6NUFHJJSg0AJm4H8mLuXIrYOpog9/HZ4uST nT0BKKNN2aBmPbk7+13cob+2GRz1k5TlerVTfxMpl4TkhM6Z8aKbj4wn00ZV4KS6Kkbg39FAnKY WQh0z X-Gm-Gg: AYBFou2wSQ9Y0StIngbphYj2YWKGpxKHB9r7r+3XNCk7h5GYLOVOCj+2iHXoUm1s+uZ eD4JHjZYdJ7D7QphEdJFggLh/jqx+ZU7sqP2opPTeExZsBRCs/rFahCHeQ5OQRX+04LQzzLc1eG vCW5ICtwkwpNWEKlHj2XsHY6/6FWMpPS8eGUMHYrN9Prka1LutstBTQkkBAlxYx/ruwdRHfP/H3 3dB1GkzQb+myYAxNALFPSzAUjqXQbb+keoC7CYONHDsYNwdNX/qPV8FMtbN+zNsfxlqumsRLHqY yqvU1i2lPnx3sYlP6xFHGrz6UxcMk2LbhNVWvbN5gaBWxXvud0hAdcOIC81dDc5ssVp5HEaZtER dQ4bbRof/yUnd8TLwPmuL6t15RD2SRVOqsF7mxYkA4jyMEBlj4xrSt1TrxE2wJM4eBmqoENl81n 8fwikLJfp+L9xvhlCO70h26wIa9iG+dP7x2UYgo7gclcKVPovt7ljje/a+ X-Received: by 2002:a05:6000:208a:b0:484:3311:3702 with SMTP id ffacd0b85a97d-48488f2205dmr21923319f8f.25.1788446610124; Thu, 03 Sep 2026 07:43:30 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 16/25] parallels: reject a bitmap L1 entry outside the data area Date: Thu, 3 Sep 2026 16:41:34 +0200 Message-ID: <20260903144143.2328870-17-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=den@openvz.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446742315158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Nothing checks where a bitmap L1 entry points. The entry is turned into an offset and the cluster is read from there, so the image decides which part of the file, if any, is deserialized as bitmap data. A short read on the protocol node is zero filled rather than refused, so an entry beyond the end of the file does not even fail: the bitmap quietly loads as completely clean. An entry below data_off deserializes the header and the BAT as bitmap data instead. Both cases used to be harmless in the sense that the extension was only parsed for read-only images, but the bitmap becomes writable and is stored back as authoritative once the image can be opened read-write. Bound the entry the way parallels_check_outside_image() bounds a BAT entry: it has to address the data area of the image file. The offset computation is bounded first, as the entry is a 64 bit value coming from the image and the shift by BDRV_SECTOR_BITS would overflow. The overflow case was reported as an I/O error before, so the test expectation changes along with it. Fixes: baefd977002e ("parallels: support bitmap extension for read-only mod= e") Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 30 ++++++++++++++++++- .../qemu-iotests/tests/parallels-read-bitmap | 23 +++++++++++--- .../tests/parallels-read-bitmap.out | 6 +++- 3 files changed, 53 insertions(+), 6 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 6a889d86fa..17445d183b 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -71,9 +71,17 @@ parallels_load_bitmap_data(BlockDriverState *bs, const u= int64_t *l1_table, int ret =3D 0; uint64_t offset, limit; uint64_t bm_size =3D bdrv_dirty_bitmap_size(bitmap); + int64_t file_size, data_start_off; uint8_t *buf =3D NULL; uint64_t i; =20 + file_size =3D bdrv_getlength(bs->file->bs); + if (file_size < 0) { + error_setg_errno(errp, -file_size, "Failed to get image file lengt= h"); + return file_size; + } + data_start_off =3D s->data_start << BDRV_SECTOR_BITS; + buf =3D qemu_try_blockalign(bs->file->bs, s->cluster_size); if (!buf) { error_setg(errp, "Failed to allocate a bitmap data cluster"); @@ -101,7 +109,27 @@ parallels_load_bitmap_data(BlockDriverState *bs, const= uint64_t *l1_table, if (entry =3D=3D 1) { bdrv_dirty_bitmap_deserialize_ones(bitmap, offset, count, fals= e); } else { - int64_t host_off =3D entry << BDRV_SECTOR_BITS; + int64_t host_off; + + if (entry > INT64_MAX / BDRV_SECTOR_SIZE) { + error_setg(errp, "Bitmap L1 entry %" PRIu64 " is out of ra= nge", + i); + ret =3D -EINVAL; + goto finish; + } + host_off =3D entry * BDRV_SECTOR_SIZE; + if (host_off < data_start_off) { + error_setg(errp, "Bitmap L1 entry %" PRIu64 " points befor= e " + "the data area of the image", i); + ret =3D -EINVAL; + goto finish; + } + if (host_off > file_size - (int64_t)s->cluster_size) { + error_setg(errp, "Bitmap L1 entry %" PRIu64 " points outsi= de " + "the image file", i); + ret =3D -EINVAL; + goto finish; + } =20 ret =3D bdrv_pread(bs->file, host_off, s->cluster_size, buf, 0= ); if (ret < 0) { diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-read-bitmap index 6990926d60..f5a1f33907 100755 --- a/tests/qemu-iotests/tests/parallels-read-bitmap +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -93,9 +93,10 @@ def extension(body, magic=3DEXT_MAGIC, checksum=3DTrue): return struct.pack(' (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446683560931.7950550683272; Thu, 3 Sep 2026 07:44:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fC-0002rc-Or; Thu, 03 Sep 2026 10:43:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f8-0002n3-U4 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:34 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f6-00045J-Uf for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:34 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-48584dc164fso416328f8f.0 for ; Thu, 03 Sep 2026 07:43:32 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446611; x=1789051411; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=IhBHv/IsAV3MCNTeGG0bhvIWIurVdnd2SebTco/6Ixo=; b=iGLoykumtWd8HxQtvCdZKoslAn8vBK2fVR4O8z02wap3GLvH1zcZZjjwVDNwvEWaeb Xh+qFdKD9v0xhXzGxsZAbydH8UNa8wPJOBn3ckuW4iDMXT9eKPMLPGOpAYuvwTd+fuk1 AEpeV5OWLCAjHrcIsa3+xSzDdYs8bhW9TTH3zMsUTNAVDwZBaV8tT3+dzjAj2U03vkIp pr+NYwkQnL4lvC3NsE0+mIg+/WQnHFZxx4jZge4N37o7goqRNQLM+NxTq8Xmq8qP3Aft G/atTHwOn8VlCgaUtCpC3veVsbTfuS9o3mBGqGdVuSHE7+0DFEZHO0vA4fGK3nifmfHO 7BuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446611; x=1789051411; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=IhBHv/IsAV3MCNTeGG0bhvIWIurVdnd2SebTco/6Ixo=; b=mzid3uid9C2Mw1IgWJmPc+T6NJxuUnBCqX+3VbGouPSrl6L+XtPYfGVnkXJBwORdqu mCgwxkm1AR9KPeI+8qyt7/uzK3CJarbV/K8m/vWs/dQPvmrMUaiaYiRoZUEyf8DRJDwp xaioFxkddu8ckg198ZSyeayUbSYJapjqa5XhZdGw43OqH/BoQ6AoM6RjiFXLMWRfVBYf KfjB9CIUTbkPy0MF6jqaWjo9bGYnPvN8o0y/veIo9PMpDJnU/nntrm/8bVqjqQswXeXa VQUFAD1gsYK7VSMnYJhuc5utUddEq8PjJZKs9H9z6z9jn4PgMABBWevCFdGhdfKCTGhd GMPg== X-Gm-Message-State: AFuF++kSXFoelUa56PT/jHYqbyfR00nBNDhHTW0Ihov5YnCCtwZOnz8D KnKDvmC9FifBAJIpPMIVEXzbvJDj4XymaHlgXUyZtIq0ngFBGdmuS55HodIyMWygcK48rZO4qgP b8B3h X-Gm-Gg: AYBFou1KDNq7VCTHngpPrflGTfKkX10Qs9KNBXofJCGPj/7B56SbSqTz3qT1AMHfhcG aPHqjRw6/Bl5nb/ygZO8E7bVWEHrUzzzTBz/51/2KgYmXDpQRvP3aFqkBtyF4Tsw17B/pbIGtLi 779KzB3yAN6wadgiN0whj/fhTaYfLGm1m3lqGiPmloFBS/JRYJuJqqJRsRIu9OF7Kn5KDjXALJ9 b01B7TQY4WsiL+2MVm9mfUxfODg5aRwENDBmk02UPG+uOWlo2IdoFBToP1A0WvfxCNY1GOchYA5 iL5oizK2EcIkf10Nd7QQEuymUUugDxh8OUV/nmCRBaXDJxbVi6OupPib24Jtus2vfuEF4GLJfkH psbr4O8NzSlUBZl99HX08zSl1xNrzY1F5dRwBNNA9/R5cjYS7pQX5HTyoOlbWNz4N55Aii8OexD 8JoXUTGnGunDJUJC8AMKTLdPCQA0byYjqD7RVaPsK0iMvNRJelNhVIPjcq X-Received: by 2002:adf:e00e:0:20b0:485:85f3:7e47 with SMTP id ffacd0b85a97d-48585f380a0mr1768336f8f.13.1788446611167; Thu, 03 Sep 2026 07:43:31 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 17/25] parallels: do not trust the bitmaps of an image which was not closed Date: Thu, 3 Sep 2026 16:41:35 +0200 Message-ID: <20260903144143.2328870-18-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=den@openvz.org; helo=mail-wr1-x42f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446685824158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev The inuse magic in the header says that the image was not closed correctly. The bitmaps stored in the Format Extension are then stale by definition: they were written by the last inactivation, and every write which happened after it is missing from them. Nothing said so, the bitmaps were loaded and handed out as valid, and an incremental backup taken from one of them would silently miss the data written after the last clean close. Mark them inconsistent, as qcow2 does for a bitmap whose in-use flag survived a crash. Using such a bitmap fails with an error naming it, so the loss is reported to whoever tries to rely on it instead of being discovered later in a backup. parallels_save_bitmap() already skips an inconsistent bitmap, so it is not written back. The format has no per bitmap flag to record that the contents are unusable, so keeping it would present it as valid again on the next open. Say what happens, as the bitmap disappears from the image and 'qemu-img bitmap --remove' would report it as missing afterwards. The image data itself is unaffected: it is repaired at open as before, and only the bitmaps are dropped. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 13 +++++++++-- tests/qemu-iotests/tests/parallels-checks | 23 +++++++++++++++++++ tests/qemu-iotests/tests/parallels-checks.out | 15 ++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 17445d183b..b7fac2514a 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -335,6 +335,9 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, goto fail; } bdrv_dirty_bitmap_set_persistence(bitmap, true); + if (s->header_unclean) { + bdrv_dirty_bitmap_set_inconsistent(bitmap); + } bitmaps =3D g_slist_append(bitmaps, bitmap); break; =20 @@ -417,8 +420,14 @@ static int GRAPH_RDLOCK parallels_save_bitmap(BlockDri= verState *bs, QemuUUID uuid; int ret =3D 0; =20 - if (!bdrv_dirty_bitmap_get_persistence(bitmap) || - bdrv_dirty_bitmap_inconsistent(bitmap)) { + if (!bdrv_dirty_bitmap_get_persistence(bitmap)) { + return 0; + } + + /* The format has no way to mark a stored bitmap unusable */ + if (bdrv_dirty_bitmap_inconsistent(bitmap)) { + warn_report("Dropping inconsistent bitmap %s", + bdrv_dirty_bitmap_name(bitmap)); return 0; } =20 diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index 6f60fda62b..575b736e35 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -414,6 +414,29 @@ _check_test_img # Clear image _make_test_img $SIZE =20 +echo "=3D=3D TEST BITMAP OF AN IMAGE WHICH WAS NOT CLOSED =3D=3D" + +INUSE_OFFSET=3D44 + +echo "=3D=3D add a persistent dirty bitmap and dirty it =3D=3D" +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_testd= ir +{ $QEMU_IO -c "write -P 0x11 0 65536" "$TEST_IMG"; } 2>&1 | _filter_qemu_i= o | _filter_testdir + +echo "=3D=3D pretend the image was not closed correctly =3D=3D" +poke_file "$TEST_IMG" "$INUSE_OFFSET" "\x59\x6e\x6f\x74" + +echo "=3D=3D the bitmap is stale, so it can not be used and is dropped =3D= =3D" +$QEMU_IMG bitmap --clear -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_tes= tdir + +echo "=3D=3D the name is free again =3D=3D" +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_testd= ir + +echo "=3D=3D guest data was never in doubt =3D=3D" +{ $QEMU_IO -r -c "read -P 0x11 0 65536" "$TEST_IMG"; } 2>&1 | _filter_qemu= _io | _filter_testdir + +# Clear image +_make_test_img $SIZE + echo "=3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D" =20 echo "=3D=3D write two clusters =3D=3D" diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index d40f865868..f390ea90d4 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -268,6 +268,21 @@ read 65536/65536 bytes at offset 0 file size: 2097152 No errors were found on the image. Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D TEST BITMAP OF AN IMAGE WHICH WAS NOT CLOSED =3D=3D +=3D=3D add a persistent dirty bitmap and dirty it =3D=3D +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D pretend the image was not closed correctly =3D=3D +=3D=3D the bitmap is stale, so it can not be used and is dropped =3D=3D +Repairing image was not closed correctly +qemu-img: Operation clear on bitmap b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 f= ailed: Bitmap 'b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45' is inconsistent and ca= nnot be used +Try block-dirty-bitmap-remove to delete this bitmap from disk +qemu-img: warning: Dropping inconsistent bitmap b2c9e1a4-5d3f-4e8b-9a7c-6f= 0d1e2b3a45 +=3D=3D the name is free again =3D=3D +=3D=3D guest data was never in doubt =3D=3D +read 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 =3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D =3D=3D write two clusters =3D=3D wrote 1048576/1048576 bytes at offset 0 --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446830; cv=none; d=zohomail.com; s=zohoarc; b=AGeUfnmDQk8crMbvqBhCNLYm3jXiGbWdySyl7UZdkdhQt0PMZ0ZY1fJWwYpspE+tO+Pvh7Yo59jsTxhAfU2F+GXEzgLISjiAh04CbTvD0gaR/tXMvKCBBv9bTU/UhxCyooFtIkTijdNN6ibgiIgxG5qZVvWIKersojwEOoAILyI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446830; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=JT9O3uxdl/4u+w7L1goAbIpPRjFt3fljeh9+YaQRlKg=; b=Dp68SMBfzOWNNqJk3Z0lHYVkmpQaTwOdmkxmkEwWv2rvZT9oggLAEXTz9v+JfOoFz7HRmdj+aGBQsetRr1sAfAh/er6DWbfySJxFZSurWSQzKi7qGsod++PSI2rvgDLejBZP+NDBJf2+AGuXEZ74pw5XUC5nGJ4PjbqULsz115U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446830399287.51884593258626; Thu, 3 Sep 2026 07:47:10 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fD-0002sM-Fa; Thu, 03 Sep 2026 10:43:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28f9-0002oU-Qi for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:35 -0400 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f7-000460-Na for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:35 -0400 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-495437bb891so9081905e9.1 for ; Thu, 03 Sep 2026 07:43:33 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446612; x=1789051412; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=JT9O3uxdl/4u+w7L1goAbIpPRjFt3fljeh9+YaQRlKg=; b=Ye4LjipiAlxU/7HJLW95qJIIBzAmDlungSAZRZ6suSJ3pyiL4nkGVGR2/+AJzsLt3m IHOPXfq9KUMkMNwholg3xoNEj7LtJz5PrOJgNz22SgIwTzUjyn/lJ71vVWWlILN5MdGt PD2K5ppUb0k/ORvy2nFqQq77yIxi3G7wNmBArq1YZREaN5ArV3fTISkdBeh+8JlZu9Tz di6jC/BCpWFDdMnZrNKnBkfnOOnSzdICyFCZBx2PtkOwRRA4g4iWKJwYfowG8rmd6h0j lTOER97G4+/g29G2DWQiOocvNwrcM5Brj2vVx8QytJTKaEQ84+oWzcSS/svq9oFFbCTM HuBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446612; x=1789051412; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=JT9O3uxdl/4u+w7L1goAbIpPRjFt3fljeh9+YaQRlKg=; b=BQaTnIoT/Trb/EhB0nhwgEs+hrHCYEww1HhixWbrRIDSz4dXnGrFJKN4gGZiJT22Ni GQjlRK+oYD7LsY8G3+7l5MjbbO1RXQ3RdokXflE5MH+0BMAasmfrWkjFhgupkOjaa2xK tv71jOxn+Kqk3klNDV6kEeVhfEq6WgDZwa8/EtU4VbBWkhZU9/Ng/ZXfsJTvWG3ofsME Alqxxuq3jjk5WbWi5Elk7HKSbuDjk/EhQta8MmLvJD+zBMfyatgDlOjxiURcH8P7vUaM DkgEwRxde269ZObVyalm7ZZVJOvx8KoSLWdsMuEwZ2WPlSgo441Uzbcen1JDZlFZ2Lmo DgVQ== X-Gm-Message-State: AFuF++lTaYy01p3goRhjGiW8f2XW3rBdwT54GFEPHJSIwIB3UdzbVebA jNGuF1FB+zflnie372jcVUUQ/db1GpU6Yk4h7pTdNU/IcJcYq69sjNNcaDey3IzrSKOG+CvKb5/ 6PRTS X-Gm-Gg: AYBFou2Rq/M7TG1p3sSguJ6EFiCHwXwTOJxNG6YkwOoSkOGe3MO30smfj33aDOOgU03 EMzjAs4nWd0tfwZhg9uq2kIfbaY+jsA1Z5LVbf7qI87195iY1EN6ZRfquMLhKM3ikEMhMmPzWYW erOJtP4GkbEhQkdwZsqkkhkAgFQsNVUe4AXtcDjcDfR+6jz+Ej3rj1LGT+SDBcWoQN96S4LXSUt JW1Hqp7yVN6hmXrtTY1SxMlKLy0i5lIhpIaMwzQKOb/jxWuTxtMHCSLw4Li6qq/bXkON1Q4i87N 6ZKk10EZ08SrbHavN/fUjt8Gs1BtzB/uJ+9Lyf38kXqZNLu4SaDLJtfaBgXyAgDAWs67XeF0WxB dw3hNm8noz8KG+4ofaepvVauGsioGj7Vb/QIWLEz8yblzBdlU5tsK4nFNuVRu+/wEM+Ug36RbhU 7UxaWQ72F/FqS0KIbYi+hE9WW+ylBsyrP6fs7v/L3TK8eR9IRUxOKz/LUA7U7ZzTIbpdPh X-Received: by 2002:a05:600c:8608:b0:49b:920b:5704 with SMTP id 5b1f17b1804b1-49cee5b75cbmr58458585e9.3.1788446612153; Thu, 03 Sep 2026 07:43:32 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 18/25] parallels: implement removing a stored dirty bitmap Date: Thu, 3 Sep 2026 16:41:36 +0200 Message-ID: <20260903144143.2328870-19-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::335; envelope-from=den@openvz.org; helo=mail-wm1-x335.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446832890158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev block-dirty-bitmap-remove leaves a parallels image alone. The driver has no bdrv_co_remove_persistent_dirty_bitmap(), and a missing handler means nothing to do, so the command reports success while the bitmap stays in the image until the node is inactivated. qcow2 updates its bitmap directory on the spot. Implement the handler. The Format Extension is written as a whole rather than edited in place, so the bitmap is dropped by clearing its persistence and storing what is left, and the header is updated to point at the new extension. Releasing the bitmap itself is up to the caller. The store runs under s->lock, as it allocates a cluster and a request can be in flight, unlike the inactivation path where the node is quiesced already. Removing a bitmap which was never stored is not an error, as bdrv_co_remove_persistent_dirty_bitmap() spells out, so a name which is not there, or is not persistent, is answered with success and no write. Write access is checked first. The extension is only rewritten while the node is writable, so on a read-only or an inactive node the request could not reach the image at all and reporting success would be a lie. The generic BDRV_BITMAP_RO check in block_dirty_bitmap_remove() hides this for a read-only node, but it does not cover an inactive one, and dropping a bitmap which was never stored needs no write access at all. Persistence is only dropped for the duration of the rewrite, so it goes back on when the rewrite fails. The bitmap is still in the image, and a bitmap which is no longer marked persistent would be dropped for good by the next inactivation, turning a removal the caller was told had failed into one which silently succeeded. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 47 +++++++++++++++++++++++++++++++++++++++++++ block/parallels.c | 4 +++- block/parallels.h | 4 ++++ 3 files changed, 54 insertions(+), 1 deletion(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index b7fac2514a..f687f2da7c 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -689,3 +689,50 @@ bool coroutine_fn parallels_co_can_store_new_dirty_bit= map(BlockDriverState *bs, =20 return true; } + +int coroutine_fn +parallels_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, + const char *name, Error **errp) +{ + BDRVParallelsState *s =3D bs->opaque; + BdrvDirtyBitmap *bitmap; + Error *err =3D NULL; + int ret; + + if (bdrv_is_read_only(bs) || (bdrv_get_flags(bs) & BDRV_O_INACTIVE)) { + error_setg(errp, "Cannot remove persistent bitmap '%s': no write " + "access to node '%s'", name, bdrv_get_node_name(bs)); + return -EACCES; + } + + bitmap =3D bdrv_find_dirty_bitmap(bs, name); + if (bitmap =3D=3D NULL || !bdrv_dirty_bitmap_get_persistence(bitmap)) { + return 0; + } + + /* The extension is written as a whole, so drop it from what goes in */ + bdrv_dirty_bitmap_set_persistence(bitmap, false); + + ret =3D 0; + WITH_QEMU_LOCK_GUARD(&s->lock) { + parallels_store_persistent_dirty_bitmaps(bs, &err); + if (err !=3D NULL) { + error_propagate(errp, err); + ret =3D -EIO; + break; + } + + ret =3D parallels_update_header(bs); + if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to update the image heade= r"); + break; + } + } + + if (ret < 0) { + /* Nothing was removed, so the bitmap is as persistent as it was */ + bdrv_dirty_bitmap_set_persistence(bitmap, true); + } + + return ret; +} diff --git a/block/parallels.c b/block/parallels.c index 90b7f7c8de..2a5ceb8978 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1288,7 +1288,7 @@ static int parallels_probe(const uint8_t *buf, int bu= f_size, return 0; } =20 -static int GRAPH_RDLOCK parallels_update_header(BlockDriverState *bs) +int GRAPH_RDLOCK parallels_update_header(BlockDriverState *bs) { BDRVParallelsState *s =3D bs->opaque; unsigned size =3D MAX(bdrv_opt_mem_align(bs->file->bs), @@ -1651,6 +1651,8 @@ static BlockDriver bdrv_parallels =3D { .bdrv_inactivate =3D parallels_inactivate, .bdrv_co_can_store_new_dirty_bitmap =3D parallels_co_can_store_new_dirty_bitmap, + .bdrv_co_remove_persistent_dirty_bitmap =3D + parallels_co_remove_persistent_dirty_bit= map, }; =20 static void bdrv_parallels_init(void) diff --git a/block/parallels.h b/block/parallels.h index 4684ba2890..27d8c3ac83 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -98,6 +98,7 @@ int parallels_mark_unused(BlockDriverState *bs, unsigned = long *bitmap, =20 int64_t GRAPH_RDLOCK parallels_allocate_host_clusters(BlockDriverState *bs, int64_t *clusters); +int GRAPH_RDLOCK parallels_update_header(BlockDriverState *bs); =20 int GRAPH_RDLOCK parallels_read_format_extension(BlockDriverState *bs, int64_t ext_off, @@ -107,5 +108,8 @@ parallels_store_persistent_dirty_bitmaps(BlockDriverSta= te *bs, Error **errp); bool coroutine_fn GRAPH_RDLOCK parallels_co_can_store_new_dirty_bitmap(BlockDriverState *bs, const char *= name, uint32_t granularity, Error **errp= ); +int coroutine_fn GRAPH_RDLOCK +parallels_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, + const char *name, Error **errp= ); =20 #endif --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446832; cv=none; d=zohomail.com; s=zohoarc; b=Dbrs7lyLlhRWxCkhTvFNEOOmi0zEjHqiV92ED6fuJpst8hl5hY4TKuvyw70uY8FDvPySqolovOqeGE5ENVSHov6nxTddpsCrBOTUX9RXyMpOi1LSjtrDRA6Q7LmeZ1dzmL0he3kWChg17fZNpRjU27U04Y/mq5kUNCYlDOtPs5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446832; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pypRYc8/MXO/3Of6gj2N/hRoWJoad4/u2unBbe1Pxck=; b=klp/w0l4fR2Pmozh9axf6twTOlkErHSsMw5UZL0Qv9EAAcZDY69zyo52hqhArCQoamfVx/Tv8KBXvx+up/TD2lPNjr4rhRDN+GdIPlfGymWGhoIPfJrXSUvpJYidtlrzqiF2Va+UA8B+cl/NNS+FtIGqr+KFJyNyuTMVKwbpUL8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446832713924.9181412879801; Thu, 3 Sep 2026 07:47:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fE-0002t4-2Q; Thu, 03 Sep 2026 10:43:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28fB-0002q5-OT for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:37 -0400 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f9-00046O-CC for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:37 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49b9320423cso25048235e9.0 for ; Thu, 03 Sep 2026 07:43:34 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446613; x=1789051413; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pypRYc8/MXO/3Of6gj2N/hRoWJoad4/u2unBbe1Pxck=; b=kzclihgMedgJNifBMd9A9RY0DOEizvejJlbtR0mPpNU/F/8YeyhXPE1vIIVYWOzSiz Fwk2vMBQeoL1lQ9R9V4gnpx6Msr3SmkrgfGKA+xwkvcC2XIDc7s7FBtZwtmGzNNICoZY +PWe9pAqfqUZ7p+c17VX9aVP3jo//4dQ9nzw+hIb4DH6a3fdHrEMSchhaFYz/EFh05kV gZ+SaHt833fSHuFLV2Sglw3hZThWUwGSm0G4gccEOt2I4kxvyS3p4rRb4DcXpOhQosz7 Srlw6/sOyVSCzewePSdV6V0fSHrECl9BXCmfsyuwWetGT4XFRWrx7sNNZuolvsASdXFb luaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446613; x=1789051413; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=pypRYc8/MXO/3Of6gj2N/hRoWJoad4/u2unBbe1Pxck=; b=Rxq1HwveUwDFcqddG+XyjHt+0tg3I+TUJZZkAzLdzy/2JDp60w/aBiIKerzJofPaVr AryWulDbDBwVCKdZET5rL8mhKq5ZgdGMHC7KTmRZBJkRJQITGIW2hanVt+lmrAcj55SX U7t7t00Z+UPW7j0vn93oTuH8efCd+/HhVPf42lnr66oZEJt7GOtfKmTxTYe7puybY4Ks AfFW9vORLovsmnSJBmKLbIIqrDCLAJxt2vGSb81YcbkSR1cq1YCcyUCG6RhY6tHG9jci SKas9Dt2NZh6AGl/qk2PLmnOSHLROROlbTcGJoM4hjOXOK950naCBOf48KiGKjZoI6HC VNkA== X-Gm-Message-State: AFuF++maUfjGyGber8vXUKRfcbs29oF4LPiZN/HJNHH5q3unXvhQ/Qyu G8U2/9MHyUcs1MbJeoub99NitgOTc8VYo+EluVoO3xCJkXwJCXOISJpenOby6oaRBCHw4uK4tYx ToPYz X-Gm-Gg: AYBFou1+fn5R+jP4WOZmiIGavzKs4rEGYBURFWrM+Abiim3bsO6g2x0vkOPdm81O00G dEmMd0WFWqOCG50ICUz9GZF1VAE0NHDaoyhXwg9AFRp0kkX3NdEfzpGpP9eVfqkHOx5lrLZel7i moRewhX8svvkY58ZsLSjg38SeSWMK0w8/h3ZZvU2Pc8UNyuoA5tPlSI02ArlXNm0WvQAFSEat67 y83sN3ZebeV+b0adoPOj7J++MKA/ZgO4ECFHpYcL4MCCBehZkk88jvk1tAyIA+I76f0wTguAahO jIAzO9yFPWLhRY0oZkZ5u3p98o+S5lqda5QPLk7VA1+2oo9b/7dbZ46j3rC64YgB3Ck4ve9bXTz T2swZvFlC4BbyrENmm0lkC8MWB5MePWsbwuu3aSwFHaGWsE4zpiIpKOdApbwRgUIAe6z+0Uq5vk PHyNn7M2CEjF5rAhhSbmB8Ph1pwPj967m5pm/i/52NfXXtyDox1Jw15ij6 X-Received: by 2002:a05:600c:83c8:b0:49c:d52e:d0ea with SMTP id 5b1f17b1804b1-49ce581779dmr242705875e9.4.1788446613338; Thu, 03 Sep 2026 07:43:33 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Eric Blake , Markus Armbruster Subject: [PATCH v7 19/25] parallels: report the stored dirty bitmaps in qemu-img info Date: Thu, 3 Sep 2026 16:41:37 +0200 Message-ID: <20260903144143.2328870-20-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32c; envelope-from=den@openvz.org; helo=mail-wm1-x32c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446834888158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Nothing tells which persistent bitmaps an image carries. qemu-img info says nothing about them, and the only other way to see one is to export the image over NBD and ask for a bitmap by name, which needs the name beforehand. Add ImageInfoSpecificParallels with the bitmaps and their granularity, in the same way as qcow2 reports the contents of its bitmap directory: Format specific information: bitmaps: [0]: name: b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 granularity: 65536 For running VM process the list is built on the fly from in-memory list. This is the best we can do. FormatExtension could be dead in the image while VMs are running as all bitmaps are cleared on non-clean VM stop. A bitmap of an image which was not closed correctly is inconsistent and can not be used. Report that as well, the way qcow2 reports its in-use flag, so such a bitmap is not listed as a valid one. The section is left empty for an image with no persistent dirty bitmaps, and an empty section is not printed, so the human readable output of "qemu-img info" and "info block" is unchanged. Cc: Stefan Hajnoczi Cc: Eric Blake Cc: Markus Armbruster Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 26 +++++++++++ block/parallels.c | 20 ++++++++ block/parallels.h | 3 ++ qapi/block-core.json | 46 ++++++++++++++++++- tests/qemu-iotests/tests/parallels-checks | 6 +++ tests/qemu-iotests/tests/parallels-checks.out | 19 ++++++++ 6 files changed, 118 insertions(+), 2 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index f687f2da7c..8b8035af91 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -736,3 +736,29 @@ parallels_co_remove_persistent_dirty_bitmap(BlockDrive= rState *bs, =20 return ret; } + +void parallels_get_bitmap_info_list(BlockDriverState *bs, + ParallelsBitmapInfoList **info_list) +{ + BdrvDirtyBitmap *bitmap; + ParallelsBitmapInfoList **tail =3D info_list; + + *info_list =3D NULL; + + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { + ParallelsBitmapInfo *info; + + if (!bdrv_dirty_bitmap_get_persistence(bitmap)) { + continue; + } + + info =3D g_new0(ParallelsBitmapInfo, 1); + info->name =3D g_strdup(bdrv_dirty_bitmap_name(bitmap)); + info->granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + if (bdrv_dirty_bitmap_inconsistent(bitmap)) { + info->has_inconsistent =3D true; + info->inconsistent =3D true; + } + QAPI_LIST_APPEND(tail, info); + } +} diff --git a/block/parallels.c b/block/parallels.c index 2a5ceb8978..e7d65d0458 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1624,6 +1624,25 @@ static bool parallels_is_support_dirty_bitmaps(Block= DriverState *bs) return 1; } =20 +static ImageInfoSpecific * GRAPH_RDLOCK +parallels_get_specific_info(BlockDriverState *bs, Error **errp) +{ + ImageInfoSpecificParallels *parallels_info; + ImageInfoSpecific *spec_info; + + parallels_info =3D g_new0(ImageInfoSpecificParallels, 1); + parallels_get_bitmap_info_list(bs, ¶llels_info->bitmaps); + parallels_info->has_bitmaps =3D !!parallels_info->bitmaps; + + spec_info =3D g_new(ImageInfoSpecific, 1); + *spec_info =3D (ImageInfoSpecific){ + .type =3D IMAGE_INFO_SPECIFIC_KIND_PARALLELS, + .u.parallels.data =3D parallels_info, + }; + + return spec_info; +} + static BlockDriver bdrv_parallels =3D { .format_name =3D "parallels", .instance_size =3D sizeof(BDRVParallelsState), @@ -1653,6 +1672,7 @@ static BlockDriver bdrv_parallels =3D { parallels_co_can_store_new_dirty_bitmap, .bdrv_co_remove_persistent_dirty_bitmap =3D parallels_co_remove_persistent_dirty_bit= map, + .bdrv_get_specific_info =3D parallels_get_specific_info, }; =20 static void bdrv_parallels_init(void) diff --git a/block/parallels.h b/block/parallels.h index 27d8c3ac83..012f47320b 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -32,6 +32,7 @@ #ifndef BLOCK_PARALLELS_H #define BLOCK_PARALLELS_H #include "qemu/coroutine.h" +#include "qapi/qapi-types-block-core.h" =20 #define HEADS_NUMBER 16 #define SEC_IN_CYL 32 @@ -111,5 +112,7 @@ parallels_co_can_store_new_dirty_bitmap(BlockDriverStat= e *bs, const char *name, int coroutine_fn GRAPH_RDLOCK parallels_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name, Error **errp= ); +void parallels_get_bitmap_info_list(BlockDriverState *bs, + ParallelsBitmapInfoList **info_list); =20 #endif diff --git a/qapi/block-core.json b/qapi/block-core.json index 199efc1e00..7499aea641 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -188,6 +188,35 @@ '*extent-size-hint': 'size' } } =20 +## +# @ParallelsBitmapInfo: +# +# Parallels dirty bitmap information. +# +# @name: the name of the bitmap +# +# @granularity: granularity of the bitmap in bytes +# +# @inconsistent: true if the bitmap was improperly stored and cannot +# be used +# +# Since: 11.2 +## +{ 'struct': 'ParallelsBitmapInfo', + 'data': { 'name': 'str', 'granularity': 'uint32', + '*inconsistent': 'bool' } } + +## +# @ImageInfoSpecificParallels: +# +# @bitmaps: A list of the persistent dirty bitmaps of the image, +# including the ones which are not written out yet +# +# Since: 11.2 +## +{ 'struct': 'ImageInfoSpecificParallels', + 'data': { '*bitmaps': ['ParallelsBitmapInfo'] } } + ## # @ImageInfoSpecificKind: # @@ -197,10 +226,12 @@ # # @file: Since 8.0 # +# @parallels: Since 11.2 +# # Since: 1.7 ## { 'enum': 'ImageInfoSpecificKind', - 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd', 'file' ] } + 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd', 'file', 'parallels' ] } =20 ## # @ImageInfoSpecificQCow2Wrapper: @@ -255,6 +286,16 @@ { 'struct': 'ImageInfoSpecificFileWrapper', 'data': { 'data': 'ImageInfoSpecificFile' } } =20 +## +# @ImageInfoSpecificParallelsWrapper: +# +# @data: image information specific to Parallels +# +# Since: 11.2 +## +{ 'struct': 'ImageInfoSpecificParallelsWrapper', + 'data': { 'data': 'ImageInfoSpecificParallels' } } + ## # @ImageInfoSpecific: # @@ -273,7 +314,8 @@ 'vmdk': 'ImageInfoSpecificVmdkWrapper', 'luks': 'ImageInfoSpecificLUKSWrapper', 'rbd': 'ImageInfoSpecificRbdWrapper', - 'file': 'ImageInfoSpecificFileWrapper' + 'file': 'ImageInfoSpecificFileWrapper', + 'parallels': 'ImageInfoSpecificParallelsWrapper' } } =20 ## diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index 575b736e35..84eb526f44 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -382,6 +382,9 @@ echo "=3D=3D dirty a single granule of the bitmap =3D= =3D" file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` echo "file size: $file_size" =20 +echo "=3D=3D the bitmap is reported by qemu-img info =3D=3D" +_img_info --format-specific + echo "=3D=3D the extension and its bitmap data are not a leak =3D=3D" _check_test_img =20 @@ -425,6 +428,9 @@ $QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2= >&1 | _filter_testdir echo "=3D=3D pretend the image was not closed correctly =3D=3D" poke_file "$TEST_IMG" "$INUSE_OFFSET" "\x59\x6e\x6f\x74" =20 +echo "=3D=3D a read-only open still reports it, marked inconsistent =3D=3D" +_img_info --format-specific + echo "=3D=3D the bitmap is stale, so it can not be used and is dropped =3D= =3D" $QEMU_IMG bitmap --clear -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_tes= tdir =20 diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index f390ea90d4..c6d9445440 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -241,6 +241,15 @@ qemu-img: Operation add on bitmap bitmap0 failed: Bitm= ap name must be a UUID to wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) file size: 4194304 +=3D=3D the bitmap is reported by qemu-img info =3D=3D +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 4 MiB (4194304 bytes) +Format specific information: + bitmaps: + [0]: + name: b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 + granularity: 65536 =3D=3D the extension and its bitmap data are not a leak =3D=3D No errors were found on the image. =3D=3D extend image by 1 cluster =3D=3D @@ -273,6 +282,16 @@ Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D41= 94304 wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) =3D=3D pretend the image was not closed correctly =3D=3D +=3D=3D a read-only open still reports it, marked inconsistent =3D=3D +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 4 MiB (4194304 bytes) +Format specific information: + bitmaps: + [0]: + name: b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 + granularity: 65536 + inconsistent: true =3D=3D the bitmap is stale, so it can not be used and is dropped =3D=3D Repairing image was not closed correctly qemu-img: Operation clear on bitmap b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 f= ailed: Bitmap 'b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45' is inconsistent and ca= nnot be used --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446765; cv=none; d=zohomail.com; s=zohoarc; b=l8F2Nl4LvPrh0+v+bb/g0t2BxzLNFKbTe9ClNtUySJmnr5D5KRJ3VBI3JZVBQhvjOtq1AJyt5FUj1XmXbCuRiGEFskggQqsm8PsNs7ZFfGtE16zbYU99r65EC0vXLp9GB2m0H6CZJldd3oHfXD0WB0c1xWykfUC2bgRfgyK96/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446765; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=lQw6tClcEuh8wmhjZmi7xrA9dHVcRR/JsHSDd6qTuHg=; b=nzI/mZqV3vyVwXl7h+S01lzQ2NbAUWzzSjsBg1I3SxGoCfcm4PKqZxuBB+Zpa+5eSdrvmw7FxTQVvfcXX1m8jq5jSvW5VMxjH+ZJiO4B2cY/yajozY1d0gWGGnk69QT/2D10b5ClH0XbJVetYH+yrGUuo1uerw59BYeWI1QBXA4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446765855692.6291950060968; Thu, 3 Sep 2026 07:46:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fD-0002sp-U1; Thu, 03 Sep 2026 10:43:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28fC-0002qt-AF for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:38 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28f9-00046z-Vs for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:38 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-4843f205a5bso1743272f8f.1 for ; Thu, 03 Sep 2026 07:43:35 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446614; x=1789051414; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lQw6tClcEuh8wmhjZmi7xrA9dHVcRR/JsHSDd6qTuHg=; b=lpsW3XLqi28xzP1bKMn3J+NLOc1lc6kbFpLG4b8bfvDol9sni+suB5ZKM9YyAN1/wD SnIez3Y1PSEPAssr4lV1cDbiQZtnoL7ZljxIjbMckJeIeUbseT5lv9eP6An0EW5T/aaX Ql8obEW7KKRYdVDA0ZnAmXP5rkSDlR2Enoq73pxqpnd8rmRXaiyZUGGHk6n/9Jj2Bumc rmGjojbTo9fKiWCStsG6fnBEZv3Mq+DBsI8kOlsfB/QKppHpoC67RnUOP0nbDfBzqv/M 6eeFor7vnPxSCdOfpvZthPP6u0CkYRJZS106fw7U74ciGR1ebKmReiKH5Ruiess+6ZXt tL0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446614; x=1789051414; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=lQw6tClcEuh8wmhjZmi7xrA9dHVcRR/JsHSDd6qTuHg=; b=jlQFencGQSbwQPZotQfpww8wDI1N07yFkXpAx8r8cnFkYqf48HNk3Io0lUbnd+bzh0 UG1HD7p1RcJc2dl5R6Rq5uoBHpCcUNs8roq/1AFeCAWfc1h7Co+DQyHH2brGOTPEO1ia m9qk4jGqAlDadQ2fzOPCssCfaODsyJNuRxR+j/Tpyl2/tyqZNr/CpPAjoV7RF6UfQUy8 aXls0SwPHGwJUUNYs7Rc0Km49zAqqm68RkBUxnDh87pSeZ8aFI29ZEsMMAwTS+XWDJSl tVBlpfgcWhc2mxoKEmDX2yxMdDUiVnsaGAQIPEatcw+XpqOWuR71rYS0K3pjTK+L7ziI wSuw== X-Gm-Message-State: AFuF++kfyUxDuFU1lW6G951fe1cXY+CZB4hLB/pYsdIdxJ3J3j/fOHDg o54jVlIIYo3n7kKUzAMPhzgTu6s5etRqZ1sLBCPp+dBAwMx9NJ9l6WdXUoZOhkWnpoKInGmTlJN HRaSm X-Gm-Gg: AYBFou2liT9AxZyIqQowWQkgvgHwOm7Zvu4QuWMUxfIldjoOxeWoRbdRXrltsDrgBZ6 xWwsf/Ajp/HFphV4cyYJKuds1fU5orXYmXKywk2Spv8edqzturF1cglxVs8gVB4NGI455M0hS63 +jHDeKN9JuuLcpojH3yGTQSjUOrN7+8xJZNulhmdY/2rGjsQPyxPHEQBheLt+lPD2Sfn+zGu8SW yHgAQM6KwHiYZd9htqK630nkZk5/SoDGmiGZCfkKsy2x8LCVUywPfiuznC3ec92+KnCOWHrAsRe nc0W2MwXOh8qLMuujCh3LEuXAoc41RjFGl8WAU+gmrefrqaRMUbb3rFIm/srWLx3/cDNd+RZ5yJ RxyH0kOEfxliTa9eOJzQg2VXX+lDcG2sSejIQDNGHg4o3zorBcAkchuChZXLuVPXHQSYNL2UITV thPfRr3DrrgY4n98WL/s+sleHdtY7lQO4SOAS8bvCFC+a1EK41vWX8auoYgvFLgglTQiE= X-Received: by 2002:a05:6000:420b:b0:45e:e1a4:c4c3 with SMTP id ffacd0b85a97d-48488f20a4cmr19977599f8f.15.1788446614384; Thu, 03 Sep 2026 07:43:34 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 20/25] iotests: rename parallels-read-bitmap to parallels-bitmap Date: Thu, 3 Sep 2026 16:41:38 +0200 Message-ID: <20260903144143.2328870-21-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=den@openvz.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446766282158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev The test is about to cover storing a bitmap as well, so its name stops being accurate. Rename it on its own, as the patch which changes what a test does should not be the one which moves it. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- .../tests/{parallels-read-bitmap =3D> parallels-bitmap} | 2 +- .../tests/{parallels-read-bitmap.out =3D> parallels-bitmap.out} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename tests/qemu-iotests/tests/{parallels-read-bitmap =3D> parallels-bitm= ap} (99%) rename tests/qemu-iotests/tests/{parallels-read-bitmap.out =3D> parallels-= bitmap.out} (100%) diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-bitmap similarity index 99% rename from tests/qemu-iotests/tests/parallels-read-bitmap rename to tests/qemu-iotests/tests/parallels-bitmap index f5a1f33907..814b56b32c 100755 --- a/tests/qemu-iotests/tests/parallels-read-bitmap +++ b/tests/qemu-iotests/tests/parallels-bitmap @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # -# Test parallels load bitmap +# Test parallels dirty bitmaps # # Copyright (c) 2021 Virtuozzo International GmbH. # diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap.out b/tests/qem= u-iotests/tests/parallels-bitmap.out similarity index 100% rename from tests/qemu-iotests/tests/parallels-read-bitmap.out rename to tests/qemu-iotests/tests/parallels-bitmap.out --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446829; cv=none; d=zohomail.com; s=zohoarc; b=JFX0PQv+bDRLnTTKFdWvTzsotGy5kPs8nt1DrorEH1nu1HgfUYZJ8efFhekdlZwc6KO5LQiOcbJkl4wiXSog2jqMGgeTAqIs/XS3C7hrYWY/ZNvmuJOfDbw3H8NIMiFPVPAUcZzjKLBlKJWr7qHGCUG+tge0G8IswsNsQoyqW/Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446829; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=CrNy0DGUAMNQACpRIKae6EFwhUPs4CrGUyns6CD/7LI=; b=SSEGpzwPX27C48K3wvLGvUUwTxdFbZPFD7ZiRw0FOYnOSEQir3W2VGrnKJwjBJIwWk0nD7nb289jgK+UIo8vKAa1LjgjeWcohZ2xzNmFiyLw001KiuLhD49dZgXU1dlTM3pewtfkAeUMQ16tw/ixQt8DC2jBRgiXQd9zE+6KL4g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446829905352.20850786098515; Thu, 3 Sep 2026 07:47:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fH-0002wJ-7b; Thu, 03 Sep 2026 10:43:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28fF-0002uy-Jb for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:41 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28fC-00047s-5N for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:41 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-482dd6ee390so2333996f8f.3 for ; Thu, 03 Sep 2026 07:43:37 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446617; x=1789051417; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=CrNy0DGUAMNQACpRIKae6EFwhUPs4CrGUyns6CD/7LI=; b=suC5SR1gEk5lQmsGJ8RI095OWtvquMFGZ533bF+4xhupYQIYUpjYxged/bdqrMjojL l+dH9CB8EF4ofZpCFbNuo5POJlOVfvKL1u6LmiPT3iWKwsoVT0UcsE8lrF/voUE0gxDH ksyK5jXOJY9I1vDzFawwo7bKZrvnV2abjJJ/PG1N2BtfE4fDWd3Li5TtotPoQEklHqAg SDyO1zXF3hdoOiXHmX1I5XgC0R+mnPkQVQTUZGtWK3ncUq8ct2mPX2C53Dg6QzQFKmhS KtqQJ+xtBPNgbUjYYbpvdsj6r42WIdTXEGnaLniYml84ml0RVK76qvo0uLBxrJQWnsC/ mI8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446617; x=1789051417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=CrNy0DGUAMNQACpRIKae6EFwhUPs4CrGUyns6CD/7LI=; b=ACYOAws0vrRTqY8LCqghxDhG8G1GXFm8poarBShL00P8226Tl5jaSPAcp2zP1qbwrD ES6X0rQRO6yPk9alxxGbp69iyVi3OGtIC28yWQRG0b2dwYLE5/QwGvNvEZNqgsfTdhR5 LDoTj1OZcppl1Ndt/VCIkS3nH/uKmaC6dMU++Z43CQQsodQPCxpYXEk7RcZcy23dDepR V0Be93XgyIeChyhJW2dCc105ub16ZpVhdNYnT5AVruX+lPLJXRuYXVRcam/oJUoIhBP5 RW5LMiKx425fjSmZTttP01jotZFqxIeGXWTWpAGDoYdTUEzftpMu5WsPYa8GqC991tBA 6iRQ== X-Gm-Message-State: AFuF++mtQfMKGWIhUBAh75QE7hMJSnBB6QGKglTqg9Ed9+mFM7fYnxuV 5fWtF0BcnVofuUM57ZGeP9PjIwVan7oW7+KhUCxP6sZM+mWv8PU0gjR6x6flTbZfEFDIXh3f+B2 z32e6 X-Gm-Gg: AYBFou1lkAFWFgBPFhUMtkhgU/bezQQDwxTPZHoHgQf+Wa9oLFjHSNDyI0wya/DP0Xg WBtzPMEiGMkNrk5V3Yk+cjzO8rG/GIQ3x0M36oL7YOcbg5pQKLA7J3QOx+6OIJqwMfRxoJDa1he xfUZ+20KYZwkbY6fWqFhKvTTwJz4oYQp9uLkzttaOj+7MBC1c2Vgcq+WJZI21weF2/EQs7gUJnc rCIvZkCzV9ZItmqvwW/XUzI7HWbty1AeCmrM3fTtpN5Ti6Rwe3B17ylZDoJ4npy+fDYDBxlQcrs jOCT29sAkczqfdYawJZAUA2U4LtEe97rEIFUtf2xYuL3l12UOK0Bp/oxp+qwMmi7LtN+mYzZlmF N46Wt8s2AF5f8I3h/XkG31gPb/qNgxE9pFOtY1yA0yA2hxp4viYhU8i2WLB6QxCdATy0ViKshMm yuSRXCGW8gBPyK2a5QdnckLXKUaukNj77ZmcY6Ezm4ZtOai0jUrUKu1UpnHwdHNJpwzkmlAd8Co 6ozniA= X-Received: by 2002:a5d:4562:0:b0:485:85ed:4911 with SMTP id ffacd0b85a97d-485860c5238mr1344178f8f.25.1788446615431; Thu, 03 Sep 2026 07:43:35 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 21/25] iotests: cover storing a parallels dirty bitmap Date: Thu, 3 Sep 2026 16:41:39 +0200 Message-ID: <20260903144143.2328870-22-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=den@openvz.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446830957158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev parallels-bitmap covers loading a bitmap and parsing the Format Extension. Storing one is the other direction and is not covered at all. Nothing compares a stored bitmap with the writes it describes: test 165 compares a hash across a VM restart, which the same code produces and consumes, so a serialization wrong in both directions passes it. Write known ranges and read the bitmap back over NBD, in the shapes the storage code decides between: short ranges, a chunk dirty as a whole, a dirty run shorter than the cluster which serializes it, and a dirty tail. A bitmap which does not fit is refused when it is created, as the L1 table shares the Format Extension cluster with the feature headers of the bitmaps already there. One which fits an empty cluster does not fit next to seven others, and those seven have to survive the refusal. The rest is read out of the image file, as that is what the next open will see: a removal has to reach it when the command is given rather than when the node is closed, and the in use flag has to go with an inactivation and come back when the node is activated again. A bitmap which can not be written used to be lost in silence, so blkdebug fails the write of its data cluster: the loss has to be reported while the guest data still goes through, and the flag has to survive the failed inactivation. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/tests/parallels-bitmap | 178 +++++++++++++++++- tests/qemu-iotests/tests/parallels-bitmap.out | 45 +++++ 2 files changed, 222 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/tests/parallels-bitmap b/tests/qemu-iotests= /tests/parallels-bitmap index 814b56b32c..be0ba8185d 100755 --- a/tests/qemu-iotests/tests/parallels-bitmap +++ b/tests/qemu-iotests/tests/parallels-bitmap @@ -25,7 +25,8 @@ import uuid from qemu.utils import VerboseProcessError =20 import iotests -from iotests import qemu_nbd_popen, qemu_img, qemu_img_map, log, file_path +from iotests import qemu_nbd_popen, qemu_img, qemu_img_create, qemu_img_ma= p, \ + qemu_io, log, file_path, QemuStorageDaemon =20 iotests.script_initialize(supported_fmts=3D['parallels']) =20 @@ -258,3 +259,178 @@ def check_multi_l1(): =20 =20 check_multi_l1() + + +# Storing a bitmap. The driver has to produce the extension itself here, +# so the images are real ones rather than hand crafted clusters. + +INUSE_MAGIC =3D 0x746F6E59 +INUSE_OFF =3D 0x2c +EXT_OFF =3D 0x38 +TRACKS_OFF =3D 0x1c + +stored =3D file_path('stored') +copy =3D file_path('copy') +STORED =3D '9b7b8b2e-1c4a-4d3f-8e6a-1f2d3c4b5a69' +OTHER =3D '11111111-2222-3333-4444-555555555555' + + +def read_header(off, fmt): + with open(stored, 'rb') as f: + return struct.unpack_from(fmt, f.read(0x40), off)[0] + + +def in_use(): + return read_header(INUSE_OFF, ' (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446752659639.6878961059499; Thu, 3 Sep 2026 07:45:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fG-0002vs-NP; Thu, 03 Sep 2026 10:43:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28fE-0002t8-2m for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:40 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28fC-00047p-3E for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:39 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-47de0093c42so2436511f8f.3 for ; Thu, 03 Sep 2026 07:43:37 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446617; x=1789051417; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=0cFMp897/2LhAMY3XQX2UH5MPXIwRH5TBMsVmASGwDU=; b=TC88sOCsTcCsdPYf8QnwLerOYhHDu2YMaY5RF9dHp2A/yEWEGJzgnDzlkPZyJJ3Ja5 kp+Br9bm9oInV9vKLCHxTtJAcE4aZo2ZFQxGjfno5kvcuY66JvAouv0JaIN2lBIe6G45 pjco0hO5aJAIT44kRKYZrSvy0hJErSEu9zWqkPApFizc/+wjPtPsCRte2GxjXgnY6WSV 5Vj2FadZ755FXLSvHai5zD7bN2Oj8kVESf8ERvmMbvH0AvaAHWTOzqzctetb84mXvHPk sY8i7YvdzohJCainluYJiNSyVME3iwejLNYUiGi7Q6qWENJIFDMeOdQ/5Q8p/beSOT44 5UhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446617; x=1789051417; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=0cFMp897/2LhAMY3XQX2UH5MPXIwRH5TBMsVmASGwDU=; b=e/gXpMJMaY/KefuXdOCRIQaNuTm0PE1LbBXVtCES3xyXxDPm7ltb5UnGRkmgM4nB7v 2AMyETL2aXAHfKTQhOk0JEM4tElUtbZ5DNbiUKvFXp8l6DXGjUzkZB/JRQctu8OSLIoP UaFj8y0IjuxIAIGWAMBPDiQ2BeApLzDH3QNA5TFpjaJYL8IG3mjLAcANh2x4AMb5OsA9 Cy+04ERdEpg7i7DvZmeXt311KF04y61O0AM/G4bLwe5BOOaxku++zJWw+v/kHwSq3D3b QWl2ZC+ARKDxoxT93udv55g4yxRvMHX0i3g0iY/j9jCtlRLa2Dm/2nA6CVxZEZnV1pb7 +o8Q== X-Gm-Message-State: AFuF++nAbAXJoBU9PDiqC+AjNWdfzOsKtI/wf2rQPKayr/MG0NuIwRrm ss3C542RDEVhiI613gD4HgLioLjuDtGc++HM2pbP6r4x32M73mOktJBJwFLYEfwqJGgy8P6IQn0 aleiA X-Gm-Gg: AYBFou16+uF+Hhscv2iyRX96FDuBq/g373VvoWjqv0u9Rbp2dCQCHIspg0m7aFqnjgr 27DSPTKRooMJzLtc3wM1oc2K78mgD0KXQoqvBhvmZDnXHq1VX+R7jZcIVynB/ksnSIoNJaNAiZ6 wbG0I7Y66em3vDpVSl5H2DZQmM0hJawq98XAG45kQ95aRvSxDPSiyUnJDvOxvxN1+jHZmws8cCi ax7ycskJmgxozDKIxxyPeAXwHlpiLWg4id37Ry1BMXzYWYetq3//fJVA42fdOvNcB2ni4Ff4mIe Pot5MvHaj9FQlnysvCrr/lEyqM11ybpGPw85JaNcuT6Gv3s4sLcWzZL/ETUks2R2KpsAkoRx9ou yUsYjsy7pcPX+v3gSy1tu0pfK/7bEjycKIbYZBLD9LfT7k1+vMEYCLzNWOtLOgKYTyYhh+w21Q6 XXImlmvnXA7FF+7yP7fFdQtZ2iVYK8ryaKPKrQ1gsWHU8mXr1RJTXNMPcX X-Received: by 2002:a5d:5f53:0:b0:482:de48:c445 with SMTP id ffacd0b85a97d-4858608849bmr1657791f8f.11.1788446616604; Thu, 03 Sep 2026 07:43:36 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 22/25] iotests: cover the qemu-img bitmap operations on parallels Date: Thu, 3 Sep 2026 16:41:40 +0200 Message-ID: <20260903144143.2328870-23-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=den@openvz.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446754237158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev qemu-img-bitmaps drives convert --bitmaps and every qemu-img bitmap sub-command, but for qcow2 alone. It is built on a backing chain and a rebase, which parallels has neither of, so half of it could not run there and the format is left with no coverage of any of this. Cover what applies in the parallels test instead. A copy made with --bitmaps has to carry them, and raw has to refuse them. --merge and --clear leave the bitmap count alone, --remove-all sweeps it to zero, and --remove-all --add in one invocation leaves only the bitmap which was just added. An image which was not closed correctly is left out. parallels-checks covers that already, next to the code which drops the bitmaps. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/tests/parallels-bitmap | 39 +++++++++++++++++++ tests/qemu-iotests/tests/parallels-bitmap.out | 12 ++++++ 2 files changed, 51 insertions(+) diff --git a/tests/qemu-iotests/tests/parallels-bitmap b/tests/qemu-iotests= /tests/parallels-bitmap index be0ba8185d..8ae9314114 100755 --- a/tests/qemu-iotests/tests/parallels-bitmap +++ b/tests/qemu-iotests/tests/parallels-bitmap @@ -273,6 +273,7 @@ stored =3D file_path('stored') copy =3D file_path('copy') STORED =3D '9b7b8b2e-1c4a-4d3f-8e6a-1f2d3c4b5a69' OTHER =3D '11111111-2222-3333-4444-555555555555' +MERGED =3D '22222222-3333-4444-5555-666666666666' =20 =20 def read_header(off, fmt): @@ -434,3 +435,41 @@ log('--- and the image is still readable') info_out =3D qemu_img('info', '-f', iotests.imgfmt, stored, check=3DFalse) log('image opened' if info_out.returncode =3D=3D 0 else iotests.filter_testfiles(info_out.stdout).strip()) + + +# qemu-img-bitmaps drives these for qcow2 alone, as it is built on a +# backing chain and a rebase, which parallels has neither of. + +log('--- bitmaps can not be preserved into raw') +make_image(STORED) +raw_out =3D qemu_img('convert', '--bitmaps', '-f', iotests.imgfmt, '-O', + 'raw', stored, copy, check=3DFalse) +log(' ' + iotests.filter_testfiles(raw_out.stdout).strip()) + +log('--- convert --bitmaps carries the bitmaps into the copy') +make_image(STORED, OTHER) +qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x11 1M 64k', stored) +qemu_img('convert', '--bitmaps', '-f', iotests.imgfmt, '-O', iotests.imgfm= t, + stored, copy) +copy_info =3D iotests.qemu_img_info('-f', iotests.imgfmt, copy) +copy_data =3D copy_info.get('format-specific', {}).get('data', {}) +log(' %d bitmaps in the copy' % len(copy_data.get('bitmaps', []))) + +log('--- merging one bitmap into a new one') +qemu_img('bitmap', '--add', '--merge', STORED, '-f', iotests.imgfmt, + stored, MERGED) +log(' %d bitmaps stored' % len(bitmaps_reported())) + +log('--- clearing a bitmap keeps it in the image') +qemu_img('bitmap', '--clear', '-f', iotests.imgfmt, stored, STORED) +log(' %d bitmaps stored' % len(bitmaps_reported())) + +log('--- remove-all sweeps every bitmap of the image') +qemu_img('bitmap', '--remove-all', '-f', iotests.imgfmt, stored) +log(' %d bitmaps after remove-all' % len(bitmaps_reported())) + +log('--- remove-all with --add leaves only the new bitmap') +make_image(STORED, OTHER) +qemu_img('bitmap', '--remove-all', '--add', '-f', iotests.imgfmt, + stored, MERGED) +log(' ' + ' '.join(bitmaps_reported())) diff --git a/tests/qemu-iotests/tests/parallels-bitmap.out b/tests/qemu-iot= ests/tests/parallels-bitmap.out index 994c67390e..df6f676106 100644 --- a/tests/qemu-iotests/tests/parallels-bitmap.out +++ b/tests/qemu-iotests/tests/parallels-bitmap.out @@ -92,3 +92,15 @@ read 65536/65536 bytes at offset 0 0 bitmaps stored --- and the image is still readable image opened +--- bitmaps can not be preserved into raw + qemu-img: Format driver 'raw' does not support bitmaps +--- convert --bitmaps carries the bitmaps into the copy + 2 bitmaps in the copy +--- merging one bitmap into a new one + 3 bitmaps stored +--- clearing a bitmap keeps it in the image + 3 bitmaps stored +--- remove-all sweeps every bitmap of the image + 0 bitmaps after remove-all +--- remove-all with --add leaves only the new bitmap + 22222222-3333-4444-5555-666666666666 --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446864; cv=none; d=zohomail.com; s=zohoarc; b=fAYm7NlDacLArmVHlQ3kmgk6rxPsshUB9tevr/7giFjjLl44IbVjJaYnXZ2Bs29+Bfaawl4IZIwtXK2eEdt7Ew3NxReMmK0qiW6eoG1i8H2W5lw5xvv7G8hOhf8O2nC/Gg0uzf7uNbc/790aJ9AeEfBv9tnaGYtydkdUPddOL8o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446864; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cQlgvs0K0xIlGh+yKAKDJcIf9T3Gw9z+mIu16XTKHjQ=; b=Htib99OdjjyvzNcuevajPqWpYhYJ1PXwxyeQyKUUiVVlyQBSMR8DDQSYIliXb6fH653hc3fn4DjLKHBjFqYbOlGvu8t78cLw7RrgsM8a0szaF60n8GoTczXtUqKN7Tnh5xtLEQbxB7MK3s/dwQLS7Ly1UKXv9zqX7JoOnbyaiII= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446864023147.87239318019465; Thu, 3 Sep 2026 07:47:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fI-0002xQ-En; Thu, 03 Sep 2026 10:43:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28fG-0002vw-Nx for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:42 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28fD-00048Y-66 for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:42 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-47de0093c42so2436536f8f.3 for ; Thu, 03 Sep 2026 07:43:38 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446618; x=1789051418; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cQlgvs0K0xIlGh+yKAKDJcIf9T3Gw9z+mIu16XTKHjQ=; b=CsrRPviUcO+kKX20n0cL3INFH3OHuG5YIxn8ucKwYaUacYuvla7LgvkhSUYd1cvbl7 uHqBOL4030oFiqqN1bJaZUrW7AcfMG3pONsrG9vruZnNhoa1m/gI+wmesfYGF9m5wCSI ZzOaM7rmn/8LUZTJwFB0FTj8dARcxdjyVBka4xSiWfQhLZjLeUq4/TG5P3EeFd/GdXcw pC6MDmCS/oiak5GeUJGNd34a4XeuxagUuGqskB53mKweoXhVHIat9AlPC52q5iBSXkB5 uqnBIo7JXf8jL6GYlquzK9WuowWyhNGVStvsr1FYbCiejuC1bhr9wPMNi0SFRXDOct6B veIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446618; x=1789051418; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=cQlgvs0K0xIlGh+yKAKDJcIf9T3Gw9z+mIu16XTKHjQ=; b=nLJM01hdMVE8XJfqnSMLhfRJIluhoqfRpcVAcbolju7PotP7mmO/HpEKe6lZM/jfL6 LLVv0xWTYmHIlkFvtALQGAbOKNiEWBX/u8zKunPcFCZjZQl8C2Wf7QgpbIFhbB//zpm9 t+1YnR9+1IakvaIo0gjgun+I8gnT3jTwV9qXNmqDGhvxcHnko8syRyZoT2gUs0shWib+ bGbcnRKnwsJmoou0P4z027T8Bj43EOJBSeDhVAM4Wx0GL8VsEN4srpvphaMRTdI+7/vs DMNPtuqNYJyDctoENH+Alc4CD2YbkFuY2qdSMDN5nG8XrB9bowhr9fBD7oT/m1B+Lqoo RRlQ== X-Gm-Message-State: AFuF++lkWzxoz45BdA9qKMHr0i0EVZ2sEW0nFzNQzCTdKNYf91KuvGDE XzNhdrIuLvZ3e41UoB7CG6hQig+4c0KDmyf0YP/x9cbp9RMEL1eOVQjBPkCvmx0+LVYqTmEjPbQ cEy5K X-Gm-Gg: AYBFou0aMLJu9s3PqXHz5HjEZ7SKsAdlrDR0nmMRKIDZ1zrCWTrMfBsrl/ilCEJ1DJv ok/9YQtuSN1QZdCjTTuX5L6MzADB1jPg9nabFAMRg32S52RAGlo+yZKTLnXeiV9dmzH75+BSAwH vHVBb31o5X6Ispud7gbt6pWjC9TIRivEMJX80yl93i1Nqq2XQaSzKYiRPUWXpeFQvtgbKiJsx9V dVfg83sIApzkGxvEICaVN3kR5IJvhfKWCwXMXC/vtTYS6sNI32nSFvoBkA0i4uSKRGU5ITqLTFO 7jZtetaMxTKgkU+bQQyOl0wHjsAqJ0QYsZrh5oHg1dciGyxPlefYZUGCUma180u4Cq46CIDky+f z+M0perIFXqyLZ8p+SkiwsZWJxcKBY4lFQtcyBN0isvSzmP6hmuMAeMjpnr+59GzPD4ILI5e06x Yf/1JfjLQ7gmS1IiPVzk3eSRQPxYtiaNXjo4xamkiC548dHBaOs+JdudRz X-Received: by 2002:a5d:4562:0:b0:485:83a6:b296 with SMTP id ffacd0b85a97d-485860d54c7mr1330821f8f.19.1788446617707; Thu, 03 Sep 2026 07:43:37 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v7 23/25] iotests: cover a broken Format Extension and a combined repair Date: Thu, 3 Sep 2026 16:41:41 +0200 Message-ID: <20260903144143.2328870-24-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=den@openvz.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446865069158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev An image which was not closed correctly may have had its Format Extension cluster reused by a guest write, which is what the reuse of those clusters is for. It has to open anyway, as the payload is intact, and it has to stop pointing at what is no longer an extension. The same damage in an image which was closed correctly is what an older qemu leaves behind, as it ignores the extension in read-write mode and truncates the file to the end of the payload on close. Both shapes of it are covered: the cluster overwritten with something which is not an extension, and the cluster truncated away with the header still pointing past the end of the file. Neither keeps the image shut, and qemu-img info is enough to tell, as it opens the image on its own. Rebuilding the used bitmap after a leak is repaired reports the errors which come with a BAT pointing a cluster twice, and those are the ones qemu-img check is there to fix, so a duplicate entry next to a leak is covered too. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/tests/parallels-checks | 80 +++++++++++++++++++ tests/qemu-iotests/tests/parallels-checks.out | 57 +++++++++++++ 2 files changed, 137 insertions(+) diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index 84eb526f44..ca89ed5d62 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -443,6 +443,86 @@ echo "=3D=3D guest data was never in doubt =3D=3D" # Clear image _make_test_img $SIZE =20 +echo "=3D=3D TEST BROKEN EXTENSION OF AN IMAGE WHICH WAS NOT CLOSED =3D=3D" + +EXT_OFF_OFFSET=3D56 + +echo "=3D=3D add a persistent dirty bitmap =3D=3D" +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_testd= ir + +ext_off=3D$(peek_file_le "$TEST_IMG" $EXT_OFF_OFFSET 8) + +echo "=3D=3D a guest write may reuse the extension cluster, so clobber it = =3D=3D" +poke_file "$TEST_IMG" $((ext_off * 512)) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" + +echo "=3D=3D pretend the image was not closed correctly =3D=3D" +poke_file "$TEST_IMG" "$INUSE_OFFSET" "\x59\x6e\x6f\x74" + +echo "=3D=3D the image opens, the extension is dropped =3D=3D" +{ $QEMU_IO -c "write -P 0x11 0 64k" "$TEST_IMG"; } 2>&1 | _filter_qemu_io | + _filter_testdir | _filter_generated_node_ids + +echo "=3D=3D and it stopped pointing at the broken extension =3D=3D" +echo "ext_off: $(peek_file_le "$TEST_IMG" $EXT_OFF_OFFSET 8)" + +echo "=3D=3D an older qemu leaves the same damage behind a clean close =3D= =3D" +_make_test_img $SIZE +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_testd= ir +ext_off=3D$(peek_file_le "$TEST_IMG" $EXT_OFF_OFFSET 8) +poke_file "$TEST_IMG" $((ext_off * 512)) "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa" +_img_info | _filter_generated_node_ids + +echo "=3D=3D truncating the extension away is dropped as well =3D=3D" +_make_test_img $SIZE +$QEMU_IMG bitmap --add -f $IMGFMT "$TEST_IMG" $BITMAP 2>&1 | _filter_testd= ir +ext_off=3D$(peek_file_le "$TEST_IMG" $EXT_OFF_OFFSET 8) +truncate -s $((ext_off * 512)) "$TEST_IMG" +_img_info | _filter_generated_node_ids + +# Clear image +_make_test_img $SIZE + +echo "=3D=3D TEST REPAIR OF A DUPLICATE ENTRY NEXT TO A LEAK =3D=3D" + +echo "=3D=3D write two clusters =3D=3D" +{ $QEMU_IO -c "write -P 0x11 0 $CLUSTER_SIZE" \ + -c "write -P 0x22 $CLUSTER_SIZE $CLUSTER_SIZE" \ + "$TEST_IMG"; } 2>&1 | _filter_qemu_io | _filter_testdir + +echo "=3D=3D point the second BAT entry at the first cluster =3D=3D" +first=3D$(peek_file_le "$TEST_IMG" $BAT_OFFSET 4) +poke_file_le "$TEST_IMG" $(($BAT_OFFSET + 4)) 4 $first + +echo "=3D=3D leak a cluster at the end of the image =3D=3D" +file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` +fallocate -xl $((file_size + CLUSTER_SIZE)) "$TEST_IMG" + +echo "=3D=3D both are repaired in one go =3D=3D" +_check_test_img -r all + +echo "=3D=3D and the image opens read-write afterwards =3D=3D" +{ $QEMU_IO -c "read -P 0x11 0 $CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 | _filter= _qemu_io | _filter_testdir + +# Clear image +_make_test_img $SIZE + +echo "=3D=3D TEST A LEAK WHICH DOES NOT FIT AN INT =3D=3D" + +echo "=3D=3D write one cluster =3D=3D" +{ $QEMU_IO -c "write -P 0x11 0 $CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 | _filte= r_qemu_io | _filter_testdir + +echo "=3D=3D leave 3 GiB of unused space behind it =3D=3D" +truncate -s $((3 * 1024 * 1024 * 1024)) "$TEST_IMG" + +echo "=3D=3D closing the image truncates it without complaining =3D=3D" +{ $QEMU_IO -c "read -P 0x11 0 $CLUSTER_SIZE" "$TEST_IMG"; } 2>&1 | _filter= _qemu_io | _filter_testdir + +file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` +echo "file size: $file_size" + +# Clear image +_make_test_img $SIZE + echo "=3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D" =20 echo "=3D=3D write two clusters =3D=3D" diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index c6d9445440..f6806f82fa 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -302,6 +302,63 @@ qemu-img: warning: Dropping inconsistent bitmap b2c9e1= a4-5d3f-4e8b-9a7c-6f0d1e2b read 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D TEST BROKEN EXTENSION OF AN IMAGE WHICH WAS NOT CLOSED =3D=3D +=3D=3D add a persistent dirty bitmap =3D=3D +=3D=3D a guest write may reuse the extension cluster, so clobber it =3D=3D +=3D=3D pretend the image was not closed correctly =3D=3D +=3D=3D the image opens, the extension is dropped =3D=3D +qemu-io: warning: Dropping the Format Extension of node 'NODE_NAME', which= does not look like one: Wrong parallels Format Extension magic: 0xaaaaaaaa= aaaaaaaa, expected: 0xab234cef23dcea87 +Repairing image was not closed correctly +Repairing space leaked at the end of the image 1048576 +wrote 65536/65536 bytes at offset 0 +64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D and it stopped pointing at the broken extension =3D=3D +ext_off: 0 +=3D=3D an older qemu leaves the same damage behind a clean close =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +qemu-img: warning: Dropping the Format Extension of node 'NODE_NAME', whic= h does not look like one: Wrong IMGFMT Format Extension magic: 0xaaaaaaaaaa= aaaaaa, expected: 0xab234cef23dcea87 +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 4 MiB (4194304 bytes) +=3D=3D truncating the extension away is dropped as well =3D=3D +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +qemu-img: warning: Dropping the Format Extension of node 'NODE_NAME', whic= h does not look like one: Format Extension is outside the image file +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 4 MiB (4194304 bytes) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D TEST REPAIR OF A DUPLICATE ENTRY NEXT TO A LEAK =3D=3D +=3D=3D write two clusters =3D=3D +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +wrote 1048576/1048576 bytes at offset 1048576 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D point the second BAT entry at the first cluster =3D=3D +=3D=3D leak a cluster at the end of the image =3D=3D +=3D=3D both are repaired in one go =3D=3D +Repairing space leaked at the end of the image 2097152 +Repairing duplicate offset in BAT entry 1 +The following inconsistencies were found and repaired: + + 2 leaked clusters + 1 corruptions + +Double checking the fixed image now... +No errors were found on the image. +=3D=3D and the image opens read-write afterwards =3D=3D +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 +=3D=3D TEST A LEAK WHICH DOES NOT FIT AN INT =3D=3D +=3D=3D write one cluster =3D=3D +wrote 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +=3D=3D leave 3 GiB of unused space behind it =3D=3D +=3D=3D closing the image truncates it without complaining =3D=3D +read 1048576/1048576 bytes at offset 0 +1 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +file size: 2097152 +Formatting 'TEST_DIR/t.IMGFMT', fmt=3DIMGFMT size=3D4194304 =3D=3D TEST A DUPLICATE IN THE LAST ALLOCATED BAT ENTRY =3D=3D =3D=3D write two clusters =3D=3D wrote 1048576/1048576 bytes at offset 0 --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446681; cv=none; d=zohomail.com; s=zohoarc; b=aPeiZVo8ZdThB52fockyFayzsETDjjMH+GdrR0uAGIe/FwJ0CnE4bk/ifpAuE26k4w1mBTLnspuo50QrSJhHaDrf4efm7W5RwBKTR01yep66rKx2T0HlBHyhwu+xvLujB3q/3W3jUr38MuhVY2J9ZIT2m6q88/4QYwp30Iie1Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446681; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WH4NtQS27vnM9CBskaa8A4wfHHtgS6Dz+fFxVJqp21Q=; b=RJ7WacY7XfAcDqRpXoe8C7zV6ipz7xM9EDRG8GgXTt1jI8sg5nNuGkBt1gNILp/jFWhVsnw7FCq1M0BWwngmUGBw2002qS8juZABmTajV4JBJreWBF6RlWcBrjD01Qba2T/OFiqips7UYEafg+MTcytvJibYZM2Jxx3DUYQ5HzA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446681630621.4504266439092; Thu, 3 Sep 2026 07:44:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fK-0002zJ-Hd; Thu, 03 Sep 2026 10:43:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28fH-0002wF-3c for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:43 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28fE-000491-JJ for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:42 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-49b392ccaacso36637205e9.2 for ; Thu, 03 Sep 2026 07:43:40 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446619; x=1789051419; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WH4NtQS27vnM9CBskaa8A4wfHHtgS6Dz+fFxVJqp21Q=; b=pfejoF+Ofi3GKurBUUMoHXgshxkkmbmy4FYjEYt395wEH7F4RQ+NEI0CuiVVzZRzdX R2JPVmOiXIRPh/CvA+PqTPVCoaj2/lYcv4e3/sZS9lK5Xz+uLZbXfK7IhZBRGB2cprDg 9rOTkouulYJQR70zpW02zo/hXUOppmhLcCqOQp2CjGEmV26XaWESDeaSFLDpL1Y+NwUZ 1IQp//puch/hIgXKoknaOqfYTEJFRUaiEs3G5WUGOCTfBv47hiZEHKMcF0Bmt3kPOkBn u+fSikDKCcnAFBwjNKH1dl2XCfTRkLdhqqs9rIvZ1e9PoSjI8Rmjb5/YoMf2uRFl78Df 4FdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446619; x=1789051419; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=WH4NtQS27vnM9CBskaa8A4wfHHtgS6Dz+fFxVJqp21Q=; b=bMzyRIUJ2mxa18BDJcVNhqD1X+kTmT8xvKxoLa6j6N3XaGed342cZgxt9oSD3TQ0Py wYs4PmXI0uc536Nu1nhoH3cLmrP93hk48Mi/+5BG5S5A88gR4kgqFaIFTrexUA54RCGr 1QQLml7QqYMEadkxkIsUKjl+oow48/znTTlYA7KOsnoJkklG9douwCzPWBtPYchDuu87 XDuNn40t+coeDQ6c9YzoiFpwQs83H8vqSrnIn4iIbMt/OHHSOI7ldBIPTUaWTg3qqCX0 LwDJkctWmFObmX42J9Xudz8+9SaTG9x2ucmjEes9bu/uAkKIY+uDIRpjlxuqtGW+a4Ya zeIw== X-Gm-Message-State: AFuF++nbY6qkY+W3Ltz0gvUwA1tLvjQIKwwV+/BWPuMhMFwf1g1y7afS Mm1YqiOPZP9hiEE2Wk0TQIPNhw4BFpcfvYlzZ8HGR/QI/OkkXyobtqVVI+JKWuXKHyp/VBOKDht 5b7MF X-Gm-Gg: AYBFou0+olaEeMH5VCIy28aExsyhOnvXk1126yCwKyCcTP+r5ZbH1tPW9jvGM3TlPj+ sU/JVNHWe5/O7NYH+6qeMTAplza0PnsNg+eX9ixGCIQ87wItdAYxTeGTl0Y5tUm6eCM/7SCqgzI 0xi1XEr/XjrmijTS/LLL5s+zAT8GkHyo1w/R7zaxfdtalTIB26PO5hjggVCj9p/cGM80/GikuLY ffjQmfxREsVQzm9tmLtl3jB9VYjDgAOXXZ1PyeNrI0cnDu7T882HgmxhlfsEJxPfs+S4zrMDchr OnltF0bc9bwLxpyQzZFbEEUD/XZhKJ9SgRZn+zP3yY4HP0aB3PpudBXopMyh/+mA4jN0By35PZg hZHUVjinAXVeHOG08BjudMqJDpsuHZnqHWLAnNgncJI6mrATgtBBKZtRoU+VIoQwntuSOLqrZG9 Z1EOxV11/ZtIje32xVO7m3DexZaPnMYWBW0uYRkSzn5WUA59Dl7WkxaOwd X-Received: by 2002:a05:600c:6296:b0:499:621a:2ec2 with SMTP id 5b1f17b1804b1-49ce581635bmr258106275e9.3.1788446618812; Thu, 03 Sep 2026 07:43:38 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v7 24/25] tests: Turned on 256, 299, 304 and block-status-cache for parallels format Date: Thu, 3 Sep 2026 16:41:42 +0200 Message-ID: <20260903144143.2328870-25-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=den@openvz.org; helo=mail-wm1-x32d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446683668158501 Content-Type: text/plain; charset="utf-8" From: Alexander Ivanov These tests pass with parallels format. Add parallels to supporting formats for these tests. Cc: Stefan Hajnoczi Signed-off-by: Alexander Ivanov Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/256 | 2 +- tests/qemu-iotests/299 | 2 +- tests/qemu-iotests/304 | 2 +- tests/qemu-iotests/tests/block-status-cache | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/256 b/tests/qemu-iotests/256 index f34af6cef7..1a4c9c6885 100755 --- a/tests/qemu-iotests/256 +++ b/tests/qemu-iotests/256 @@ -26,7 +26,7 @@ from iotests import log =20 iotests.verify_virtio_scsi_pci_or_ccw() =20 -iotests.script_initialize(supported_fmts=3D['qcow2']) +iotests.script_initialize(supported_fmts=3D['qcow2', 'parallels']) size =3D 64 * 1024 * 1024 =20 with iotests.FilePath('img0') as img0_path, \ diff --git a/tests/qemu-iotests/299 b/tests/qemu-iotests/299 index a7122941fd..d8c4399446 100755 --- a/tests/qemu-iotests/299 +++ b/tests/qemu-iotests/299 @@ -23,7 +23,7 @@ import iotests =20 # The test is unrelated to formats, restrict it to qcow2 to avoid extra ru= ns iotests.script_initialize( - supported_fmts=3D['qcow2'], + supported_fmts=3D['qcow2', 'parallels'], ) =20 nbd_sock =3D iotests.file_path('nbd.sock', base_dir=3Diotests.sock_dir) diff --git a/tests/qemu-iotests/304 b/tests/qemu-iotests/304 index d465a519a9..03c7c1cbe3 100755 --- a/tests/qemu-iotests/304 +++ b/tests/qemu-iotests/304 @@ -23,7 +23,7 @@ import iotests from iotests import qemu_img_create, qemu_img_log, file_path =20 -iotests.script_initialize(supported_fmts=3D['qcow2'], +iotests.script_initialize(supported_fmts=3D['qcow2', 'parallels'], supported_protocols=3D['file'], require_hmp=3DTrue) =20 diff --git a/tests/qemu-iotests/tests/block-status-cache b/tests/qemu-iotes= ts/tests/block-status-cache index 5a7bc2c149..ade3d5b169 100755 --- a/tests/qemu-iotests/tests/block-status-cache +++ b/tests/qemu-iotests/tests/block-status-cache @@ -131,5 +131,5 @@ class TestBscWithNbd(iotests.QMPTestCase): if __name__ =3D=3D '__main__': # The block-status cache only works on the protocol layer, so to test = it, # we can only use the raw format - iotests.main(supported_fmts=3D['raw'], + iotests.main(supported_fmts=3D['raw', 'parallels'], supported_protocols=3D['file']) --=20 2.53.0 From nobody Sat Sep 26 20:51:03 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=quarantine dis=none) header.from=openvz.org ARC-Seal: i=1; a=rsa-sha256; t=1788446786; cv=none; d=zohomail.com; s=zohoarc; b=aDjJ05X2Z+e2dvRuBUHwI57POTM1BT/EGSYlVDX2YPaRPmbFY4U1KJX6vz5THzz16HTNhHAC2H/cJJ9emdqTmZ0YkfG+TohJHmcma0Map3iAXFNFNya39dEtlDm/+D1E3xhTBCtxaGVEh91V+l8anNOdZRfyqgXRkI808xxAmK0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1788446786; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=cwUTQMhe74SR6t67iKwOiGBl/CWJ7OZ0wscikZLVil4=; b=X7SnZjAdPcT3uJPB9lXKWHLHPWK+oBxDwqPvsnPUIVFP8hSTDy+/X6DLSJgOfEe8KYUmMeb6jIC+FjtDHDeD3gnYlwLabd2rWbIK+l7et7IlnCB8ecYQBwVg3VwqgmqgeuYeJL7ro8UGOhQuFFouicZoiIjHAXLWV7fw2Cm/4eU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1788446786114560.4529546933109; Thu, 3 Sep 2026 07:46:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x28fL-0002zd-OF; Thu, 03 Sep 2026 10:43:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x28fI-0002wx-1s for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:44 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x28fF-00049V-Pr for qemu-devel@nongnu.org; Thu, 03 Sep 2026 10:43:43 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-482e067e908so2162692f8f.2 for ; Thu, 03 Sep 2026 07:43:41 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:83cc:ab98:cda9:7dc]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48448ee9cf7sm15165483f8f.25.2026.09.03.07.43.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Sep 2026 07:43:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1788446620; x=1789051420; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=cwUTQMhe74SR6t67iKwOiGBl/CWJ7OZ0wscikZLVil4=; b=PqUDkrnlyzMXi2sL/WqZtEkvGQeJ2NVqXv02NBVl/RSBzJO+XkOlPJu67YjnJoD8ey jU/AJzkEJoORfr6lqxVQl9B/AqdQHRF/UBw+MryGDJJSx/ojRvT3S7LVz5xJfLhbbyw4 DYpu218U2dUxxozBppF19RdTinSMVFzF1v7s44YtLRlL71tGP3MOvO2vzH9s4uqno08n EOcbqyiuB0gcEB/h7nkq2Fy2PXTV9Go5AWM3RXuSBDoRwgMwHpnVaqviMqEN84ySAOZ9 uPPFCdny7MfSeCA85w6mVgzv0oEg3hr7+6Ckj9U+iM2feocUNyHJ+vmUcO8UuJVGYCmr McsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788446620; x=1789051420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=cwUTQMhe74SR6t67iKwOiGBl/CWJ7OZ0wscikZLVil4=; b=rVJAiCJcNzOsj0O3fq2m3mpddd51p6PgrFbwZgOzsS7nJfHO8v818SSs4iVKAyUNCl /qk9UnfIbhjej8+1XOXGQfEkf5baBvFjNIEI2EXPx8Ow1L8JITiNYiutwsqf71bdTb18 4dPv21W/dT42r72Vk6RviIQiapkUbI/UW0AiXq/gqLWU0SGjIkCGajqeNJA1o3AuA0aR n2lb+r65/2k9BoPwZ1mia9BnAl9IlExIt6JeJdMCC06SIGQxJI/CBJUiqoXk8QdK7l8X 0G2tEZLogK9zgQ/IPNG48OF18mcjd4dRTuYtsnOYf/9FPnUCrIgwivyNsVjHk6vm0JTY qH+w== X-Gm-Message-State: AFuF++msMoh8p1hr5Q0gkhZbcNFJbbo2w+D7+8qQ959eTk2k4Jee8KJs 0+siBIlVWOY9RUXEXt/u9j+ZzOty+fXumEUO9ZQ+Ex81xv4mHlopO+1tMSW6acL4c6BKAqkgUqU Q0jen X-Gm-Gg: AYBFou2kIoRsZvvdBuYr6qAIzqZi3Y4MIqR1st3u2vfCsCMtTao/UeA91n5tVpLOX5B tAa2XbJr4O8R+h2Y2OTbgE5FEv2qRSekiWfadjxK5iqI5gy3EBrqRpIb1LmkVnA9LJTzOYYLBZm 0esGIz8PhmludMpuCphD6ZRvGNSyXuqmWAWOmGIuMoUNi3PudxoNpJIefvmXK4QcC9jFBpn3Rv5 qDFR5qQE7mGkX4FHPFLbbpWpZKpSmsv1G6yfQYIThCOadICDpV30swN0Ce3hhuYJMvB9dd66u7W 6R3rj8iOlnFcfGRLq9kcJ5YBTFcaxAv5wbr0JfZVHSFWfEizyoq/yDnTRgcKX9mvjDUpVt4EVDo ruWKnD3+QkxLyFLyCsIwd4e5icpf6u5VCAqkviqsWnk7LArL/aTpTPA9yURbHp8jNAksy1lwWY5 xdtMgl/Y7fZtkkI+hYm6iolDI0BXYWEgr+00L6tHKgx2U0IPrbz3z663nNqu4+T+RbfNI= X-Received: by 2002:a05:6000:490e:b0:484:478e:e19f with SMTP id ffacd0b85a97d-4847b6266a6mr25383404f8f.0.1788446620095; Thu, 03 Sep 2026 07:43:40 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy Subject: [PATCH v7 25/25] tests: Add parallels format support to image-fleecing Date: Thu, 3 Sep 2026 16:41:43 +0200 Message-ID: <20260903144143.2328870-26-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260903144143.2328870-1-den@openvz.org> References: <20260903144143.2328870-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=den@openvz.org; helo=mail-wr1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1788446786544158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Use a different bitmap name for parallels images, as the format has its own ID format and can not hold an arbitrary string. Replace the hardcoded 'qcow2' target format with iotests.imgfmt. Add 'parallels' to the supported formats. Based on the original work from Alexander Ivanov. Cc: Stefan Hajnoczi Cc: Vladimir Sementsov-Ogievskiy Signed-off-by: Denis V. Lunev Reviewed-by: Vladimir Sementsov-Ogievskiy --- tests/qemu-iotests/tests/image-fleecing | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/tests/image-fleecing b/tests/qemu-iotests/t= ests/image-fleecing index b42aa6967f..0142289843 100755 --- a/tests/qemu-iotests/tests/image-fleecing +++ b/tests/qemu-iotests/tests/image-fleecing @@ -28,7 +28,7 @@ import iotests from iotests import log, qemu_img, qemu_io =20 iotests.script_initialize( - supported_fmts=3D['qcow2'], + supported_fmts=3D['qcow2', 'parallels'], supported_platforms=3D['linux'], required_fmts=3D['copy-before-write'], unsupported_imgopts=3D['compat'], @@ -62,12 +62,18 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, ba= se_img_path, if push_backup: assert use_cbw =20 + # parallels stores a bitmap name as the UUID identifying it in the ima= ge + if iotests.imgfmt =3D=3D 'parallels': + bitmap_name =3D '00000000-0000-0000-0000-000000000000' + else: + bitmap_name =3D 'bitmap0' + log('--- Setting up images ---') log('') =20 qemu_img('create', '-f', iotests.imgfmt, base_img_path, '64M') if bitmap: - qemu_img('bitmap', '--add', base_img_path, 'bitmap0') + qemu_img('bitmap', '--add', base_img_path, bitmap_name) =20 if use_snapshot_access_filter: assert use_cbw @@ -76,7 +82,7 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, base= _img_path, qemu_img('create', '-f', 'qcow2', fleece_img_path, '64M') =20 if push_backup: - qemu_img('create', '-f', 'qcow2', target_img_path, '64M') + qemu_img('create', '-f', iotests.imgfmt, target_img_path, '64M') =20 for p in patterns: qemu_io('-f', iotests.imgfmt, @@ -131,7 +137,7 @@ def do_test(vm, use_cbw, use_snapshot_access_filter, ba= se_img_path, } =20 if bitmap: - fl_cbw['bitmap'] =3D {'node': src_node, 'name': 'bitmap0'} + fl_cbw['bitmap'] =3D {'node': src_node, 'name': bitmap_name} =20 log(vm.qmp('blockdev-add', fl_cbw)) =20 --=20 2.53.0