From nobody Sat Sep 26 20:50:58 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=1789088652; cv=none; d=zohomail.com; s=zohoarc; b=D8/OYEDkOCqvc2i/vx/nusdw9Y0ePZTXb7SLse4Yygo9tM5tqR01FQElYf1ry9JxD2OyGxCU4FAfZGdMg2kGc8NhqCC/dqj7bMX3uxThPQCiucqVnU5+WnVhVBIVtYzOBp5Ch/1U426cckKnJ0UgSQ41mLZ2TvamTALcSF4FJEw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088652; h=Content-Type: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=I/WX+4pCAmK4ycsPuxUQEh25NlG6reKGl1ZmaTRTHAg=; b=SbLvHpnAxiIRLeND2g26R8Zy8lC5j3LwdttVxwKGeBSkM56/z+bJ4FW/EPaHYALvlhs8J2bLTmp6HX9f3ONCQaqOTeZtPdn2Kqw8ELP8d1hEHIQUVs/1W1W13vUTXKw7EoUA4+rqAdhMcJ+xep6CXrbuq6Ra+mEIAc/VT+miPgM= 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 1789088652531728.601004950748; Thu, 10 Sep 2026 18:04:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pgG-0001IB-7T; Thu, 10 Sep 2026 21:03:55 -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 1x4oPX-0001g3-5a for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:41 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPU-00078R-TB for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:30 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-49e625d5a2fso748305e9.1 for ; Thu, 10 Sep 2026 16:42:27 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083746; x=1789688546; darn=nongnu.org; h=content-transfer-encoding:content-type: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=I/WX+4pCAmK4ycsPuxUQEh25NlG6reKGl1ZmaTRTHAg=; b=DSxoQdDXW4gyO8esFnO+EKRJPxOazeGIa/hxdva6YeIa095PsmmZ0nurs0QSg4456H hh9HBhYjuoB1ZUKpV9XkbnPf7GRrXM/ygeesoLrCHc6wH/7XOvCW58NYbuHjsGAZm6g1 vWMALtcUtlBOzbi1VezJwJDWoscN8aB1TmjOAyJZUXpgPMGtSwRpj1zCTRu4KhOquFWG QxNRgkKlRJJke4XNrLXp7Z5axnQ/PU0l1iJaMoiO7QupfsM1JegpTr4X2RgU7kG4QuY+ o0wRAugEjB7AB8PRQY06elweqWLzaKSmy7HWfXAGMDOGnrQ9ivYblPWJYvCRSuHCZoVk LCLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083746; x=1789688546; h=content-transfer-encoding:content-type: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=I/WX+4pCAmK4ycsPuxUQEh25NlG6reKGl1ZmaTRTHAg=; b=ZnqUs9rjOyxm6hs/ChaSCHjBt8QHd4zmMRQdwXwMasj56MrlZFCKnq5dYTJmhjX7Aj wI3RWWAkuRAcPgq9oqmz7xIgz3byZcP8MaZ3MiLAaUhZfKQiMXO2zmeDVkfwFn6IYOiT dyBgST8+BiKcSW/Hdf6AB+Faeyv6z1erdlelhOfmuWZH3NWMoPCps5ZCn0EThu4rpiM7 aIcaoWei7W/7SWFhoux+VX3jOCg2842X1rjTxmtRkflaAMegkcs2m4qdOwcFH7q7NVv3 My0QMsCsBfrXGRMGk76CFy3gWiJWLNRZNxEpvkn0YLH12H1rR56qnPotUwP0BDjh2rW1 8Utg== X-Gm-Message-State: AFuF++kFpSAX9M48NuqVftOCcIT9YkhD3spJa04mfi7T0zmiARgJPDJf IEIK8MvpZG7fsFCsYyH84zDUuBfa8YbCon+uv7AZJk3U54tQ3qoU2McWTDXQo7Yf8H8= X-Gm-Gg: AYBFou0x2l+YtLCAb711Evo5xD6v8kiAUtJyHEQaoFqBAtauEsRViZEvc6eFda/uqYV kIFyrmJl8Eb80Fmui+vkdOitk0OB6qwB+4XzsAQU/XkkD+Yglc9PAT28D9M50TAXqiL0phIWxgE 6tT95C+Za7PcFqQzm3p2WUL/7vu7lCMIqYVO4v+D+Uu5mEPRbXncG7nLhv/dtmZR48uGpP3RCHV MGbPZszFAbuIn2dW1DE/Gypo5ZggE/h5qct2NAih8GU2FOVH3HR3F71NsxqPSxxOQCD+B0RVfMF 6VL+22dL/LHZWazdeyKDXkliKOb7Jc67wd7pkKJPVRhu4+j4FO3esKWAfCZW1kl6Qk2E9+OuHw+ ow5yiDKFZwQsLlp+r2hUgYN9yuJxkZxOC6L02mpSlAuWS84AePz90qU6d7I3CrYuVfN1OuvJwRw zxCrlFMl2lQIaDekPzatpVrta4I2IrKib9ory0PdFf4L/0z+RY+1EwtdhuNffo/FGw6s7p X-Received: by 2002:a05:600c:3494:b0:49c:fa21:1c7c with SMTP id 5b1f17b1804b1-49e619bb143mr14136555e9.17.1789083746381; Thu, 10 Sep 2026 16:42:26 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 01/29] parallels: fix out-of-bounds read in format extension parsing Date: Fri, 11 Sep 2026 01:41:54 +0200 Message-ID: <20260910234222.3039975-2-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-1-den@openvz.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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::32a; envelope-from=den@openvz.org; helo=mail-wm1-x32a.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: 1789088653924158500 From: Denis V. Lunev parallels_parse_format_extension() advances the cursor over the feature payload but subtracts only the feature header size from the remaining byte count. A feature whose payload reaches the end of the extension cluster leaves the cursor at the end of the allocation while the count still allows one more header, which the next iteration then reads out of bounds, 0 bytes after the 512 byte cluster. The stale count also breaks the data_size bound of any further feature, so parallels_load_bitmap() can read past the cluster as well. Account the aligned payload in both the cursor and the count. Aligning data_size before the bound check changes nothing, as the count is always a multiple of 8, but it has to be computed in 64 bits: on a uint32_t a data_size of 0xfffffff9 or above wraps to zero. Reported-by: Martin Hole=C4=8Dek Resolves: https://gitlab.com/qemu-project/qemu/-/issues/4156 Fixes: baefd977002e ("parallels: support bitmap extension for read-only mod= e") Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 7f6ab6b0d2..baee86a159 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -239,6 +239,7 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, while (true) { ParallelsFeatureHeader fh; BdrvDirtyBitmap *bitmap; + uint64_t data_size; =20 if (remaining < sizeof(fh)) { error_setg(errp, "Can not read feature header, as remaining by= tes " @@ -260,7 +261,8 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, goto fail; } =20 - if (fh.data_size > remaining) { + data_size =3D QEMU_ALIGN_UP((uint64_t)fh.data_size, 8); + if (data_size > remaining) { error_setg(errp, "Feature data_size exceedes Format Extension " "cluster"); goto fail; @@ -283,7 +285,8 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, goto fail; } =20 - pos =3D ext_cluster + QEMU_ALIGN_UP(pos + fh.data_size - ext_clust= er, 8); + pos +=3D data_size; + remaining -=3D data_size; } =20 fail: --=20 2.53.0 From nobody Sat Sep 26 20:50:58 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=1789088951; cv=none; d=zohomail.com; s=zohoarc; b=Sqng/R8AG8ET9ii7W0OmLoJ9leKIuOLssNha2qZ5vVDopc2KBbtRrZlgykuvRbHKYrdipztoXN/jdwi9pS+pBwNH9oYIUUnW7tX+royLdNVkfyKDV+aQxX3FKUwVSbMA0x920jH5uTIVBjyplVryF94UCNxQSsILmPcNIghx5p4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088951; 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=W3Bx8pnT2sDuexNJA7DxABZ4LqKNGDa3976jN1luce0=; b=gSxUeFTV1ADDBoVl5vwMLBkspWGzMUxWiaZUmVwTztJQboyBrvWt/AbZ9tiiKb+e3/Uvg7iJn64eqx8EIdvrihG7uawJd8CvcuBv77pF8vGwF0pbogQX8w76dsyfW1g6j9y6OcTN5C3AfRErHMufZQXiZb31DQecSAKBoJrIxkc= 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 1789088951552609.1711520467817; Thu, 10 Sep 2026 18:09:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pkn-00053P-EP; Thu, 10 Sep 2026 21:08: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 1x4oPX-0001g1-4i for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:43 -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 1x4oPU-00078h-TL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:30 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-499ac87c92bso4412705e9.1 for ; Thu, 10 Sep 2026 16:42:28 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083747; x=1789688547; 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=W3Bx8pnT2sDuexNJA7DxABZ4LqKNGDa3976jN1luce0=; b=mK7Z1ZYD99A+ad+/VKzVnnmZ9xTLrHlXxJitM42UyJ8dV55kWuxFTh4Q+2mWND9rbK 8man9jDCti/zAEHxsi7V3dozSn+Q1YrYp5AqW8N4RWSUm8Ks8yAsy7frV02yYENjv63z sNnC+QgPicqC5V0f51UL7TJ6BmBKyqG85aaV6e/elHORQffT6lQSX1NSvmFBkOHRQu5u iPAFoQ31ZDwTx2aSlYUh6eKbAABlEpEPUuYgnFKP2ESpAyCbOlWDstdiu7FlMajw65Da SpVEXsevlqE+1aISFnX9E/buikIoQ0mCDJRLEH8PjvIl2lSu+A7cQn7iEQ2d8DTRijrk DQlQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083747; x=1789688547; 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=W3Bx8pnT2sDuexNJA7DxABZ4LqKNGDa3976jN1luce0=; b=lGMIQQKmzmZ4BYZQuJnuNCDEO5sZK8fc53cGWiTOamji0LllEDxCxv1NA0iPHr3cPg 4oHZzSsNmOM/9FNvgAuQpamvv2bM6k6r1sH1e8RthaKi4+k287vzT2Lne1dVu3oi4WYt 8zvF/FvHrXoM3ZRxTzZbhJyBehSmtWQJMe1bLuE+L37uN6GWkszQT02FPpEFkhqeveI0 uHB1doZeQW5xXzXminQSldxcf/PPJ5EahU9HcvoQH2+WgrbETj26iTxe8OvO6mvFQkwd biJ7OR57VTpGRe1Rj/yrbNoQI5v80Wfauj+lsz4ShdDpCFjAU49smkQ+zKzGG6c5WO++ bvsA== X-Gm-Message-State: AFuF++nQE2SPDzfAkCE02oAtonvUIw/TYnLn5Jwg/od89Bv1uxXTj6mr XWyFiPGr+AOg5H+8zjaBOu7FovLgGZDWIp2jy9au5Gvegrc4fcPz731F8nJFJcuiBbI= X-Gm-Gg: AYBFou1jZiZqkFd1h3iKqGIbsEZ2LVZVUccv8/ScQVT3xhwAGtLTHWIpk/Dye9bIt0Q C4wDGQSIKL7buzN6dg//iesYF/XYV+kxKUdlzU7eePjHGYk5mMZ6EyB88njMq0exwGpWFhhbAqH z1GwpMt3uagimoiXxYxu5C1Ku6IXOiB7oRJ1Cps4+UypaU0r6FbRfJRviI3vyKlSV3De94AlPkF yndmwZXlP9tqr8WdfvIrxCL9cO7CunJSKeO3LKLGY4I9pt891xfryAbfc0apDcyk04poxoAteFW Vs1X6pXuhxF4ekh33pPwktwYT25PutEt/p0UP2muBYLyrpJMxvziOEfmg8fAh6YUZZIq0O60GBg XAZV/RkT7U8JHEnrwc5EBPTQBC3hx+EAByXbis61CM3kwEsQn+MNbMpYXMYmxoEToM0N2F/YZoe Tvh3R9l5gplHh421U/ojAQ1wyj8HgT14svagDwQUaaerzeOH4Mj/ZrAphjxLcSwenRUqzs X-Received: by 2002:a05:600c:3b90:b0:49d:16df:8521 with SMTP id 5b1f17b1804b1-49e619805f1mr14921895e9.4.1789083747197; Thu, 10 Sep 2026 16:42:27 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 02/29] parallels: validate dirty bitmap granularity Date: Fri, 11 Sep 2026 01:41:55 +0200 Message-ID: <20260910234222.3039975-3-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789088953355158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev bf.granularity comes from the image and is passed to bdrv_create_dirty_bitmap(), which asserts on it. An otherwise valid image thus aborts qemu-img for a granularity of zero or one which is not a power of two. The shift by BDRV_SECTOR_BITS is done on a uint32_t as well, so 1 << 23 sectors and above wrap to zero and hit the same assertion. Compute the granularity in 64 bits and reject what bdrv_create_dirty_bitmap() cannot accept. Fixes: baefd977002e ("parallels: support bitmap extension for read-only mod= e") Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index baee86a159..830ac78a11 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -31,6 +31,7 @@ #include "parallels.h" #include "crypto/hash.h" #include "qemu/bswap.h" +#include "qemu/host-utils.h" #include "qemu/uuid.h" #include "qemu/memalign.h" =20 @@ -122,7 +123,7 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *da= ta, size_t data_size, BdrvDirtyBitmap *bitmap; QemuUUID uuid; char uuidstr[UUID_STR_LEN]; - uint64_t bm_size, tab_size; + uint64_t bm_size, tab_size, granularity; int i; =20 if (data_size < sizeof(bf)) { @@ -133,7 +134,7 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *da= ta, size_t data_size, } memcpy(&bf, data, sizeof(bf)); bf.size =3D le64_to_cpu(bf.size); - bf.granularity =3D le32_to_cpu(bf.granularity) << BDRV_SECTOR_BITS; + bf.granularity =3D le32_to_cpu(bf.granularity); bf.l1_size =3D le32_to_cpu(bf.l1_size); data +=3D sizeof(bf); data_size -=3D sizeof(bf); @@ -144,6 +145,16 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *d= ata, size_t data_size, return NULL; } =20 + /* bdrv_create_dirty_bitmap() asserts on an unusable granularity */ + granularity =3D (uint64_t)bf.granularity << BDRV_SECTOR_BITS; + if (granularity < BDRV_SECTOR_SIZE || granularity > UINT32_MAX || + !is_power_of_2(granularity)) { + error_setg(errp, "Invalid bitmap granularity %" PRIu64 ", expected= a " + "power of two of at least %" PRIu64 " bytes", granulari= ty, + (uint64_t)BDRV_SECTOR_SIZE); + return NULL; + } + if (bf.l1_size * sizeof(uint64_t) > data_size) { error_setg(errp, "Bitmaps feature corrupted: l1 table exceeds " "extension data_size"); @@ -152,7 +163,7 @@ parallels_load_bitmap(BlockDriverState *bs, uint8_t *da= ta, size_t data_size, =20 memcpy(&uuid, bf.id, sizeof(uuid)); qemu_uuid_unparse(&uuid, uuidstr); - bitmap =3D bdrv_create_dirty_bitmap(bs, bf.granularity, uuidstr, errp); + bitmap =3D bdrv_create_dirty_bitmap(bs, granularity, uuidstr, errp); if (!bitmap) { return NULL; } --=20 2.53.0 From nobody Sat Sep 26 20:50:58 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=1789089126; cv=none; d=zohomail.com; s=zohoarc; b=A/P3Y9tNVNBYCn9936EbxEYzy5TC5m/ddxGk5xeZsEWpabhW3/6eaQWvnYT20+CmR70onO3x63o/+iSF88GvDWlYpxkoc/kQ79A3Jl3M8ZSg3HCenj6hrmBzitEzIZp8ffg1w8uJ0N115q6VfndJ8NMiy9x3D06+M3SC9giKiF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089126; 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=3NKROluHrX0VacEA4l0FH/FI2U2V5K+qKaWUQ7JbxTI=; b=fDNGzFwyP1sjHn1tMRWWTTh2nQeB0R8wXBg2V0fKLlq75aJ3087xPloWSqPUMDOYq/r66ylwKXkKyy0VG198bSdzyNqX9adxTHFzXaEpa2aI1ML0s7E8Xbg//P2Pp5n2BfUgkqadTi6sUiaXoxc42me/Xq1hd9NQUNHcb2iPD3M= 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 1789089126883435.9652034388969; Thu, 10 Sep 2026 18:12:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pnS-0006TE-Sf; Thu, 10 Sep 2026 21:11:29 -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 1x4oPc-0001gL-EJ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:54 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPW-00078x-Rt for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:35 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4995b0343c1so5026545e9.3 for ; Thu, 10 Sep 2026 16:42:29 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083748; x=1789688548; 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=3NKROluHrX0VacEA4l0FH/FI2U2V5K+qKaWUQ7JbxTI=; b=fmukhHXjQyZ4VYWMBiEFesVuNeukMLC4UYaIziyr0WNtsWGZJaQsoHBG9zyvb6nAob JAAn0YKf6HAttfnKeWHwjyKYhSqc+t58EbvIshGGXpsvqiLkmJ5AtU6Lo31zOsln94FM 44S0RJgqXXUq6F7kDqnfChaLw5lPk/f4grhZmdV6GTaJMI7li27UEBHf9akUYLGmPElg rAtFb7GEhkwy+U1KjczzhXqKVnDpeZIJoncE/zsl2cRuvg0kQzKbN3JWgh9LYUbxR9z3 vTZ8YKGILtt5wVyX+e2HXW/poAFvhEf3cledVqOD8f3swssakfG0nU3T4NN2r342bbMW V97Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083748; x=1789688548; 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=3NKROluHrX0VacEA4l0FH/FI2U2V5K+qKaWUQ7JbxTI=; b=V1JB8OgmMyTwFm4atjmxGktTvjbYsOc9g+T91kuZfDjJ+WqERbB+Pw4KyegTwcHXZK zc2mT2goAFggN84HDmsw8FsbxoqZ/Hz7uzyTfQCStZdw9vf0oQcA40cbMaidH7gEZbdz KJ4u5a8NBt4vxANBIo9+qr96BGv4KsFxEAby0PzdH3/PNZaJs5O7fkBI6CtdIcqLKoEL GRktTsIfzVW1WXyCTYby4nibg6fz4jFft4nq9cMZ392BHssqisU9+omxdRHRDqMdO48m 4n4YYR1FmWG+eHFU70wZKXVhnqIUSAXWFYzKvyx/TM3a+hN+jHG0vgd9l3fn++68F1q1 bMQg== X-Gm-Message-State: AFuF++l3lcodlgohe91r5b/z1T5QDnHHaFPCiSzwI92oDtwNi1LasBFr hEbOJRZZQaiLyEg3oinJek9xuVCTQvIIjqZ0Y3B8jv4Fq5yjMPruwnp7kuWBFdijMPw= X-Gm-Gg: AYBFou1fAntTqGgwQlf4X5cbySHV2C9q1a2Y+GXKrBX/qMwEIrBi2OproEjOJFRzUWi kZUKcp7u6IkUyi6dHgjMKp7cF1FXgwxeaZO4vguyACw6iK/e+YQmFP+XhgZiMe8zjxHh8dYIHik wlI6yDB5FCgqAzaRorRMNgCnDeLIZuuvco3lHoNsxiQ8DPVpaq2HxvTEhit9EGXcItB+OxJu6w3 LJTTdRuUfiHpnZU6NbRVoB6IhSd15NALp7uA5EzbYYASYrdbvgp9GFgGgNshwFjlHfoxVkkkX79 /xf4qe4i5pi+be1v5sYaIvcLjYRjqVdUY3ac2awXXHH0bMlbd7DBDVqWT5PklZdoRABtVcb2RhZ 6IFfOR6sd8L7CKVkoxlphYE3p73v4QGInqf0lC3Ouh+OXK48VJIK9XobbuHfEZSsr8jI5HUDdcG aKWTGmg1YP6JqwbyHmFD2Dz6FJGP4wx+V8S+dVZ90QnXC9fj7ipYuHBC0tgiqNeiStGAuxQ3Tci xDN6Yg= X-Received: by 2002:a05:600c:8b23:b0:49e:6067:72ff with SMTP id 5b1f17b1804b1-49e619d1e6amr13987575e9.31.1789083748140; Thu, 10 Sep 2026 16:42:28 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 03/29] parallels: bound the bitmap L1 table against the bitmap size Date: Fri, 11 Sep 2026 01:41:56 +0200 Message-ID: <20260910234222.3039975-4-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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::332; envelope-from=den@openvz.org; helo=mail-wm1-x332.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: 1789089128109158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev parallels_load_bitmap_data() derives the number of bytes to deserialize from "bm_size - offset" without checking that the offset is still inside the bitmap, and an offset past the end makes that subtraction underflow. The overflow which used to produce such an offset is fixed by "dirty-bitmap: fix integer overflow in serialization coverage", but both the cluster size and the L1 contents come from the image, so refuse the table explicitly. The check cannot reject a valid table: l1_size is DIV_ROUND_UP(bm_size, limit), so the largest offset the loop reaches is (l1_size - 1) * limit, always below bm_size. Fixes: baefd977002e ("parallels: support bitmap extension for read-only mod= e") Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 830ac78a11..63fe4d5b1e 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -76,8 +76,17 @@ parallels_load_bitmap_data(BlockDriverState *bs, const u= int64_t *l1_table, buf =3D qemu_blockalign(bs, s->cluster_size); 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 =3D MIN(bm_size - offset, limit); - uint64_t entry =3D l1_table[i]; + uint64_t count, entry; + + if (offset >=3D bm_size) { + error_setg(errp, "Bitmap L1 table covers more than the bitmap " + "size %" PRIu64, bm_size); + ret =3D -EINVAL; + goto finish; + } + + count =3D MIN(bm_size - offset, limit); + entry =3D l1_table[i]; =20 if (entry =3D=3D 0) { /* No need to deserialize zeros because @bitmap is cleared. */ --=20 2.53.0 From nobody Sat Sep 26 20:50:58 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=1789088288; cv=none; d=zohomail.com; s=zohoarc; b=kfOgJLVAcBxslQxWKpKlrvFNrwMWgeIi2IrBK/WksME/hvAR+z7eZJ7oB15d53xb4eqwyeKm27LgretRWrzt/0AAgINfz3yCHUAmFxdEc/6GB6fA7O9R2E3eRXr9LG434818Y/nnoWk6D9fTG0xlVA6dKgM75OQ2HAwvnB9oZEA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088288; 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=xmIJ/DJJkGNWUN3aFg+eKBZQoYpsUnERuZvgRZchJco=; b=CIOoHeEDD6lp4brxqVzuw2csw4wpWyrgDbwwTuW+Mpxs5M312Y0nay76Wx3TZIDEC6Gg2zG7sZfpsnySQmDXmE9lcUlbG9hAOgUuIkJrCcD8pJ8cyWpuVm/0Jc/Q+NTiGt3hMg46pgF2elxFR9swBhIV1tQOyCvSlXsE3p11QvE= 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 1789088288664668.7405382169007; Thu, 10 Sep 2026 17:58:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pa5-0004Y9-IL; Thu, 10 Sep 2026 20:57:31 -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 1x4oPa-0001gG-K6 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:44 -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 1x4oPW-00079K-RW for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:34 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-49cca4ffdcfso3168825e9.0 for ; Thu, 10 Sep 2026 16:42:30 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083749; x=1789688549; 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=xmIJ/DJJkGNWUN3aFg+eKBZQoYpsUnERuZvgRZchJco=; b=gLYyHjiIZ4wZqM4Od8W0Sxt19z1TY9pyw+6Ud5n1VrKZs3NFY71jEZH+j9y9LtZVz2 YxFbrJMlw8tNJiV0b67Hdq2zm+r0w2CxxW6Ch0EdcSQauMxHujtqAiLwhMMLE9VreMeI jWakfQEr4HMwHYsgmhhVlKlgmQhiKQPYCXgV8reG8Ym42ZOXTKrvAsvlbQnilU+yP3DT CWd393TtBZptoRWN2cSrWvdzBD2zbdzvrAyD8l6MrS1DScEUVa5VVE6C7K1cJY7aEkUe jfWVbgPXpaeBJHaOM3WrDrz74dhCbB120dTgu2ZUQ5z2EEqr4DVKej3bLtLk6H8wgMl4 IiFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083749; x=1789688549; 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=xmIJ/DJJkGNWUN3aFg+eKBZQoYpsUnERuZvgRZchJco=; b=sOpGiYLTdkPEbzKGABgCXyLncLubQ0qGN09Osc0/M8mEEOrydIdIgk9o6Lf0dOUdiJ edM8+cDFkhE7xLnMSwXdUP44/PreYa/8SKRVt6BknlSb7txvXEBTA/GgK60pEVwUybru QyWUu6EwzI6rB/7zpyWC+L8rdw/PzQBaNvIcEx3hdFz6FicvZyfJv07gdYtzaLvf+Jgq 4BUDe9SJBzD3stvXRddPM/Z4wVD8NLUJ6k+YcDfrglEVV+/jD7dq+FWfj4pYvZlqtQaN 31HkdL+nRIhBCeDieK3vS/GFGZ83q0+mx+pVrUPR4DUInGDoEmgwHjKxqrFnY9vW7wn3 rIQg== X-Gm-Message-State: AFuF++mDM7XiILGz/8qosNoU22DVW3PfYLeE0uRG1V3Cai4ur57ieNX2 PX4vj1T+IRgKWLmQqQ+7z2I+fSASob2vc/w0QKs93Bk+8y/R12SnOGZWx/ETQq3Ke3k= X-Gm-Gg: AYBFou3mYLgCnAyDUTPOQTcCvpLGt4YtiD9jMJcKGIG9GCw0Kpw683TY1B+YW7nzOa/ 8lF4NCUWCDuW1evmnZHqcTy9n9yyduv3zHUL0/DyliO6dmxSYBWnKD9DO3/zx4Rvm5EO1uDSxQs 2lXugSW4r1PVVriNVNVlP7B1cyMy8LejVOEfafoiAS41JG5xCXTWBAu/6rlY6V2uTvbuse5iGLE pZ31f0XtiN49BA1dVUM6XRBK3uSPSksA8UyoYzYiQ2ft+kjmGK96kHnPpsWpvzAKNqhdmKF/VDh R8SvjowlajCmGrxOkeSDdJc49T1+aiit7qBOE0mk5iF8hZobzGJhcUaR4dZ7leDpIIniZ15BSdt htGjZvkC4FU/nHclI9/1uiWqwcnBbxYs/9HzLyPxfW46E3/vCwxkrSn9J89sojisQtvD4tx7hSm kg2r2W8/o76puLjRY7fLyM/rcogVPAlSPqULB9MEK1W0B7DE107dynIgsDjr7m4SHDEuu7 X-Received: by 2002:a05:600c:8a1a:10b0:49c:ee22:364c with SMTP id 5b1f17b1804b1-49e6198d0a6mr10919025e9.9.1789083749047; Thu, 10 Sep 2026 16:42:29 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 04/29] parallels: reject a Format Extension outside the image file Date: Fri, 11 Sep 2026 01:41:57 +0200 Message-ID: <20260910234222.3039975-5-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789088290184158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev The Format Extension offset and the cluster size both come from the image header and neither is checked against the image file. Reject the image rather than reading a cluster which is not there. Fixes: baefd977002e ("parallels: support bitmap extension for read-only mod= e") Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- block/parallels.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/block/parallels.c b/block/parallels.c index 93b5fa9dcd..50748d1415 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1375,6 +1375,8 @@ static int parallels_open(BlockDriverState *bs, QDict= *options, int flags, } =20 if (ph.ext_off) { + int64_t ext_off =3D le64_to_cpu(ph.ext_off); + if (flags & BDRV_O_RDWR) { /* * It's unsafe to open image RW if there is an extension (as we @@ -1382,9 +1384,14 @@ static int parallels_open(BlockDriverState *bs, QDic= t *options, int flags, * 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; } else { ret =3D parallels_read_format_extension( - bs, le64_to_cpu(ph.ext_off) << BDRV_SECTOR_BITS, errp); + bs, ext_off << BDRV_SECTOR_BITS, errp); if (ret < 0) { goto fail; } --=20 2.53.0 From nobody Sat Sep 26 20:50:58 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=1789088731; cv=none; d=zohomail.com; s=zohoarc; b=HIoT/Q29OPJj1xIbDJlc7tqPwhpJDHHuWHsgMgz7VVbW3HrHz6bhzP/JZaVb2sTLbYqhnMjAuJmk/A/gV9NovCARiky+X/Ayjk93y4olhVkDDVCmJVXm4RZ3JGRJhEJL3oQ+0DlrQfkYFANZFJHJ6NduM+tMUimgSKmGRje15m0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088731; 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=QKVJvx37U1Ou4yt08ZBZeRtwXNpu+2B01rGqZNKxlUU=; b=mY0o0A1fYzW1MSStvO/1wahMnuLs1idceLpTWnDRbc8yCQgxPgIgDBSMHG3h0QZ5IbPzWyzYduaCgJU7VMYEANo0dcl1iQ+KlcgyGT4ybFltCL696UgXumRwSQJd9bqxHuuAxM+rQqQQmbH4t6hK7sKzXaiTirQUeztrfSj2vyw= 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 17890887317134.117800258139937; Thu, 10 Sep 2026 18:05:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4phc-0002dt-Vw; Thu, 10 Sep 2026 21:05:19 -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 1x4oPc-0001gJ-D2 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:54 -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 1x4oPY-00079X-QV for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:35 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49b8ce9b733so3083095e9.1 for ; Thu, 10 Sep 2026 16:42:30 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083750; x=1789688550; 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=QKVJvx37U1Ou4yt08ZBZeRtwXNpu+2B01rGqZNKxlUU=; b=lRbh29nR9zh7GL9sRPwJUsfIESeXgVlBfr5Bw/nSclo/jAKCuNARxWslVFRvYdb9Ly R2sL0xpomi5QS+t2n88V1a7qSbu4gUkZ2DQKrgwG25qnLsMGmhDhyJj9D/35eKHe1aky Rjg69LYe/XOFHegnNFnwjiTX0do7oSBviLua+LI8d/ZMvrE8rBWENXfsF+QppW1PK31q uMmc+v+IE0SpuGCeJC6g1uiBw9NnUpJB29BNA5RywQ1GV2m8EFC+jZ2qWdl1P2ysqxSh J3hqbQmMAdzOI99k/q4rMTdstAz6/UypConLcXv+AYaHbqND0SCLXnRSwrvMSu8mSg6K FlQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083750; x=1789688550; 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=QKVJvx37U1Ou4yt08ZBZeRtwXNpu+2B01rGqZNKxlUU=; b=DjizTymnpe/+GYWoua0qPD+T0QQ4HK/oIrZ/+apYCLvSSqDqw+emUcXFg8hY4/LmXM Q4ShqN2Y4xdkwyDGpiVNYvaC5ZPyrRcl2VenPQMGDXw3UYWJlO26Fzk2sfqSX/auUSRV Xy1W7o734JPCiXj3wV2QHLSEyycnkKfeqQv4AWiOi5p0tKi69olnl7PtbmmC0ouUIaXF /eTlmYLPfRxyZWGZnbE+T5EvRuoM8+63Us4y24QjHY0X8BrdK1zzBPQxgsDxdWnB1WyG QssmO2P779wbZ17AfqzFsEODSEFnutFAojVpi8sxPus3jquOHwDA8KZfoUINqBSRJDt6 quOg== X-Gm-Message-State: AFuF++k5fEH4V0O4vVNnaHKB2XAdNaInv5rzMad8TNty5UCbmHgRByyB Lr8g31kreNTbKH0TsiGeYRB/t+NXlQNjzrcTTWGkNwskv61WLoBYvMRlybonM/Q7S0o= X-Gm-Gg: AYBFou3utxEu6A8lYS5YrBgg/KAgzV8neTk+Rm8PiYngGvhaEIuAF8iWnwVHCoT1CeE z8Bzkmg6cK7/yQMyJJWLSQgo9nrJvMqzubvS6Qnra36xIGjhmLCDty8Iqv4LjRMoDGZ7f/ZNrtS /J1wQOg/kz/8LhY1Rngx4ZUjiKsoQTKb1+Vs7nyyRaLOSP36OghS3fS9R/Or5yUpTHhxMmXGzKD I2Q+EEllMpBlgGI2vJsc8TVnPiK1BKsLpW6guhSTHrDT0QVnfFkUfX1p+xtqm7DHBl7xxsYDsbo 1+erVcagaoD+urN7hajbWkjwWxKS4UqicxM3i4UjXRzYOmdQQEEUjGe6D22CynDpR/fMEVISkka 45LlplOARP5tzZtfy3ZtaY7Qzv2nHR7VbN+OlCegM/kvXivv7dmvw7YKxM8KysBvaodWRscxK68 9U2KHs6ssb6ynfEji5ziiNswGF5Op/TRK1XSEAUDcxHBVolENU0DDNSBuRjmQ8tPMDPOmc X-Received: by 2002:a05:600c:8b23:b0:49c:fa20:cc0a with SMTP id 5b1f17b1804b1-49e619e6849mr13858245e9.33.1789083749880; Thu, 10 Sep 2026 16:42:29 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 05/29] parallels: allocate the Format Extension cluster gracefully Date: Fri, 11 Sep 2026 01:41:58 +0200 Message-ID: <20260910234222.3039975-6-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789088732078158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev s->cluster_size comes from the image and qemu_blockalign() aborts when the allocation cannot be satisfied, so use the try variant and report the failure instead. The two are not interchangeable: qemu_try_blockalign() asserts that the alignment is non zero, while qemu_blockalign() reaches qemu_try_memalign(), which quietly raises a zero alignment to sizeof(void *). bs->bl is only filled in once .bdrv_open() returns, so the alignment has to come from bs->file, which is the node the cluster is read through anyway and what parallels_open() uses for the header. Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 63fe4d5b1e..89fab36039 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -323,10 +323,16 @@ int parallels_read_format_extension(BlockDriverState = *bs, { BDRVParallelsState *s =3D bs->opaque; int ret; - uint8_t *ext_cluster =3D qemu_blockalign(bs, s->cluster_size); + uint8_t *ext_cluster; =20 assert(ext_off > 0); =20 + 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"= ); + return -ENOMEM; + } + ret =3D bdrv_pread(bs->file, ext_off, s->cluster_size, ext_cluster, 0); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to read Format Extension clus= ter"); --=20 2.53.0 From nobody Sat Sep 26 20:50:58 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=1789089168; cv=none; d=zohomail.com; s=zohoarc; b=ku/JBM38vXJtdoGy4EUm3dHzsAcIL4e2bIDsD34KwTPJWAEvdqbmDcFV3yakr7ix87R6sOyfDBKtANme3ALGdGftLwKwLw53uKUN1nMUtQArWcBVKYKenRTASxfWvXNj4Dd7Vogk+frHP9uExevCaNakcUDrfkybJPQgkDu2vb4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089168; 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=prD5E0dEw6BGQrNnryKTNEUWkZGVuVEP4Po4nI7jckI=; b=DgmuiXjIE8LjMdby9Z8ZbtFeYvdZv4Kk+7+elJ7E/nEWFO6nbKJD/B60SfJqBUpmZm15nZHM7K4SuJF8Inj2mjtCv6bz+pL4/IM2Mg0+5xHlQ3JkiuNpBwWS5Qg4UqZY66aBFcgvw7t+VRxZF9Za+KFMsT/01/hzdeOVftxrhf8= 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 1789089168595694.0677409470292; Thu, 10 Sep 2026 18:12:48 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4poD-000713-PP; Thu, 10 Sep 2026 21:12:18 -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 1x4oPc-0001gN-N6 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:54 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPZ-0007AU-Vs for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:36 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49cd6185db7so2003995e9.1 for ; Thu, 10 Sep 2026 16:42:33 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083751; x=1789688551; 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=prD5E0dEw6BGQrNnryKTNEUWkZGVuVEP4Po4nI7jckI=; b=MZ1mGYfxAtOyO5cZ6woHM+pkazak59JZt3CDJRIrm3DfiCfkYX+Ej0RG1LRYmjDBO3 r6YRzoWrtpu/4pdZ9wyzr+FvHbBaaL9d4UqK2SLFUcgRbdeXc9XD1JWz25OLcpKcuRC4 /c7YYd5/bGXWdOpyB0Se4VjouSEnIBweby0L7DCbKognDFUUaKDJan1afwV0Ddli7iZg L549RdwsnPv5yi0TSFLxqIvN70LIPqXdQ78C+IQHjEBGkBtj6xWTQzTFR48nDuj84o0t fbYA4OuOrOv4uzLW9bKoZatOMrk0d+AQAN8TvaJ+MFce2Ea4uds2+N+caUyHrwruF0/r JxVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083751; x=1789688551; 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=prD5E0dEw6BGQrNnryKTNEUWkZGVuVEP4Po4nI7jckI=; b=afFd0Z/ZKA0RFeJE8i8w4Q2nDAuKuSE6bsPi0PyUfVtJKY99u4l2h7bLtb2FAy6BZh pcNbPqHZVS/sHS3usiO0/UXecr8L354uWiZIECNevA6oGqIA/0v/G36TUHRXtoSGzZCB xZO258qFqh3OyHS6FJazBFeisyIXhsXiSp3UA6RFVsdLhxf4n4T3i99Qw/B1z0979XC+ yLnoQN1b0h3tQVTcVYMUihKwAVL6rmZAGU1YO70Zur/UqEZzS+cS2dB9v+2Ef6dLQlHz P+oszct2SoKiFfK5B/TuWQrgScBoimGrmJenKebIK9/F04kbQ9JX73ov6HUVGZycK00W B9AA== X-Gm-Message-State: AFuF++nVi+8hSlBmPyJBwPbWbe/zEfSqm1vJ4uicdYubcomECTMaV40o LWsKuAZ9k3q3Olb86OaSfw76rdxlpSkZ98WRMvi7Wr1xbJ2cueSnUkx1GEuPiy/mVfs= X-Gm-Gg: AYBFou0sbPs/DdVMu12UMqyUww3IkuesHoIMdmcqZQm8oywm0EVqZWGFzWHUclKlf+j FlROZ7Zo21f6RIBJFV0wpdGa+qa+ze8cO3dyF6mvMNy0sahrkHU9+4c54UNKFcmSM7HxjSPFg8e sWzDcnmJ4p4DSovBEoCqIYXzEqdPNvKDOD1U7xL4tBOYF1HwoukjtjkEpjzjxUDTt2EBBrYO1J/ DoDku0ecEWWEBUSSIUe3yGi+l1DSjdCC8rBLxNwqwqgC4gRZSW5t0ngYqB+iMntrUmF+Hdczook PULZNQI7+/gCtimfbGX2q4qBmUin1PH9Jb5/S0AECjwsjT1LoCDyILcRfcrC7JUJJ1heh6Hxh10 pszhwjzCrLB/psW6/kbDhS9F63rQi4qiGgkp3uO9oGgRwfBGg6ceqMJhYfPpQTTYsKz2VKbqyuw 5e0b1youIDef/4UMkClqW3rn/OFacIn7jgsCVoqzfct8ovKvqEvi8n6GNhZC0I+t+uK94E X-Received: by 2002:a05:600c:3509:b0:49c:f13e:e4d with SMTP id 5b1f17b1804b1-49e61082a1dmr19729965e9.10.1789083751426; Thu, 10 Sep 2026 16:42:31 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 06/29] parallels: fix GSList leak on the format extension success path Date: Fri, 11 Sep 2026 01:41:59 +0200 Message-ID: <20260910234222.3039975-7-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.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: 1789089170324158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev parallels_parse_format_extension() returns directly on the end of features marker, leaking the list which tracks the loaded bitmaps. The bitmaps themselves belong to the block driver state, only the list nodes are lost. Fixes: baefd977002e ("parallels: support bitmap extension for read-only mod= e") Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index 89fab36039..21f54e4e3e 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -290,6 +290,7 @@ parallels_parse_format_extension(BlockDriverState *bs, = uint8_t *ext_cluster, =20 switch (fh.magic) { case PARALLELS_END_OF_FEATURES_MAGIC: + g_slist_free(bitmaps); return 0; =20 case PARALLELS_DIRTY_BITMAP_FEATURE_MAGIC: --=20 2.53.0 From nobody Sat Sep 26 20:50:58 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=1789088337; cv=none; d=zohomail.com; s=zohoarc; b=c3GB/j9aUgkFvaTcS3RHwEFB1ajRKYabb2sp5Lhn+mjE2NkzV31PWqs3CGFLDF2p9vvWgSWJZi9H9VzIbnxIbushuWZJBpTuljZ3e2nYgXroqTBFXoBNm9/MSWFXYVq2/nxg2eP64gG0QscT6HKGKleYWcwc25wYdV8hvInxgGQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088337; 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=sS82x9gVdySNfwG4lS1OAUl+9Ll5vTkrbexOf8WD9EQ=; b=nDo9AwnSAIPziDUwuBDi0PccFDI89sJotRSfvlbmUGUKtRoYdKJyrxNtmV5op5CzoikNF/EYyn/6tX1jkTakW8Qv6ItDzvJQBU8NDkGVNHwT6VnxrpinVkhf/E7Tbfj/c8kGaqcA4xtfd3zJ9N5O+elyuR0Ei9qEZUnYXfOofz8= 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 1789088337313931.4448739027156; Thu, 10 Sep 2026 17:58:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pb8-0005ew-Oy; Thu, 10 Sep 2026 20:58: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 1x4oPd-0001hj-FR for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:54 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPa-0007AR-1b for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:37 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49b912e2406so1543325e9.1 for ; Thu, 10 Sep 2026 16:42:33 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083752; x=1789688552; 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=sS82x9gVdySNfwG4lS1OAUl+9Ll5vTkrbexOf8WD9EQ=; b=c59TwasX7Vy6TwPrNRcRm3oPW+zN1xC/t6ZHQaATtXqQ7a5heGNyS3k6pcG9zVPlPU BlLSTKr0h8YlYi0zxQsEzzKVSPTqZnZziGUvuLFSJdTrr8O8vQwsKb1uzjCyYJQ7fQVq 6FpFKxJnbjPlUsH8PeRpywksW2YW9sMFoWCuTt+z5duskRsWuxjotaVLKcTVSr3IZo/U kAszx38Yl2LXzPCgrWHlQUb6OLkdLSZpVldsCL6MEoPCf58lSXWSEQCvpBloyLKFv+V4 odt53KbQb6/wXpaZHZXHI3CH0oajJ+4ZeITscT57kmr+JVHIEeYIj0gy1iLLAKrZp/+t pzMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083752; x=1789688552; 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=sS82x9gVdySNfwG4lS1OAUl+9Ll5vTkrbexOf8WD9EQ=; b=ZBzgYH2IbjATjHUXlPYWhLncQALye0O4bnba5MIFxrBBoMO59lK8OAD3ZMl1nzIzZ0 XAP7isyQgJMHYglHZvjJm7Jq9tB3Cvgzw+B8HmGz1IWe3veGrh14zYFUP/G2O+VxI9IH nKXRQK+kRWE/hoXVz43QfIrdee37hFHxWDYiRSzn2LW8dPRke0EUGRKOlcLg/DmB5t2x dagosPvYp5EiSgMKUxOwC5cVsZ6bI8ARatmfnSX+W86kz1aJ1iGmhcho3UlsJluOQhoT tMeyPJJCXL4tK3Wrwg6AJuh2zrY+e53xUJeBL4Kt2iQE6Vn9V/vfgo0hrfjMHvSPcEWl 9kWA== X-Gm-Message-State: AFuF++k6ZP6Uxly8DTXBvCo1Sp4sfFBk3eHG6tRxlOGvUPEzeOPOwgDt t8fIj9cScsq0EADh99RC6lN9Ri6c7am3dd1QTeeeYAZNB2Eq5QPCafxRPmHOUpLsACpWceT+A2z QdrJY X-Gm-Gg: AYBFou3idM7RzZPYZnO8WdceuXyV007FFuhgrY3HZ12Hzrh+dcYdX0/JjnrgTJa0AsI AORZ4h7glOryOGLplKub1oNCetU+z4K9HZSJ9ehHcgsarFZWqC1cq3pISR3gPBSCY5xANkL4OK1 PUGuDFS3PeD/VdhH7Z9TPcLBG5E4qTKEiNFgolrkITe3F9DVFE02M7vBkSDeqLpDO0/GCuIxqLY hXX3zz0zXGEXLXWllQAWQuphO6BaXPjueq53gxzcKlSV7ul1VClMENW/G6R9xFRJ066cRlob63f 7PTR5uCIEtFdWl2NEoAbXQvBiCuT5lwPJcz9S6XxOBKHUGIhdi/soKGJJZmCjyI8htZUYfoYnJM sg6/rasUjBIOL4e2D8vWG9HLf+pec6GDtyc83W7G+tTdB0If3KKe2EMTIVzDxMy1A0o6L5RQwH9 WU05bL0quejeyDtWw4hBr9WQ3sljhJk+/hc7fg9wlEmQ0p2fV92g5zo/wxEJaRlHSzAvTg X-Received: by 2002:a05:600c:4f53:b0:49e:620b:918c with SMTP id 5b1f17b1804b1-49e620b9490mr8643315e9.5.1789083752401; Thu, 10 Sep 2026 16:42:32 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 07/29] iotests: cover the Parallels format extension parser Date: Fri, 11 Sep 2026 01:42:00 +0200 Message-ID: <20260910234222.3039975-8-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.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: 1789088338462158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Extend the existing test with hand crafted extension clusters, built in the test rather than shipped as samples. Each corruption case is one qemu-img info run which either opens the image or reports why it was rejected: extension magic and checksum, feature magic and flags, payloads running past the cluster, bitmap granularity, an L1 entry which overflows when converted to an offset, and a cluster_size larger than the image file. Two more cases load a bitmap spanning two L1 entries. Termination by a signal is not covered by check=3DFalse, so it is caught and logged to keep the remaining cases running. Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- .../qemu-iotests/tests/parallels-read-bitmap | 180 +++++++++++++++++- .../tests/parallels-read-bitmap.out | 33 ++++ 2 files changed, 212 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-io= tests/tests/parallels-read-bitmap index 38ab5fa5b2..5cbef25018 100755 --- a/tests/qemu-iotests/tests/parallels-read-bitmap +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -18,14 +18,22 @@ # along with this program. If not, see . # =20 +import hashlib +import struct +import uuid + +from qemu.utils import VerboseProcessError + import iotests -from iotests import qemu_nbd_popen, qemu_img_map, log, file_path +from iotests import qemu_nbd_popen, qemu_img, qemu_img_map, log, file_path =20 iotests.script_initialize(supported_fmts=3D['parallels']) =20 nbd_sock =3D file_path('nbd-sock', base_dir=3Diotests.sock_dir) +nbd_sock2 =3D file_path('nbd-sock2', base_dir=3Diotests.sock_dir) disk =3D iotests.file_path('disk') bitmap =3D 'e4f2eed0-37fe-4539-b50b-85d2e7fd235f' +MULTI_L1_UUID =3D '5f2e1c00-0000-4000-8000-0123456789ab' nbd_opts =3D f'driver=3Dnbd,server.type=3Dunix,server.path=3D{nbd_sock}' \ f',x-dirty-bitmap=3Dqemu:dirty-bitmap:{bitmap}' =20 @@ -51,3 +59,173 @@ with qemu_nbd_popen('--read-only', f'--socket=3D{nbd_so= ck}', log(f'{a}-{b-1}') else: log(a) + + +# Hand crafted Format Extension clusters. + +EXT_MAGIC =3D 0xAB234CEF23DCEA87 +BITMAP_MAGIC =3D 0x20385FAE252CB34A + +CLUSTER =3D 512 # one sector per track +SECTORS =3D 8 # 4 KiB disk +EXT_SECTOR =3D 1 # the extension cluster follows the header +EH_SIZE =3D 24 # ParallelsFormatExtensionHeader +FH_SIZE =3D 24 # ParallelsFeatureHeader +BF_SIZE =3D 32 # ParallelsDirtyBitmapFeature + +crafted =3D file_path('crafted') + + +def feature(magic, data_size, flags=3D0): + return struct.pack('> 30 + last =3D (chunk['start'] + chunk['length']) >> 30 + log(f'dirty {first}-{last} GiB') + + +check_multi_l1() diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap.out b/tests/qem= u-iotests/tests/parallels-read-bitmap.out index e8f6bc9e96..3b3f90c8de 100644 --- a/tests/qemu-iotests/tests/parallels-read-bitmap.out +++ b/tests/qemu-iotests/tests/parallels-read-bitmap.out @@ -4,3 +4,36 @@ dirty clusters (cluster size is 64K): 10-12 30 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 +--- wrong extension checksum +qemu-img: Could not open 'TEST_DIR/PID-crafted': Wrong checksum in Format = Extension header. Format extension is corrupted. +--- unknown feature +qemu-img: Could not open 'TEST_DIR/PID-crafted': Unknown feature: 0x20385f= ae252cb34b +--- feature flags set +qemu-img: Could not open 'TEST_DIR/PID-crafted': Flags for extension featu= re are unsupported +--- feature data_size beyond the cluster +qemu-img: Could not open 'TEST_DIR/PID-crafted': Feature data_size exceede= s Format Extension cluster +--- feature payload consumes the cluster +qemu-img: Could not open 'TEST_DIR/PID-crafted': Can not read feature head= er, as remaining bytes (0) in Format Extension is less than Feature header = size (24) +--- second feature payload beyond the cluster +qemu-img: Could not open 'TEST_DIR/PID-crafted': Feature data_size exceede= s Format Extension cluster +--- bitmap granularity 0 +qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid bitmap granularit= y 0, expected a power of two of at least 512 bytes +--- bitmap granularity 3 +qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid bitmap granularit= y 1536, expected a power of two of at least 512 bytes +--- bitmap granularity 8388608 +qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid bitmap granularit= y 4294967296, expected a power of two of at least 512 bytes +--- 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 +--- bitmap serialization coverage overflow +image opened +--- bitmap spanning two L1 entries +Start NBD server +dirty 32-64 GiB +Kill NBD server --=20 2.53.0 From nobody Sat Sep 26 20:50:58 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=1789089364; cv=none; d=zohomail.com; s=zohoarc; b=TFspQqSHm5Q49GxyLgEv3YotVP8B4eeSWb81+ddTwlJtXIQTStkDVJ3lqZcoOyaUUMhrXk/uwCLdCklzlbyKo6nModXQzpZ68xjF1J47hPqVPRTYJOalrl8Bk/MZqW1ZfZFpssa577nWBs0DWK4Vhp6IrFTIMc0m82NAFZwz2sY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089364; 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=S3Mg5A3y5Who0cod+okN6DmMPkJngoeuek2O2up6nZ2A10zI7JcStPaVErxl5yvu7gVoJ/miBeuWKSDZUlcFnQjdasMY8L3AJN0GQFXQvme9VyxzL8m7Xt2F6X2SrvQsb2XtzUUlUk/KzjtSX5S2SHXGXZJd9zaig75L5A7iz38= 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 1789089364214675.2849425216231; Thu, 10 Sep 2026 18:16:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ppd-0007u3-1h; Thu, 10 Sep 2026 21:13: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 1x4oPe-0001hp-PY for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:54 -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 1x4oPc-0007BJ-Eh for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:38 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-49b392ccaacso5554425e9.2 for ; Thu, 10 Sep 2026 16:42:35 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083754; x=1789688554; 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=Bz75DDYLLY5+ZUI6lp8zWGeitd1OvcZdhU/7bGbx3+4bbOTwqg1btgrS+r92swKDRm xh6rQXwjkwwtuNhWBLbIyOtgB5kkkHS2O8EWJ8L5XwSf5CuHC29uxVncT39+mjpeSQKI fZfLZsZFLXK1HqB7/7Ydts/ZfLjVAHddG9831l6ODu0NtIFvONiYkEqNvg7nQZxIFiVE RigvuY5vgbNag1cmVX99w3rfaS/5+8EZyBN41jXZRq39IRcyVynH6YSWAkJyNGOpcdzq TnvyJZ23dCowIiUJQLzFBeVJuD3lIwEVgWIpnr4Wy8+J5o96gFDh5cou9gzlhHENtJHx wtNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083754; x=1789688554; 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=ULLyT9jvW+fV7Utmlsc10ePRObrgxSWKKvTwsY5AEHr11+D3nrDpGS5mwntbyYNHGM w7O5YmzYSfs7Ovl2irfOk7vLy6aaBdAtTEpyslHNkDfqr5NiS3X2r/wYzlU4auYbIjtC caliy5iGArI52Y9FXOp1EoPdX/1g0eWEwe6pSoG/qgkqR4kWSPmn/3/ebFyHl8+Izj2p gbgzh+Bgg3mfXGnAgBgCtoa2yYFob1Pnc/aqjSaoH5/vBkd7Di4p9x4ul57Cqz9XktNt gPRe0cu9DkS6F4kOwUJv5v3qdWhayd1VQY96RamtaT+DELI3B+6iKWi/oVfOwAtcEXHb uN1A== X-Gm-Message-State: AFuF++l/cynyTMUHgVkwaB7dT5JHGwgtxGsAPJB1DzszEpOMVDb9z0Ip 0BOOX0hh3H+csiF+tonJMCRrI70ay6O44eFUE++X0L4hQmJej1amODLmAzNFY+Z7mXo= X-Gm-Gg: AYBFou2BOyG+lOi6bifeM7hYZMeD3L03bzLBV9M8m4ePXII7RbvJnldmFMb0EMy+zd6 j6smWJ/Qqn9RF4+6W56Hv/OoXdDVRcqOP2cVL8YSE9jklpjGsO8dzUvsuoS01m9LHrwo6BJ5S5t ykHREO99v6NNMOMg4BXuk0OagRK9qRzBqBOMxplHNYNN0htcGCfuzN1sGe6BwB+qXKs9aG4T9gs j4uzGPka00kzhJb24X6vGhZn3Q/5Ypf0X6FLziOZCM4G1lmSd5JzxKE/RzonM+fuYjSR87IvoeH 3lgBSTKV4zlwUyHuHlNWg/y4kR5JtvthAcdXLEv3X6LVcUgCxtGVUhjcHm9XDNpo4BG8oTlLvDl qHgJ3puhe6eqfKnXK6MgV2u9CjEdl9rg7OFInw8zsKVlQT/a8oGUuK3XVWGjQ5uoEC36FlFmMT6 37DQs3Db6TNIz9J2ms0LRahjEjLP65MOEm0MLEJbrcm6M3ruGpofc+5/eQOCBXrjREUm2YEmqHt SjILvs= X-Received: by 2002:a05:600c:358c:b0:49c:cee0:f383 with SMTP id 5b1f17b1804b1-49e619bb961mr17700545e9.16.1789083754077; Thu, 10 Sep 2026 16:42:34 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PULL 08/29] parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap() Date: Fri, 11 Sep 2026 01:42:01 +0200 Message-ID: <20260910234222.3039975-9-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789089364948158500 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:50:58 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=1789087882; cv=none; d=zohomail.com; s=zohoarc; b=esrH0ZkAsNl81G6gB0ljNiu+08wy/bdcwZ+Cbs5PEhMZSStBHgL0o1fkCpRQ1ic2Uj1B1R6CBuszLNM5EZNquX4rsp64+uVS+dKtnQLEik0anRg9xPf9Yq18rouGr9hvwmxoL0kzcgRqQfEI2RSEMyMsfQvLhqVddLPPZOezjMo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789087882; 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=WxJLaEFlYO6XLXRZLN+ZTbVMubNCB82KDlXFqV7T3G6HcdIyoGY86cqHwIgxuaqoMavweHWTqHZpd/VCqtUFL+V6g0mcmUoPrzZp2j6AHCCOFQuqwL+b3B+bWg38h1kBTHBdrqLr7lWR8Q45hz/XayetmBI8NBkmnufIuC4J56E= 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 1789087882675138.9041152388346; Thu, 10 Sep 2026 17:51:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pTO-0007x3-FC; Thu, 10 Sep 2026 20:50: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 1x4oPf-0001hs-2T for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:54 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPc-0007Bi-FU for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:38 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49d097b4939so1681245e9.0 for ; Thu, 10 Sep 2026 16:42:35 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083755; x=1789688555; 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=TKLJyj5s4XYZbYir+WkemkaDV4LHPC+dfudPjyGGex0mAKfXtNgpYPVGj/vz3FujPr 90V9UaoROsZqAxT3KvUrJkuAPOgJLu94WdR+VdOZe8bZGWox1xQLL+ZjcRRrvIRFZ2GW QLjAc349Y8gL2AWXrEzhhob2YslUN8fwEPbX5zuR2xAcPnRZ9Y9Cj940rC6tPt/TP/+4 GNTqrDD8XNEAR5jUs+9qiXHzqqfqXa4ItowiWouxDauNwzqcwLhcbctzLTQWDd/PVDjz FDZb572rXjI2QDXNa+KhqaFsoYVC23T7aTgvVAHWK9UDw6fdig1h0mlHk9qpRDGmrfD4 9qTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083755; x=1789688555; 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=EIgmW7P2b5r1il7HAWgxyOTzqRrgQKHYfRa/c6f5XWur1VmtlufvPakIlwgCL6RhMP WGBdMB2RaJ7yXnD6TcnUDVqKA+mv1NS6qTRxgvSpMcly3JQL50VseavYLYOQFoZjKQvL vJ+6GVoiJq8SdCoSKD2//Tqf845l8F4knup8McRjeQKeXHN8VlMO6grOSIqGH4Row0Cx W6iqQqIiECTKWtiBuTqy+FYG1rafBKSaAxCYlgUms/e9OwwMAABwgBC9/6RQiM4mxns9 EbSn+6CPL+PujgexDpGOeeCvFFMAEnXcbMXC9g1FRsh1y8cymj44y9FVzpvoICZslC02 DhjQ== X-Gm-Message-State: AFuF++luHd0YaLjEeOb26MGITeBh29pPBH2NKQ0enOlojBoWZkVWi9JA ACCSRJmLf5vC8hWisW9gzN9cUEYdNVJlk/Dcj/WcanjTp0W6amDC8E0qsaj2BLpQsWQ= X-Gm-Gg: AYBFou3WkUvWeTbuXBs2OZFt5SbFTYN4C55fuKFM37JdSoQ1GhfLa4UxSDx4gup6wVK XrQxiXC3YgHAmT5fdqoWuTWcl1CFmwJtUzlFFCnfXLuhgX8p6HU59/kIty2I5L2kUNiJjvGfgXZ ewPc630acf84C2zR4wE45KiBHLq2G/0BNMnogji6LnYtA/Y/nf/kYudC2/arwsGmMXn/7om4y95 q9irtRfpHFbQnwSPddfJHy6rpdKKGcUEgO6K56CW0BE6fXPTZx/7CcJkW3R7KvDBtxUBX26hnBk Bg433mDeBrbpJZRn4ITQ83JL0Fl9ejtQRjxjbMjy756/RO+yGQdnow3lQA95oFu13NNMQUg+OI7 y/J7PmUr+bU+f0W9MjEfscrsfjj0wwNlJcue8Ba6meIKDokcN2E7bDtWk6RtEmIzOHWciN/M0fR ILogHqayfYF4dS3VjDle/lRr3JR9F50BV5ZO0mdQU1mZ7OB+/e8NfVn9atfmVGa5N4d2r7 X-Received: by 2002:a05:600c:c48f:b0:499:bf0e:95c8 with SMTP id 5b1f17b1804b1-49e619831b6mr17217095e9.1.1789083755030; Thu, 10 Sep 2026 16:42:35 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 09/29] parallels: split inactivation out and add the activation counterpart Date: Fri, 11 Sep 2026 01:42:02 +0200 Message-ID: <20260910234222.3039975-10-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.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: 1789087885746158500 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:50:58 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=1789087977; cv=none; d=zohomail.com; s=zohoarc; b=l5eqdmv8UoGc+jyzvKMq00bpeSct/OnQZvzv8V1hVCpBqGiDjyZvJ+QiS2/yV2oh48jycWY01Rfgz6MA2/wpitrsXQNZyyFg/UUHhwkQQr2Pzt0LtbTcCh26CiCyP/kl11KTOgWTsCCb/TOEadxmEdb7aHVRv2a04JiESNz0xm4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789087977; 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=dylrG3Qu0MiJ9IqLf6OV4IxZXjGkTC8JjwHtkU8RCv0B+0asa3XDV0Hf4r6B+/v4vE0Cd0KfCw9/XUuhamo1tiLSQ/xSr7+nKOhx//AbtBnTrrrDJD8MUbz5NOL1xjNngvxMci77hQqFyt04GbQYs6wuofn5Id8qhdbw8lCZkXU= 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 178908797701735.8884724728548; Thu, 10 Sep 2026 17:52:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pVQ-0000fT-CM; Thu, 10 Sep 2026 20:52: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 1x4oPl-0001ij-9m for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:05 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPe-0007Ck-IM for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:40 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-49e63568bfbso513455e9.2 for ; Thu, 10 Sep 2026 16:42:38 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083757; x=1789688557; 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=QljilNWwiKBFj26pvyyrSm3/BovdVc7voVz/qkIc/bueBOrn2tf4rGw4Zm/8TgkQez /pZuFNz+TB2mm1H1JqENkVcgGDeMA6PWj6VKFG4MLfYIPbqKmIB2SfQxT2HuWdsfLXdU QnWfv5Y1/a2MBNZvK9ZxDI9ov4TUwtPLu+60VU21aYnXlDmR2kOhMdjZWu7okVAHoC1f qao/Ckg0q0BqR2q9aVvQzG2u8JGPUmb6sZtDyFfleViJCxGRjH2UD65aqGmI+L87W4RU OP0hfBHv1h9AAk9q0+QjQqjAHu3KO8XZ9xnUz6fEhBa8UrMNXF5bOZwAg5i/YOk71Zfb Uuew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083757; x=1789688557; 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=j+/KnlvFc98AEv67Lg0MqAkthErh9lGxG9cFC+UdVTgDb744NzySw5bIe6zu9r3uzX JJz8OlE0Rw5ubb3Qcbh9iC1ZUdpkD9gVPprEC/pcUGRtFOezr461nt704/mM6+kh6u99 TEcJY4/orGxpwamUoXpMgzOmUv5Ukgi6r9WcRrsvngWcokeRC3CZdZgBagHh4gXBFgMJ 6CzqvSzHxpvBNMisIbib/Fm9gw5Z7qVYhhkt0oFDKxJnBi1cqR4ttSp2hmI0ECXHwJOi EGu26a7NvnGn3fiLRkCPqnVMANaSF7RsOkyfY3w51EVMC8qSgtS8+KFIyrWVF5cBJKCS kqBA== X-Gm-Message-State: AFuF++l1wa5Zq9s+oMbzJKMcz9e8mM14XWt0sbxFZYfGx2D9+i7fQ6IY WqdBCd066FAAJTfzqPnHCNh72fWayQkBwa/mBMMjbNeRKn1sm4uWnJUIq+Tymv+4MVc= X-Gm-Gg: AYBFou1zDbsmlE22ECppZmL4tHZCoNVb2Lmm/wfN1k7ggM+Tr0I9H1hoT3lPlzQ/Spk GOGp8PZflyQE6JX/mH4CSsZZaeaSHDZDA2VBvxLwR5/3JZ/FdFSo/x1cytWqCm5UbUId0wt5b94 1U0yNQC2jo2cCSHTOCemgk226P1HUt6SQin8d0DeM31RJ6/9iO+8ozcfAZvDSfGbpsjsS3eC1iR LeMLPPo27oxdNlLEj0iqCzhZFO5xzhRw4w2DgtyN/V/o/7/bMSjUldM9aH0RUGoqq9T0hnXhIbb o+NZMsilEjTJc6U2sMOuqwJ2P/L7JFJcvLtmON/Kr56KI590UCcrkRpVwsYjEVASk7mVXI+8DxR nSTojXojaTqzq2dXNtQfsadmkzr72DBFSrXM0ZdS+HuQkmoGaPTmUz2+u6DyNFtQZ9LmIK/P789 DgMpYlDWXGHe7NTK91ZlpyUsdIiD3iIvjFqqA93sL4bU2RGq4rFHLXi/+q1x5vXEYQvY77 X-Received: by 2002:a05:600c:698c:b0:49d:2803:22fe with SMTP id 5b1f17b1804b1-49e619e1714mr18324985e9.32.1789083757065; Thu, 10 Sep 2026 16:42:37 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 10/29] iotests: cover inactivating a read-only node Date: Fri, 11 Sep 2026 01:42:03 +0200 Message-ID: <20260910234222.3039975-11-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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::332; envelope-from=den@openvz.org; helo=mail-wm1-x332.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: 1789087978826158500 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:50:58 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=1789088296; cv=none; d=zohomail.com; s=zohoarc; b=R8I9X0P7s7pDCESDRvPNNIDAmqiuDHB6yTWx9K9Il1WqFUS6oMwpaMASf9oqJvqBf7UqN7GYKsM6yP8wztdMZ4cIbB/VAZypyaX+hMEd1KoLDgnfmpdaHMFbpp+rUWkAc0YIP7oih6LkyS+TEZerrSrluCx3ChLjagaW59VH1wY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088296; 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=YgIEL5Ih3W+RiXxQjsmmbOhRNrlwwgBQYhwNM4h9igCm0gxd43PiG7ov72koFagVgB6JAx1dUfKmAX+6vWqM5D1kDcS3/WpOcc7jSe3KLVmuWDrZ08N9i/qYus51p5rVQdG79DEO60kn8l2jnuaEdnOzg8dF9LmC/b7ireel3oE= 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 1789088296486147.28848023254795; Thu, 10 Sep 2026 17:58:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4paT-00053B-4m; Thu, 10 Sep 2026 20:57:54 -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 1x4oPv-0001jT-Ej for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -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 1x4oPl-0007DL-1V for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:49 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-49cd77e0f95so2888955e9.3 for ; Thu, 10 Sep 2026 16:42:39 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083759; x=1789688559; 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=VXz5gZXqjEpUPGNfI6zA2zw29nzzWaHhJSlnSagtklA17j7qYLo1mWrh3WurhkTt0a Slzu5C7CZt0bNXHQSGWmPEO/beOb2pu1a4CnIhVjMl3oHBl9iLdXw2HDI7qeZwlkhQK7 jph/invF8HDIARIuu3ek+r1XCbX642MKiO32gl5aDXMpQJdb16Yn4aPdqCPptVS/gykz +9xGVOgrxtGYQ/FWGrzuvSH1rE8g86dgJPGLuYSORLWL2ktXu8zEumqwNFH/1Irt/qmd gN67XcA32N6XagQHLvLsd/+5v2P2yhmpnmLM20EthWb9o3/aBbF9GRX8YZ66GhEqCChV kY8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083759; x=1789688559; 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=hbg8ac1pm7Gjhc3fKYkv9J48fUuJ7EJ/5GgWWPf+vmQ0onfc4e35D2DAeZbIsY9vwJ hPZiHrLTgbZZa33fcu3ZfLt0ZkEYlbRIOJZzCZ/4DfVlf5GzbvJunmj4F8YEGa3vPtjc KyMWiFsMK9O84FqFZrah+2Jfo+95w55F2lhr5SH854XbO+fKR7Y0sYcJoAg2UNprIjBU aMpx3amOQ+NJqZrc32u5VtPtBInKRRvVEUXDBgpqyh4qx46zwNQDiAlpqy2HrW2AGepc QPuDf1eQBCKJULflUb87T+6tVX3O4+YiOcG6Mhu3bD0BDeNhLRREv3L+CUyMutsiME+v QodQ== X-Gm-Message-State: AFuF++nCwFQLFrTebp0M2Gb3VXFEGTn9m+WajjXjpv+sJlSoEobB6i7j v4nXT0uxSUTHnsnezJT53P2lEUrv9WuV4DzATodgWoWshh2dM3BYio8owSt9auOnfRDs8IoHx5O Yzls1 X-Gm-Gg: AYBFou1zofUL9VbUZ8v8AHaqgBH9j76riBvlEqXo4c0OrtqK8VwsWa/ooEigx5DNko5 PjEIxdjQy0/rKgH8IPcjwMAqMVdSX43nvNLcqZ6q2LqLOSF1VMyt5FJSzUG85JRZg5BOdjvd+4Q 3aYWtIxbjEYz9nvK3KEuASXJw8CqqLaCEMCIWWK0I8xrfcoesMUqDhuKApDAXpVpJOuVU1DHJRw Zb4OuhKJwi6mNo/ZbcSUKXl94N3M718ehyNSlpxfn0ZtAsLJdmrUjDkghWIOmgNenz3pCRUuOu7 DMZgbLB0G/Gre+FTuYNYELDne9nMXZzf4kPuwKuLhRHbIUQ/2etxdGvKsvENv0VA5IA/Ou7Bb+3 kz2LeCC6Q1g5r30DigshEq2Gs8CR9yJd/AA3UC+9Vq9njVcbUTm/j7XVpMzMBeFvqSSv5KsZf60 GBAmbWX+3geEhM4BuxheEOhvZFfJh38toEQfTHQE4egdDC06a3jLSX+9moffkxhoETCZKWuA== X-Received: by 2002:a05:600c:46cc:b0:49c:fc6e:a3d9 with SMTP id 5b1f17b1804b1-49e619cc71bmr14037445e9.24.1789083758810; Thu, 10 Sep 2026 16:42:38 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PULL 11/29] parallels: Make mark_used() a global function Date: Fri, 11 Sep 2026 01:42:04 +0200 Message-ID: <20260910234222.3039975-12-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789088298127158500 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:50:58 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=1789089434; cv=none; d=zohomail.com; s=zohoarc; b=WRDx4NamSamGCOKSaQQ6G1v3AeG5+msnsUvWsfMa0WLHWgu4hFBh4q27gX9e44N3OzNlKM+Jym6Y0oP76wOymd9fxONduO76XeBIlX10pLI0bF4/VKiTjeepbGtGV7SKWfmm5k4jb55mIRi6jgK8jreD1ixbRf09Emm4t5qcseE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089434; 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=aIUbGuuIQFHnzQruJBMSIgqXZdQBzp6pa2Xqrds2cP7iPgvimXQ+WuPeqPo7FRDfWjRV48NWddvwazUdGg1GEfa0zsFqH9qSx1H2ksFG5zzmNpEkNHDZ7cHsz3M+fwWNZx305ghcW3rdF6Q4piZOA+bFED8BYeE+KCYr1fD/dOs= 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 1789089434370650.8426660337009; Thu, 10 Sep 2026 18:17:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4prF-0000co-9V; Thu, 10 Sep 2026 21:15:15 -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 1x4oPv-0001jS-Dz for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -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 1x4oPl-0007DV-2X for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:49 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49e63568bfbso513915e9.2 for ; Thu, 10 Sep 2026 16:42:40 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083759; x=1789688559; 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=kaM1IZH8rwXzjuP9hkwXbUzeYCNBJfjROb0Xk1J9PcCQZ50Ukt1OVPEkJVukDT3CM9 IPiWsWz0ebmzLb7CBlZuDAzOg8ocoiMSIjvLfSjbtmbExMPWEwSPlS/KeoYFjk6lo/mf 2xN1/AlmOco2mFJVdErH9DhWZ/B99UEmJLhMEOCIlYdf9XzQ8EsEZAi/hAsiV8ToGeeK +qWxXZI4D03BGGQD+2iOLyYccq9mIDAIS8ZOtTi40gWccgycFWzz122lOf1QFIF2YOyh jhIo3kFkQOIDtPLXo/7BVcaKiT5XLEQnNjnoBO+UIERJ12Djnu8mhtAo3a/0F3oF06x5 LOGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083759; x=1789688559; 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=TAvkTbe00L8UwlR56qMAkEaQyNOLZjMxgn+ZSLFkh55R+h5EZnRQ81dvoke9mCFFdZ X2hyke20OxX8VARkC9Y9tHMgbV9HNHgUHblCr2HxFzc6a6/FrJh3Nvyj+8VOyJt7HuAZ AtOOzAkcX5kOcuyjdA7braLRoQra/U6CMsC3ajamkkfPTYTLegIoMktevkDBCWvNBTsN c7hihwG5Krd81EKMf7AcflDfaEqclkTCDb9H1nwtAFaBrYjpu/jet2geM0Y6ApUw7Uar D7amCXVHIwNv2lARamSzAsxmeM2oElj2jnM0ecSuUqio1D8gcsI2muxg0VEJofc0WBS6 rWnA== X-Gm-Message-State: AFuF++lEzVyUg6tBu65q3WejVtLadPaQFR6tK5upfUhU1iU6+geeAAOW Fho9UvoAkVTO1WUQUaecRPTBseg3xsKz+i0lv+IZfuuc9G7ChI3z5qhrDBpLXvziyx8= X-Gm-Gg: AYBFou09l8cD3oo9+jqqY93J1DSj83+eBRN6a26JQjsH7YY5blXPSdHZf1VnaqmKfeO B5yl1VuuIoGQ728CVxlMLI85mr94emXmvdf/XQGyNhPLkTKXYokGJ31bcSBxLXSDtAa+KeY7XRi UtBnYfIVj00UdIF0trbHeINugscaCFZeJiOTYVfjPAP15YiuoQ38HJzUKzta3F37FozQx22/5TX wPFADk1SUvgXBhKmI8OwhP8pPt/sGAc4aI+0exzoB3dBlvMHTz+SMBAp1iK82IrhMYsMf19h2D3 hwrCybn4ydGlfLAMMnBNrWiG3FysvRpTdUxJ72kZfLA4HtsUC2fI+lwoZrBAbGgVp8F0kyd89dX s5wEHdhgpTqxbTv4nTMl9oeKAMZ35LwJ+O9kwAj4IqlCulvcfrqC/4rtwWMcQ3eCZCuOJq6zWK2 hpebrz+7c3FKneC0S2sRqPTss57nDA8f/BOZb9X87lOH/b9e5m85QnXkG84Ss0AKrghE2Y X-Received: by 2002:a05:600c:1f8d:b0:499:be2d:c290 with SMTP id 5b1f17b1804b1-49e6198933cmr15706105e9.9.1789083759602; Thu, 10 Sep 2026 16:42:39 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 12/29] parallels: Limit search in parallels_mark_used to the last marked cluster Date: Fri, 11 Sep 2026 01:42:05 +0200 Message-ID: <20260910234222.3039975-13-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789089435228158500 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:50:58 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=1789088337; cv=none; d=zohomail.com; s=zohoarc; b=AXv1zqMLWhl+i4BWFu8vripIzsPYXx8/fUSx80Myn7M+JJ8w3pSlcRbWRkQDpCG7GNtzeg6+1N467EeNAcqPp07I8lUTZb7N0Sno6aJd7hVqD5xaSL2jfwaILo7ebka/HuJJSE0CincrEVNK9RxvFcPbxWZfr8A5DMzrW+5BDes= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088337; 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=fyJqK+ephVPSwJChcIYmyvr4V0TAvEoFLxrO31seQbYX+eqbW3szRPv2xj0ogNEjcO6FkcA/qzcBpbvvfhKu3o0U6ZbNRWHeHi8+pGTUf9NprGYzAJzvbmDpr9E/hyb3nujaEiS9xVHxkNBxXYh2lt1hTzfz6P80SGGxZUV55no= 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 1789088337660294.97894187732095; Thu, 10 Sep 2026 17:58:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pb8-0005ev-O4; Thu, 10 Sep 2026 20:58: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 1x4oQ5-0001k4-2x for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -0400 Received: from mail-wm1-x330.google.com ([2a00:1450:4864:20::330]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPv-0007Dj-6f for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:01 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-49ccfbe062eso4078515e9.3 for ; Thu, 10 Sep 2026 16:42:42 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083761; x=1789688561; 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=ZTR88fsmzTMZfpNE88CWg2WISArM1zyPSC/+F1evVizQv/ZWq6vROqejSMABbCqCYi 3hSyKL/s69LSVMkbri40aGyOLHUY1RqIM7kjshhn9us2d6oFhsWWxAlqN2EOs/aPItay pLxZgMzzgeyI8bKq+8yef0qZMr7wRfFNL+EyFJ+6SlER/PqtGsPNsPiK6CPuhqwkv5Ht BGUlRs9rAnSFrLnLzY/PlQwJjruLqK01PcHTGrIdWR7gg9SU3gszN/xmytaPoJfqCry0 lKi3Oh+lXDPXlxOWzPBTYp8k2X2LeFYKG1M0aGHsH32w94V9eInJs3Gi9PPn3Mqtz9t7 7EnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083761; x=1789688561; 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=SRIbL3IuQAkVOgtN93cH9VyJz+xTnsa9HsOFYSsf/9UC6fO6Q51Y3f3M/tSGFse8Bc EQeroIydVnuEO2UrSv46kORuK/XEDjtosGVuyVnmeoOcyPNtCy53/0/GQJ3UyjXoGN0Z s0F5qgsRjZoHN2RI0f51CsCiulhrhiFFzxdsbnIYgXmRhjnzBRLQZt+uNbcyBvn+Qihj YsiJiYp3IaNX1C79/s9goPnlU6KZX9WIeqLT6fYtOETo85Sf19cVFyRPTc3NmQTd0xWE 7fPfGdGJj1ccp/1CYIns7XOZ1Fn83XvqjLmsfS5HCZLnu0kRq3Dh3L3R321owJhWanmt oyvQ== X-Gm-Message-State: AFuF++kM9kzeOhuyPMCCSaszLZov2x8HbAxt9S30wKDEI0UVgOFz6QuX iW4Vi+F45Ef7kwwq1aiDgyxuysCEZFEP6dOoIXTYLfE8KzYWo27dFh1FhqgilacUvFQ= X-Gm-Gg: AYBFou1vEbOJb6aYPFSGG14TqSEGFCoWPS58XH3pvCP5461hXxP2hZ69tKrxswoAiL1 8fgjvhmsPhR5iLwZ/Sg6gqXx1EGr/V/3JQtPgXL2G5iI2ZmfsYLvZrSb/s04jXG6w5a/+NFOIWx gy6VtztGl1mRYaV1RkMcBherub1+i0sx4ooM3ebLXmOGX2nH1z7PQeNA/Qcy7xwbWQkTfvBiD47 9kmc4mUWUoRqpH7F1PJ1RMfpzlYWl1a6BiO5/W14rvNIDqJbjT8oxvOYBZc6shYiPCV4CUC0fKT iuRy4vaC7NbNbxAZDSEjkiLD7EyLjEUQP32abjCXvsgPXHUt/gvKGQNP25aHJabQwrKxE+Nh1E4 2kbcrTfxB93cMzXZwlpmXg0PrWrsFABWFANe2ezN84X41ph6A6zo4boRoWnzybNF/Ds3pEXNtc2 AWdsO17qWRej5ylEb/KBnn9UWzjQHHx1QA9/kpqlD65jEWEbVFBlsZhwUAPF5MDKV32DZQ X-Received: by 2002:a05:600c:540e:b0:49c:e1b5:b2bf with SMTP id 5b1f17b1804b1-49e61645616mr16022175e9.0.1789083761320; Thu, 10 Sep 2026 16:42:41 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 13/29] parallels: Move host clusters allocation to a separate function Date: Fri, 11 Sep 2026 01:42:06 +0200 Message-ID: <20260910234222.3039975-14-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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::330; envelope-from=den@openvz.org; helo=mail-wm1-x330.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: 1789088338450158500 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:50:58 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=1789089665; cv=none; d=zohomail.com; s=zohoarc; b=oE9I47uebYMGAFp/Zfccny39mHgkaimeBDCZU82jJuS+pFToDTNJ9ZYQOVqTAkI334+awK/AdCcaINEbjXkO413QiLGkrIaBnhid2QexyKCrdRExvuZ8k2DRRlwgLu0RZ7fwW55NHVgmuVI8d9h+JGxLL42lXRh8IVUz+F34skQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089665; 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=WoaQRB0enYnbm4sIc0bfVZFgq7KufZWnIv15Tp+FdVMmg3zQOt2j99AZtZ/FILMOKJwG05V8HmDnVSaUQFzDLmGPS6Nqq1gEwFXbo+F0ROjXpU3rEen8kZBOv/fokNWp5+t/i7xOBIKyVmWqJRxJ3hmHLHWWEUqSpj4Wir/g1sE= 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 1789089665824471.8006633151117; Thu, 10 Sep 2026 18:21:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pwk-0004bf-Tt; Thu, 10 Sep 2026 21:20:55 -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 1x4oQ5-0001kC-4c for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:13 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPv-0007Dz-72 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:01 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49ccfd61ecaso3441795e9.3 for ; Thu, 10 Sep 2026 16:42:44 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083763; x=1789688563; 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=ML2JpUlctdsdX4/9OgnhtD4rAf4kq4Jog06+vSpMzWJZAiKBKO45edmx+1ugOQ9+zJ RnubVWDuiq4VOC0VsicWl0j0uwNQrbigyp8p3B+XathF37r4pzuU9Koscw1R3BBLNPYI dkF3hnuYSYH+pRiAxiJaZyRm6/3xdw5ZzCyrvlG8UQnkRVEFenrWlCyKSj0DFirJAaUV TSAj38AoCBSKqcdQHb/zRxDXq6CHr6bxjWlNtm1l1Ow8d9zONDiGxkQPynAojF5AxVbh IO7ZkV8odQTQj2CGEmlR1oOQ7zqHWxyoGwcFbfKFYLmfdWJOEJag+K41QaoGLP9FMhnM MmnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083763; x=1789688563; 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=f1lVTlgIDxxAzC5sT3Ag68FfiucKNWlHNcG4ubQ8/hSGd/g+ZrG8dqykNPF1Qo/Yts Wc6YYaya9tgmWRas2pTASShO5Te0flp/xZr4BBoPvCZOuYX8DvnGSrpoRoe5gL3d9VTo ec+/xfthlX4A7sfm5D4axu6zHUKDtNV89Bh6cyT8p8e8DmEmUCsopLH379pAjr2SYK5G 07mm2Aim7FUTUTQL5rIpLJkNA69HPxxLb0u83JzyWiNRPaHMzHxKrw7bGprtR+11JAW9 1IHPoJVuF3+rk+APq/77mmB4lZK5xv3Ld1aNEHb5SR94emxVzH3ODuaYT+IWpL5Fn23L c82Q== X-Gm-Message-State: AFuF++lhB9nkQLnDy8GU54ly6mjR8uixh//GfOT8VGuqz/VpuGDJOIfi U9PHvGA/E6ENMmmdJsbVNiqKQDfWAr9AnLN4lTPCZ/g7yegCjeNJuOes/xHxcQdBXx0= X-Gm-Gg: AYBFou2ZLE7pOPWuV6ndoB2n4Y0VqCJo+87/PFj0aWhpS++gYtidHyGjrayFGRiXD2i Zq1lRK9GqOw0E0KyndZXpHM1Fa6Q3TjYcuOMrM64IokMwodxMISHbgFh3AHZ9TqthCoL+BMAvDM wXq1krK2D5Wx4b+nCa5/bqMfy3UVedw9JpMSbQ2CqUgWEKmFaCOBs7vrFtnI1v+SUXUeDGiD9mh tnp1NbNCpDYrwXCGuQzz/x6rtOusHbDNuFfpSd/5EUGAryi9dLLVAnCZ7ZzZSAkOmCOd+hQxBh9 v6YMeCUMZsCjXJJICpglkNZDpZvjeWD22wnaf9/1WDFcaIqFIlFwx/pNMV7gyp4cpuV1rRK+WFW semXwn6moKylM8X7aH0jb7VAujavBMulQmHMc68pwjJJWCGnKR/F4rau9G2whBsOklZWtWkqZgx /A0kCzPRlyPFVIGFfrA9fpkO7jAxQz2oX2zmJdEth877O0acO7k7W3EzBXEFU8wWMXBe6DcNG6H 0W/+Lw= X-Received: by 2002:a05:600c:3b02:b0:49c:e3ad:41d3 with SMTP id 5b1f17b1804b1-49e61649b8dmr16793005e9.0.1789083763021; Thu, 10 Sep 2026 16:42:43 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 14/29] parallels: do not let the check die on what it is meant to report Date: Fri, 11 Sep 2026 01:42:07 +0200 Message-ID: <20260910234222.3039975-15-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.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: 1789089666361158500 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:50:58 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=1789089442; cv=none; d=zohomail.com; s=zohoarc; b=CvHoPBoQtxORrNB8ksW347gbfIPpzVRrmpaDcegtVHUusKVHpp/Ade8HJUeruzHqUv1oVTbZku5QD5cxnnYs6+8we01boaRBCFQgcL1Iqpkea0JH48FYr8+B0YhLww4XAB4YqETCE374oPhN6dRrJGeQYvKZejtB+2RNnpdVw4s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089442; 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=Zq/f5F0g8g01CsVPFXYRyBIP0tvMF3m8Pf33x25SepO6zrx8R+K4R3/JbIGE3CJXdHKSTgtW7XNTsQ0sWzRGZA5ObtL8paz0M17w1igv6JNOlY4a71CT0xriGEKzqLqMWWeGTiK96e/V6+4pYWZLLWA8rOrpjaWLJexSRmgBmj8= 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 1789089442781825.1697113523225; Thu, 10 Sep 2026 18:17:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4psn-0001XS-88; Thu, 10 Sep 2026 21:16:57 -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 1x4oQ5-0001k1-1u for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -0400 Received: from mail-wr2-x10.google.com ([2a00:1450:4864:30::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPx-0007EB-2F for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:01 -0400 Received: by mail-wr2-x10.google.com with SMTP id ffacd0b85a97d-4834977ae75so135284f8f.3 for ; Thu, 10 Sep 2026 16:42:45 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083764; x=1789688564; 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=XSDt0VYCmZlmW6G+54d/hkZ93kzrTWxECJSFncalOjCJsZ1vM/tVNPtrU2CTpx8BxQ TmmjhZDjf2yfVFUk69AMqm7OwhY1dARJf5EtJoVmgWZAZRvYQPZrsQW60MfFnwMdBkpV 6svMta/orWOJn5oOzqsNOkTyOWVtNzZJl2XM+dd4OwqYoRAA9d6vFkhNnJFQg9WY/VkH G79odwFqEw9crN0iBX029i2g8Tpz7LfsUM4m5E2yEAf81Z7aMxWaOQn0QDrhyvKEnnlq FeQndTPZCzLM/mavrFLEFeVYwnohtmPWpNlCU8OSvZ4cLlNUQq0iLx3riHnoemgfPNg1 PQLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083764; x=1789688564; 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=pQnKJrej89b1lcpR/q+MJ3s3Twue3og3zUtzrEDsfngsjv1NdIY6Qon1P0c3uJa90B 07H/Ckz4bucPCvJx7h0BQxXB7WAaabXIozxh7cmcFl3GVmHC7/4M6yY6njNK0r0swZxN yV+wc6psdPHmq3h40fEQk68O8p1SoUXj2frEDxx3fnRaGr6dOXTUU0DXLvdeTUl7LGTG Pv/TUdsa0I/pR+M3ZKb70nrOgN3cegQ7LI6NqDLqp27yUDdVdsjUaOrjayztsevZmYfN YGEQvBpmK+B9BpLgGDoEd96fjje7HOlxe+pJXXj/+winXRwr9mh+/NAhjDU2MYBYtUSE StMA== X-Gm-Message-State: AFuF++mVGacuuLhJrYH6SAz/34Kf+4al7c2pgQIhpnI2J+nwd/XIb215 +WBv9wDSRpzl6l5EZ6/iIYQ5AjTTkaKX0lPn59/mz00kqECby4StXGUMCX7P2/S3sVlsX1RfqjS d/zzU X-Gm-Gg: AYBFou1rxQqdLxw/mm7jr4+UfHDLESHuSklQaJT8DmoVpTSiMtu1YrdA/TyqRZVbctF 2UATgxC9i2kwrGrh60GgNZ8Yi3Meotfe3K8lm/0g/IS2H88dcex2TgT6Cb2wZmG3qQvDchOVQ/B QyVcTiwCi1zj82E+y8x7Pr8W7bm2DrfFQdl9+Vf0bu0SMlLWb9Jdgpq8GuCN1qShbFocMPNMwHE yTHDLEUcUCR01PE0SnqCw0PNwlK1tynjIb5jsu876AcluFuAJimvx9YoP5UYL9eLdKysoOBoTb/ RSWc9sZqaFa4tO0AjVdDaGNDOXQhtusrWpWaN1drzDpaJMLuQxnEM9GiW5ofolaQneHFoRuXToT EfeWai6PIuf2QyL8TPrKNHzRTPutDvOKgbvwXHZu16XNy+79dnescCdRBOqZ+EU+HVf2tstS+1a SZXXp2KKtUXGc0yJSYShaL2QDrXOzwsK5abwFComoFSlUt+Nf/cAPz03kIB3x3CccXrlB5 X-Received: by 2002:a05:600c:4fd4:b0:49d:870:7a69 with SMTP id 5b1f17b1804b1-49e619b8a83mr24707045e9.12.1789083763900; Thu, 10 Sep 2026 16:42:43 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PULL 15/29] parallels: Create used bitmap even if checks needed Date: Fri, 11 Sep 2026 01:42:08 +0200 Message-ID: <20260910234222.3039975-16-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:30::10; envelope-from=den@openvz.org; helo=mail-wr2-x10.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: 1789089443265158500 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:50:58 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=1789090036; cv=none; d=zohomail.com; s=zohoarc; b=cy1uDfdQf6/OIGDh7fIsRD54jBOBKTSBqYGIXx8iouwswTabzJjp5gf6FK0ZjsRPq3SyqvTpJQhl0aet9rCGMb9ejT3+w/pnlHeQxfD+w8lfwyQHo2LEiojeCrof0xaAq3fsn4sv3U4bskHVbeUJ1ifTn+zwQYAXINcZGRWOlGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789090036; 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=TLTwN8nNd03UZ5GQ3v1JzX1DdFBrexhGteHocvzJarwtGBAthopst0FMr9QxHIcRcpe82eiGXZ7oDgMm2u0VmnoQNc9LM6qXxoZek1xEJYR7UdFzEbTo9FOEvo4h8YbbmnnXBQ4fshcRnxjwTVc8G5Mt6htncdRYt42v0R+UsqQ= 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 1789090036138843.0718708760728; Thu, 10 Sep 2026 18:27:16 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4q2b-0008EF-Rs; Thu, 10 Sep 2026 21:26:59 -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 1x4oQD-0001o3-QC for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:30 -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 1x4oQ5-0007Ec-Fi for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:09 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-49cf4f81d86so2710605e9.2 for ; Thu, 10 Sep 2026 16:42:46 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083765; x=1789688565; 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=TK9gu0fFqSLvXUpNkI0IB4fw/OoZul+0HXh6mE7OhoJIHqz7D/zrYw5nzNkdFqF2CR VPQTBwICnF8KfiYYbn43nwwMu0inbqVhQTdvtHAStrCkog1+/6ot9GZPYMCLdbfOakh1 0+qnxOsPj9QaY8h+3/1DZ2LM324QoqIWp+bhZpqYMH3Mm3WJP25JIIJOmuYm0btix3Ex h6uCvpBuYlJI6RnRNX6odnBA3RXBIyCIRAGLrplHgqNmZZcfysZD9IDuHw7k1p7h+WKR q0i5K5h/IDD0jDwLVUWZkd1Bpf3HV4P/kBVSA/xh7c1atWBr3/nOYNXjfmPF1jNnLUYW xUSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083765; x=1789688565; 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=Evri82oXUSkeHT5vwqRy4CZCAPF/cbZ+xBJZHH/xfnp/VrRGKAjDBrlqyCnXVFFISR T7hSLTyA5/uQetN8PSZ8RA6xUVEo+GLB/MfCpkSymknLDHQP3Gfgw02Za/amij4Cifta hte5dCJ0XaCQkR2qijbowxkKNswmR7PEho9rm49NBx41LDz8PBp37h7lwixfkuMcS6VE UlVyiPNfpCg4QnYt+mCoAIS/+Sn3+pXu/DZeVk9GalkT5UUeWOvaRefSgn2o30tK7FKe +AfFCu3rGn6eOqw5S/ONDwdhvllknYoGX1iAZ2NBlRtT1xAqXRNuXKm33c7opLVyJ5H4 RBcQ== X-Gm-Message-State: AFuF++mWNqNPXLvln9YJXicEiO2q7f9t3UYUTTDFmo8lzjojBbza44Km 0GYHveXG5DDXgSWeklMYOq5rKxdfnpoFzP6BzvjfsbExXyLSrs0f3Jbgj7aZjOTfW24= X-Gm-Gg: AYBFou2vH1f4KZJO4DaO1DYPMo7TSRVDQrrGTE2X1+nv3pujW+FdeBRtUz2gmdaOL/i H+Y5wEkiS2hk/nxh7D4NBFtoA+Ulnwc8uJYZ30/N3WSm5rRqlqm9Hn3S5tx+2zZvrhhkU8umm0u R9OjUwdQBM1ckyBdiFjsWFaZN5xGSocFTEk2etta+p3nrptcbF6J26Rc7qq2erNUQ2PJFq694rG gmN7KYBLgH6EWU9yTHqE9UxXigSdPS36RAoq5wV5cO5eAC4i+TH0D9vH3naiaRIwSrAgJ4UBMcX QoUdBAnI72n3NgOHASqvasS9VBs1ySQoWPKbQmCTYXwgt3oPZGKmg37rmcGVIhrsq9kyw6rKeZ/ +Unih9EsO17kFdhrTiEhij9tOMqF3EmExj9Y1Fqf3g6/PdhJtxtkPI+sf0DpgtAdEL77orE73NU xvB9s+Oo5AictxcpgEZZxhThIB4TUVz/0jouY30sXHl5/wVwPS8NtjBgXr1iVIcD6zJQhOBFaw6 STx0tg= X-Received: by 2002:a05:600c:8b5b:b0:49c:fc6c:be1b with SMTP id 5b1f17b1804b1-49e619d5301mr16388265e9.33.1789083765561; Thu, 10 Sep 2026 16:42:45 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 16/29] parallels: Drop unused clusters at the end of the image Date: Fri, 11 Sep 2026 01:42:09 +0200 Message-ID: <20260910234222.3039975-17-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789090037633158500 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:50:58 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=1789089984; cv=none; d=zohomail.com; s=zohoarc; b=AVX5XoDItfSR3oU62/VIgto5AL7teE0Q+Nbhs3G2lhEkDa2P/5n2ZMWd2AxEHWbTdJvKizBcyO/KMNX9HiwDgK3HittzEpri3j19z1zLDlZPzI8l+alnloFqTAVoTv6SseRx3n/QZItYXwKiS0F/dhl+EfX8nFfv50I4ffQp3aM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089984; 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=VfcI1DrK3v1arE4cchJQb54iHQAKFSeQJLDEkkAD9UNt2S5uh6dlu3azWNZca5NKuEumpjzQd8o6gIZqc0VA3OAN7xqMJ5ssbRVg9Mz8OXkyear2jE/k7RKcNsVBFNeqVSOlf1uaia1D8l1Bym3sJrdn4J2cmH5bdht2lIX4J8o= 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 1789089984585970.1388766628116; Thu, 10 Sep 2026 18:26:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4q15-0007hF-Jj; Thu, 10 Sep 2026 21:25: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 1x4oQD-0001nw-Mi for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:30 -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 1x4oQ3-0007F0-Mj for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-49b0d8bc2aaso4491535e9.0 for ; Thu, 10 Sep 2026 16:42:48 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083767; x=1789688567; 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=sFmmZshpQgqMj/WnnA7ry6gQhaCpFkF2Q2ZhXm5uDo/EovCJaEONK4yuDCrIkIKzzB GxdQWTrFiYEdhVG/GK7JbdsFfkEZpA9FxpwX4ZMM4Nz9KjTTmjfjPeTnBR+OhuuZOpar vlr7QsqlgcrQ4QqdOdgLepUz8WzIWrWewZXZyYvQAOknLwYAQbURkbZ109IlPRb+/8ZC +IwtK4YdWJ4qRi18D84mTjuF1pIQvINPoyc7DQ+AO6O7MT6d7vLvZe+K3rG6aCcZ3ZdF Nmo0pY/VfjrIb/ie+RMRzldd9G3TwK7BvrQLaKF6UTJdOFJjMM4sB17n3vvmz6Q/QNqd r6iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083767; x=1789688567; 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=KLbrY1VjzqNPyJLy8nfL7uxz76B9o0OWgUKgGsouMg3s3ho2iOl0OKggZiaIq2cfVB rvdZspi7mSY3/TRRZRew/Y2Trp15UPasrVdXkz7tNHcEBw5Xp4EU7vBqd68o1hxBDYpf AvdFByk+gPoQsd0w2Do5qiqhJiIyYytay+KeT5nKDYwOfTEHSoPpbLMZWRnwT6Og/rEZ nUulVidM6aEuZ3HiB9RJ11qdRmCTBhUO5lG/0TyZHGB6vsCcLX6StVvvdPA4GmYVTPYu SYerZSL2EjloY5BSEab5Dkz+J+TPLbReNl6u6AOfmGW8uCE0BscHcmUX0aCMflk+K0ih IZPA== X-Gm-Message-State: AFuF++leLJ2BbcDC6bgB5354j4aT49/hCPQWAk7WiQcCiq2h8M82rKaz SgYtImaJ3rGG74biq09Ia1b36Hm2ZeD2zGGtXGA762QWNflx3e3jGveq97AbdUdvfoc= X-Gm-Gg: AYBFou3W4tHxXVN4zedD7UR3Uhvi53/FG4EjTCF36ZxSU4zPWQO/m2uYdw8QiMoAfsl cgd1P2035NHNMyViuVWnv2NXjdnRpuWxjj2x7vzLYCLy+0WpD1lNAjj60Fq+vWU2JDkcxeMVUBT 4gqXRpsBnX0snJ4ira81lkGyUKvYoIh8IB+iWLjGJ34DamHm/Qp1q+eiBXo/jNN9I7bDYlXyQQ/ NQGbKmLx4GiF5o+Y89SDzA82HDWDbZHkjheuWrXkgCqFWnUAJ5zum6WoESuHYGcqkpCXlhnHcQX y7T20p4yP2m652+ccLbktOdAzvAOSPPiWnSJ5wlt6W6o2w6bR0oqLJgum/4hmpwZC9tRNZJQeYa yF8SmfeIvDuiqTvneeYHXngDsEx+tBbMmejFcxaGSpalBhi6w6AgYQAoQm93q9XhmGCDD4EFM27 y2Bn7s96xkIq/ykzP+iOdwO+ciy0Qm+itCR6Vx8LSKVhTYbwKqjKeFtyhsOvA3xjT6JLw4 X-Received: by 2002:a05:600c:5254:b0:49d:5ff:f404 with SMTP id 5b1f17b1804b1-49e6197f57emr16034515e9.1.1789083767185; Thu, 10 Sep 2026 16:42:47 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 17/29] parallels: Remove unnecessary data_end field Date: Fri, 11 Sep 2026 01:42:10 +0200 Message-ID: <20260910234222.3039975-18-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789089985766158500 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:50:58 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=1789088422; cv=none; d=zohomail.com; s=zohoarc; b=inENybiqGFTPL3Quy9tztWCMG9FTEFH7jKR87NCYJ3vRHH0VrdvHggTyXWYDG6lr+nzZZNgc09ftfYwjdnxx1g7lYUDWS6enutsOYswixg+mBRWzickHz+TqAqHfFZvTqfhg62YHrk6ApF0h3z42lMbI5QfsmgvFWW1WafYIers= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088422; 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=TzBlRBkO2o2eeKXJAJ256fU2VAugRB9CcDCNVyUnK7Aj4ldIgYR4lOyy+no+F+nLstrv2H72GkqXjVLD9j5ZOvf43Ht9MehyWDFkzOKRMjzi5ZeMUB06dOkQQMc5fjApmqho0TFvya0rN6vHmY3Vff+XRu6xAalWOgJD1JsAHRA= 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 1789088422486561.3250687072763; Thu, 10 Sep 2026 18:00:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pcZ-0006Gq-37; Thu, 10 Sep 2026 21:00:06 -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 1x4oQ5-0001k2-38 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -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 1x4oPw-0007Fd-Ok for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:02 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-49b392ccaacso5556465e9.2 for ; Thu, 10 Sep 2026 16:42:50 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083769; x=1789688569; 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=K3TvOgrhe8XO1Tcj8YaU+f41aO+qeqGDCRLRIVZ75csFyVBUIXctjJ3HieUDnHc01p IxfZ3R3cfJex4GAP8tadKt0Z0JrxaF/5mA4ag9GlzKNTIqHppHz54ZUhRCdfGLwMDhMi FaY77DcJru6wF6etL6N7sSK6cb8TaPHvjWhoIZuACqT6RFIzH0lOoDrBfTkND/mJAVmB uSuFacphnlWVjAHGsMGdczz8GTgRTPaFdUk4K7cvbNFkZIO45xLd3FANyK0+xNhvycZN FaP6YSehC+a/1owliLZspNCKVG0oc+qwaXm357SS9AOXN7mE+V4DW5R209zsXOCxsPnP hhGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083769; x=1789688569; 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=hVmKuAkbQ+XgMQ3LF3+8CPrDY9fhegbd2cHxmuoiox0N0cASyEj1aFL38DvbNQAK7o EywrzYZ4LgU9jtlloIb/6J6n2HBQFw5dSyDMT1o3U+LXB7nk058qcZNPM4G4HbhSQKM3 3jDsSq1j9jIION/3hD1AaY1ooygXXho+MFQ3aMF7u7Teyzo1VFfx6rMI0DihTvZ7inXS Oyw7lopZfiIvOj1lhQmW1mpiTfHCE28ENJjsYhG+WYl6+hncyBiFXObdjOO6uKlvcDmY 6aB//Bg3mXVnKPhwlt2agtL4MnMUemD0OEiz1x/VdPXHystdhrcZqBoeu9GfkXtI4TJA zjFg== X-Gm-Message-State: AFuF++ko3OdaJliG5t+i4eZ6lpJeuJG3pECXwHeEqYL3ZuJhzux55iDR xLxiChMCq4ao7gwinTDqd9J15rRBWWmK2O2PewjNzzz6MiQOMu+VY92GtyblQi5J7Zo= X-Gm-Gg: AYBFou0X2VtzciLNBxnis1sN/TNEssHAckeI/YkIRdFK/tBfS1aLMIM6UU8UnDojO7d bX3Dffsi+TXB7S1NLoVvl7ZyOkzXG3KLhmpRZZL/yAVrBLXclzbuwAUdp31rKDN6/5ku47TBhMv OrJhlIuVcm51p+QMhy2/reqr85/9yWuoCrsSka3eWc4bhCsMA+eKOsQRDYY3e132IiWeMzaPXF/ efmIGv+woNiu45YpvNqo3WrSckPRQadQykmWanMwOVs7GuAt3/UjdN3Vc4W1CKeXNgXyev9za24 EmnW1o4TA2oho0O83wEObBR6PUsy5m03pga7QfKhmnLRZezrA/EExvQYAMljCg8wdZTvxOP5pyC YLBdeSnEGBu0RH2A46wxykn84lVfJ4Dc+3bW8DpzsyXlsUCwfsrQfv1KIiF7tZFN4TPVxqrKeaK 7uc0vxjRq+MV5rli2h7ZNkWTPiJwsXVvohDXk3wusQe1ucvx8FREt/56E1SMWIIaffdsRSh/DmX 5pwKBk= X-Received: by 2002:a05:600c:860b:b0:49c:fa21:1c87 with SMTP id 5b1f17b1804b1-49e619d1bddmr12783925e9.28.1789083769037; Thu, 10 Sep 2026 16:42:49 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 18/29] parallels: Add dirty bitmaps saving Date: Fri, 11 Sep 2026 01:42:11 +0200 Message-ID: <20260910234222.3039975-19-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789088424647158500 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:50:58 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=1789088857; cv=none; d=zohomail.com; s=zohoarc; b=foJkxN2fUwAUcKhEllsdrUDss6TUPa6yw19vfaN8vomNIJw/qpQ8I/j1TfTj7iT6lJ2d1KBtQz/vaSinbLiv7AHgkPqyHiKg2bT2imstwrp4YFOqLQxHq2ZDKuf+uPBNMvJVIOtu5XwZIg14Upw2i5MACO+M/IyoUTwSGkIB3yE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088857; 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=Ji5NXZWwk7LErCM6iBO0s8rgo3xLk1cPggEG1FmCZyGRvQfMh2fS2DAuZJpH9FtqqW/G1Nf+xC2HytVIa0bkRIZBB15/vUZW3mm4Yyq87kO3YGEbKfDSpFScXpGFhaZt82YCzJYUTo1FoyZQJtqM6bA9mRwpgLWK75GJZmdO5ZY= 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 1789088857438253.2048470171926; Thu, 10 Sep 2026 18:07:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pjV-0003r3-3v; Thu, 10 Sep 2026 21:07:18 -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 1x4oQ5-0001k5-37 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPv-0007Fr-6T for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:02 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49d1fb0cf5eso2906595e9.3 for ; Thu, 10 Sep 2026 16:42:50 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083770; x=1789688570; 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=XKcIojqunHly4mg/GvetaIYYmapsAea+9pfTDj/6OK44fi3ysvmSkC8/W8C+BMaVg0 DsKtmewlvTByzAHw0X7NvnmQfpdypl8a+H6wz8kv/xFr/aMkTAkjkHAH7vxZtefDhwf0 YC6ZhGSh+MEf+ykID2ZR8fNMWBBhpWQXlSOUG+PVJ1jhb0sQrBylMj0J3bwevPrH68q1 UN9BaTN2TjKcINN8JoZOM3Ur66MjavRxVX59tW9vtMqKtZ5MbyKTOSt65lTEA8LdSOET NY7vknTeC9l/rqq4O6oR6lZBTJIr19n8JhbEI9OuhPDdv3MHnlmddivN39YthkrfUMXi NwYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083770; x=1789688570; 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=pEBm9V0rsWqnOn6Qw61aTz8QXpKS//bXAwtl7EJPr22LeiaxH3jIq6PNn1Qb6wo5Gi 71kP3ChGq2A5xnCXU1TVeiFxeSZ+ZLZMQuqfpOzGpL79O3G7OTzqCvyLYfl0xRdVplc8 v5U/lsmOvLbeeck3/CKT2nsTlsveklZ9CmR39EvxaQMRVcvBfGgEPBtweVzh2PBUqfm5 d74KRs2lgO98tO9m1o9gQMTVW0FhVh3qYyYb+6C4MSeM3253v0xCarwaySgij8r+zLuf FdoUIiARTCdEB70CLm956MnZzJnaN0Pya5N1hSWoHeZElr2Lwwl0iDiMHXMGTeHWLg+P O+bw== X-Gm-Message-State: AFuF++lEzyhgth1NHly96kzId3X58iwQ92eyliH22AuX2HIvG1cf4rAP BRWWbwcapX7u+YjRpg8C8HHm0pvR8HJPnsy2YU+BAgAIfvhw8W659o1i0tnK1B3e/MI= X-Gm-Gg: AYBFou2gxScOrKgUgtSJRiHsjmM955HGVOKync62cuootLJHF4QmadzyOJbREMsfAK5 FevkKIEawNUSUiOHEkFSVLVJ4ck0lZyzNlSvSqMGhaN6IILFdPzy7xEe+sj4aZsaaSOKsjhwB0X bE/jnWRarT3vQo8dFNm4lxrlyR2UP97tvo5tCKaOVPNBbmDxc0STzSe9cLwWKF4Y5+0k3L87JWh +4EVmBdYKHxXZlpHMBZ7QJVl2mw6jIfNhMa7NiLUvOzbbPbfaRPg/Hm9Xb/4z09EdpUWkmX9aki pBarzOZ3S33lIybD7tFJ61kk8ecDOsZbUKHG+BvURWotCLK8w+4sf4zXgO54ccvCJGYyezVVDVO jng50pdZowbfdTCrbxAgjAvaCirig25oNNxctLVXJ220Uas/9CTDSMYDExIji+h7HcT9GABYPHM 7R8nHVucEtabdYwBibn8pgYBtP6iVwpMWzdOnYHDXoK7eHttSj3QLH3oAt5oSI4jcmRMqEmXwAM 9YBJXc= X-Received: by 2002:a05:600c:8411:b0:49d:1e09:694a with SMTP id 5b1f17b1804b1-49e619f5049mr31651455e9.11.1789083769898; Thu, 10 Sep 2026 16:42:49 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 19/29] parallels: Let image extensions work in RW mode Date: Fri, 11 Sep 2026 01:42:12 +0200 Message-ID: <20260910234222.3039975-20-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.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: 1789088858815158500 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:50:58 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=1789089287; cv=none; d=zohomail.com; s=zohoarc; b=BRZn54xFn5DNOxfJSG94/DrnmI9a9bROXsvC/nMTWBmFvaLeYt7yPuKUvJoA9G7T7yRn+oD1uq/xP3S0F3DrbKQIbWMV+YBCOpOn+i5DSxpL6KG2Ju9YqoLR9DyPiJzb8nQpVFzwjonD6j8fUIP1hFP6dmlDfKfEhL4NC/OqaTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089287; 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=kM9VQGd2MPVGgUvWCWeY93+LjlH7v9zXfeP5KiPAR8HEkKSbViqJ3wV5HzwtKHjSaLAON735Xw4oU15AXy6W5n8y9awZOlsjH66vXp6FUdxMqPuD0W+m/XWtzp5V36VaOGwMjL919NzNJmC0HBnaLkElr7FE/9r5vNPZNekFtwQ= 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 1789089287933470.61970030993336; Thu, 10 Sep 2026 18:14:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pqT-0008HH-1I; Thu, 10 Sep 2026 21:14:27 -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 1x4oQ5-0001k6-3j for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:08 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPv-0007G8-6a for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:59 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49d1fb0cf5eso2906695e9.3 for ; Thu, 10 Sep 2026 16:42:52 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083771; x=1789688571; 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=hE2AsHPO7iItjPaK2FRzPWMpgBufMch0IVmmicilTvjMfHJBfkAM4HJMWEERiuL8GK OA5GlViTFJSoe6+/DCVzQQac6eDaYLzNUCw9nn+XCDhNavBOL72H+ATd5RcAn87L5Pny Kb84/yG0gv1jhKmMENTwgJ+6vvXTbtzK0iA+RBhGirMsiXZTh+q08BKCmFloKvmL+eam Z968NvAkRrr2cQ3Q5NuTW+IBOTEYF7k4VVzVq/LqFV+2SC6gLnVhZAcM3iFRhn44xzTL hhaTw/iPf6lt8pMQ2zdSisutk/+5nHhR+yz9cpxdmKMkYtWFo5FfNp9LftrVnaoaJ4+D femQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083771; x=1789688571; 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=b5cweRpP9ou11NLBZjcFneZHuEHcDLLbt5+fosesud8QVWRrAEf4GRJ7HtrHtW1i7Y Z35r26r2BY7laJW3mo5Yi+adAILnukYEZ+gNRFk+nSug0eOGvaQB5O12fNT1hceT0HkD XW1x9e3aCvPPJlAYakADh1htSNMAHGDlNAwqqkvXBfGddkO8Gm7horaNeXpcgSpdiHAE gbEvCQfgqA8CgSUbZbLMoco9dyNdNKQgpxbyHPRkmgjIEdxDR9GtG7w98WjbyHU0Mp3d YbIAXFQIJF7y6kDD0gdMizTCFFj64CGyAgfrFKx5K6j+M4d7Ia7ncbJWUdMy+XJtlwYO It1Q== X-Gm-Message-State: AFuF++kMCsaEslf8HMoUeZSPMd4xIOlFNdhWwdQNbpwKV2CZoIqDIFiC 2i9m0cvgDETdFqXeDJie1TwRc5/x7NgHT4TP9dMA1+XCkVpo9RtRiwsEJ7E2yMTi26k= X-Gm-Gg: AYBFou3JkxepMaVacI/PpKu8zuWGe5LjQPgCL9x52u3KVjxKRI/By6QjL5ev5gEeKs7 RGsf4VSKK83E1zsKVfdKsO33MuxmVUk1OJhB+TBBdhDf+G5Sbhtx+p/53SWfNnOObDyuuvk8pu6 NkS0jiLTXGpsqvEtNtP4aDvgElMr3tlEhZF6sbVQeyP7rbbp9RR79A3mPGjrEXRZgKYJXE+6KVz O9LZuoe+bMUuWK4IWMy2pBYBX+H+Uoaj6ei+0jYLl4//qSb8GMF53WoC0m82y84tS9uGVvzsXzV ig1eqdLiHc7X04/Wy7uJ6Aj14YVVj/szfbYtRIIN6n8pdwcu0aRir5S6F1yT9Pp+WVrWrTM24VD DL2L/tFnTT2sbro0cnpse3Ccfft+d7MFS3vTu53DIoxTG9i/XWYLo5jIxKAZe2bwTslUnPAYb8N d4ztFoqPjCnU1N3ZhqLDYavSHi8lwEXTHc9xJbGy17ZIgc8k1zCJWkZYvk+OBxWZlHfjB9 X-Received: by 2002:a05:600c:3b11:b0:49c:f617:7cf with SMTP id 5b1f17b1804b1-49e61645c2fmr26511985e9.0.1789083771563; Thu, 10 Sep 2026 16:42:51 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 20/29] parallels: Handle L1 entries equal to one Date: Fri, 11 Sep 2026 01:42:13 +0200 Message-ID: <20260910234222.3039975-21-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.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: 1789089288681158500 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:50:58 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=1789089886; cv=none; d=zohomail.com; s=zohoarc; b=hqrZ2RfPH0Mh08hxl+FKVMuPg3YLvSbp10oH1kL5I7raJNbyP0UfIEYetplamrMQDdYsNty8pMe60AAQoMvXn9zhC3vUCwYEBGAaP769oUUxs2yLa5TESzPckh20W6aak1ehX0G7DXO2aKYrHKrMzNAylTXXSsVMob2s+VUQJHI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089886; 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=UBZvG8jPb20uSgTCCGOI/gWkPawtF71WEPo7tRIchLiHLBSavz25u8rBcgpl95wr2GcLlZtBngqOPoxwPkE2p/+Vir/+jYrJrTAehcnlhq52BP/uHVtwCtGCjcXrgevM+4giIYrX325vVNvTx1i18NOIO36XeDYETjZ1ptFtkk4= 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 1789089886592460.45387971426044; Thu, 10 Sep 2026 18:24:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pzp-0006iL-8U; Thu, 10 Sep 2026 21:24:06 -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 1x4oQD-0001o5-R1 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:30 -0400 Received: from mail-wr2-x10.google.com ([2a00:1450:4864:30::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oQ4-0007GL-Ln for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:09 -0400 Received: by mail-wr2-x10.google.com with SMTP id ffacd0b85a97d-4843cedd129so168981f8f.0 for ; Thu, 10 Sep 2026 16:42:53 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083772; x=1789688572; 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=glpyB4DxsS8ZWN5aIRdsqhP/0DLwU+xj9L5Ah6WnlWLgweVezaysk8qmjljDhhVY0R Tw8UcKBTHX1r6Qfd1haaduTZSUBsFfhSUX+/uKc7SprjVptMXgB+R3fSa9M6BYNtw/xd 0hZEUt1Resff9JfWQuU9mtt/ZakjTYIOm/qkW+Dv9Rn3fCICPjKLdVG1zs0Kd4bnlm/F +/aHJyTub7PTR3gpehZYbevDMu4xphhzq4ayBZYDXVynaSWc+ydRSoggAIKdgFJrYHr0 biuibFiJhWOIXNmQxUx34nb5nOqbbHGWXpKe87ftma8uGzNvwCPhyQMZy1wtiBJqGy65 HJog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083772; x=1789688572; 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=Yh1kFi1r/bkt6F6M9OZeZnSIwX/ryfTfzN6UTRApj2NJr0CuxHq39dQL/YSZUzIo1w UIjE1FcU/QiVwjmvdy68I7nqMM1R+YOyIUh382ditugzCzNCWypbpMbWkGw9O3W0vJ8b Ih5iml9iFTk0DlPiLwMJfg+CyDvEWmr0YxC5NTsWEyswvXAOd6Tqs7+CodptPFSFxFMq bUNOpW3Ko9LINp1FQZdf5yCeIHpbAsXSaKH6/kPpTHe9pNnHxR6w+splUhKilQX1YVOd pvLInTIGDBkdENo0zA5nllIa8qcxdiw4iZS6Tid9l49Jn+dz56hGQQTZJs9xlmU0p3EE 1AjA== X-Gm-Message-State: AFuF++lmE+rp6wUzpB/OSle0vmk6Hpy1ZbgKkJHdEjKhIBiY7IIz0FgE VvJtY+89D0GyhdGr/w2Mvg8N1gUHvyzDqdGnXqVVxmbsacGRlqhSrSRWI6yM8HSysls= X-Gm-Gg: AYBFou3Da7ap9XM4PQsTtBy+8p+qtLFThNIloYh8cN437CHeBvfUdhJy7WJMfixiiRQ az7/cXDKe/wRjlWC/G6RGNRHDqG0jJenwsXrbCVD8cKxJuNYm+0CFqzBYBV4wYZIraNx1eXScvc eIevVHHJ7ziEvF0IGN/sxwvElfKvcWhvd4c4aT5McKMX2256K2clTgyYQ3jS+p8NcBBiCOQLY8S X4qD60Z9D57ZYNawSNzbJhkc7lp7CJduU0laemZLBQkVxObsaefqyu6qERLDgTp9NB1fBiErFpO ogt4Ae2gY8FItfozPs9FTItjtfhZjq/pMYuRtF8RF5pRmq9O4hXw4fGjy/Em/Rm/1Mw9Dyb3x9p +tA4teLyY9ZPmSoBCK8Mh9hGY3+XBAutF17rTt8SywWkH+8We4BRLmm2CyZ87NnqnTRA+BC/F6D hQNI4HazeQt0DcnXQeUbh3uQWgLmseD4O+IGERv+95zDvZGqmjzTYAJ3JmfVLW9m5S5CKxhw== X-Received: by 2002:a05:600c:8518:b0:49c:edfe:d525 with SMTP id 5b1f17b1804b1-49e619acc89mr36624775e9.10.1789083772457; Thu, 10 Sep 2026 16:42:52 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 21/29] iotests: cover the Format Extension against the leak check Date: Fri, 11 Sep 2026 01:42:14 +0200 Message-ID: <20260910234222.3039975-22-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:30::10; envelope-from=den@openvz.org; helo=mail-wr2-x10.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: 1789089888993158500 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:50:58 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=1789089113; cv=none; d=zohomail.com; s=zohoarc; b=WdaAUibUqEC6WtC3eJlkKb+ggAIqi2oCev1clI9awg8ciQ/Hp3KN1utl/yjINO4WrZRxQWuBnGFVCvlWYRR3gqwULABno9v6Tje6Ylp4KgwqEKyi/X9JzbMFTvz8BNhkG0LKRKw9ms/i7kajaNoGN0EvrWPFe4KgoLHmfMwqV7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089113; 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=RhaHYJIm0cTBn02mxdG/c1H2BL4IKqGZtqU459B6pekX2YmQu4r0LCvbjJmL/Fdr+45FqtEIqcp8dG0H0rPhxR4Au2BQtwPywMMnDNGRJTBiDdqzd23UlrMpyJDM6Yl+BnmrZtdBLoSALp6TVgCDxRnPFyUO8WMjBCKPHle4G4U= 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 1789089113309532.8193575441886; Thu, 10 Sep 2026 18:11:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pmK-0005lP-Ei; Thu, 10 Sep 2026 21:10:17 -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 1x4oQ5-0001kA-4C for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:13 -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 1x4oPv-0007GX-6t for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:00 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-482ea739de2so192106f8f.0 for ; Thu, 10 Sep 2026 16:42:54 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083773; x=1789688573; 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=cUVwSazRTi9UTqONOjXiXqK1cEHTdXcRuCvE319qNJmAiXpm6l4cpyQYpsK6Oc4og/ 8yl4PuFDag3lLIybyj+7JtfnC73MOWEnDot0blCHQAQAcumKzNnMMZVvHLkRVZmKQl5W NrR2O8Z4OkYFVrQi077VEp/4S0F8tGVZTWlroePwsRlWFCGgyIIOK4z7VP91fr9FVl1c EsQhCkmslSkTqtJkmS1J1HtY0+dAp7K9uEelXdon0aDxtqUtrqspwIgcPz2hM9Ddk6+F rkUYOOkjFFdbwZzhXSak0UwuOGeTKZrpkarXPdgnojlIh4eNYAAYKNzbSE72xYuBkDNG gpVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083773; x=1789688573; 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=gs4WnJUn+pC7rYJBeIBprQ8phvd7UeULmbeblmtm9sXeMo6veAMjqDUCR1K6RuyJ+P yA1N+DBeXZNe6gUNOf4Cyes0e0S/W23+Bkt2xVbQwZ+Ft343bxyATYzGo/mMiZ4TUwzt kv10BLbvx/YDxYeQph+u8q5iDqaNzMmzg778LcHacT4edFfFTwgn6EYipIMl5EDavUqr x/czIjqWzO9AMTvYbV0qE/yTEJBFImcY+aCxttIkj4/wl2Rl0JhInWJBWyJmoQk58kom wCacmkltQFBODLHkR2/WhDJZ9l6vPixXXgVbdQV6TlcmT+d+IZtT9TSDYqtyn/HwPx/k yYSw== X-Gm-Message-State: AFuF++mYJ7aT0cURkYPlkQA+9ipLafK+P5b2EOcveAtokRahHpitmWoM 8XvmnyvaVqUzRaQbvkLAQovlvKN688no+Y7UVt8CvxB+yYDpLnH7thZy1sS0o1qB2YskvxszC2O YF+S6 X-Gm-Gg: AYBFou0zrvjKM2cyxGnIIZjaU2cVYJnPwCZPII943trg7I+pK0OvAV9nuKqeeBTGDrH L2hK33Ju+FYFYcIjBdsAWScVE9ySB7gHm/ronR1im8hbCkq8rR5Ul+UpdfmeDaeP3BANWFQhCg/ 4n4hS/7qT9JqWUMFnUmHguYp4JrfzpEAA2KdBaKuPFcTGQ8yjZBhghPqAcr3fNEJ+aLr5vEKu65 6VGJByH0Q9DtWUYTYw3ErFuTMXpLGq8b+zhnqijoBjF3HKiqsLBwY+lwMzjDnf8NW9sfIcaqEMj AVfTCfwjBOmOdvXef1XfFVT4CfZkPJtbRVDCMfXqoN0a4k2tuBl7ImCREuqrhqgRvDjWNptkXpN 0M5SPw+ryevtpX2lyJOu8DKIsJsARmjdh+FPivENenZemOHcCCOgIdDk12wj/uKD8J+oc/joruu 9eNRSd9ykE8u8XsW8VjnJBRqKxO5GHEBt6W72zeo7YxI45naGPA7i3Va/fNW6DEPi55h3bmdnRW zXoc/Q= X-Received: by 2002:a05:600c:1385:b0:49c:fc6e:a3d5 with SMTP id 5b1f17b1804b1-49e619bfebcmr12244635e9.20.1789083773299; Thu, 10 Sep 2026 16:42:53 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 22/29] iotests: run the persistent dirty bitmap test on parallels Date: Fri, 11 Sep 2026 01:42:15 +0200 Message-ID: <20260910234222.3039975-23-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789089114065158500 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:50:58 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=1789088540; cv=none; d=zohomail.com; s=zohoarc; b=fEbLRzq/AEYa30Tu8itxkhie1oJD9BkxcuEqhg/R5ihjPMhL4dwpEW39wSeu72wo/Has8Y37wTcwck65/k/TTB7R5wA4PfQtFtG6SoZFofj8AMgaOgogeXbV7R1vPPbLXwyCzD7MyjNQG5UpwmCOgK5rlkCGgCSTfbaFAx7qDoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088540; 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=SwN7wzMUvfN/1QBnRLRnnEYtFBcPibFU4dslZPZrRL4c0jo0XhclOfTISTxW1/DNHAwmScjSDA4HzhXfeaKN/0WLUCu9Y5LkTN6LJVa7UaWoEycoavxOU/+edkendZVD2KDnt6/EOgoturDChQ7A4INqz4feqA3ovOj8u+jX20o= 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 1789088540285537.0686653247002; Thu, 10 Sep 2026 18:02:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4peI-0007ve-1T; Thu, 10 Sep 2026 21:01:59 -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 1x4oQ5-0001kB-4Z for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:13 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPy-0007Gl-Iv for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:03 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-49cf4f81d86so2711035e9.2 for ; Thu, 10 Sep 2026 16:42:55 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083774; x=1789688574; 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=hTC38LsJ2zOgO7ZUJRFgdsd5HYLHNE9buGKuAh+GEtTAIKEceDZbEvX1VQGkMMadFl a6jkeOa4EBh7or0tNwya4RYAiRkao2Sfb7nqnIIIkUImdwci4yEor1Cu2eesVowfpt0U V0DrTS2benToS6y9du3ZLpDhDnx6GDfaKWZaN9U00g0KH+GZo8ZUccSHNfK9PWUic7J5 FgsgBZM39wxFb8KDeFQZ0dn13sKUKAQF4JkRsd+xAk9abhOYuCnP07MAT/Yop9ocjEcq jrhrvOOHZtvvbnWGP+0x6Lh+5Ex0g2n21RDJy/uVDLBOPCX70Lqvhmrhan1AnZ5db4Ur UP1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083774; x=1789688574; 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=GWJMqhg7SdIxfklRs6hDIf0Q0lifvd0hp/wBExXpbW3+MDUTEk9jaXYAl5NMepIlkE uIrtiBuq0PMN+m4P1o00Ul4ceeVowwy1arv64xMzqhBKWS6eLyK/hrBP2D534HKWj5hp aUpVrJvkq59sSmIdKw2IQQ6tjHLhpjQRtlq/bn61N9GbMhKlM1Phqn1hCQY7S0fbo+PD ja/isqC4sKlnxBZtM+Qb0zwaEHlvNSHfK0SNenW09MuNwoi9WQdmOPutw9qkO6DpbaB4 81ycEWwvTeywDtWmT+pG4FvhXzUX4T6RhIxN3fwbnOHz1KStNoiDhnkQEIcYKhygjRBR HjMg== X-Gm-Message-State: AFuF++lU5BZNz86dS+i+VdaQCMGgnbF9yhdDjOG9ewx4RSW8rBAsU19z uvO1A9qRluPbgrphBBxWc6X2dTd7hVUAElF/YcVcvaYIYTEzFiwWm5kzgIobHNCjooQ= X-Gm-Gg: AYBFou33Avzgm6JY60RmlgX+EqPjN2DoapWOZVVQZapXSLMT8A+z+WJCCxCqmNBvw6n 6vukChoiGimsNuY4xcDUIDP1Vqm64NkgxV3l1J1OcC5U3Y6nWpyRIHtiFD0YvSY5JLfVdsZ1W5K VYAegdQLiOBAblfT2+oNjJ0qfUYLKVJi5TDckT5fo8zYwv19ezUUNYSuUbqdc6kaKemRvnZ0saG eB0BYjAkRqRMztCXxjhb+Lx7NU5Zv+HGxIsb4tYheJ4FOZJwlVsP97Gsr8BvaDI3fWLaI4/37iP 81JnJBt6ebNdYTNI6nw4iIkC7gQWzn77iu9zYl/Su2rmuw7UQA8jTnC0X3bgxbuFVe15V7ydVOY XSQ+Chk5BG8Klh3z/zwGfVOFik4irXTVkyvnBzsVdf8NyyRv2IVy/RUOqY9RwZy13jU+5B0as7Z nuX3HalKDizVv76gpnDijTGJmRZ0dfSnAWTYulnyc+Rqb7RA2rlxqmWDsgWHxUMgz5ki64 X-Received: by 2002:a05:600c:628e:b0:49c:fc6c:be13 with SMTP id 5b1f17b1804b1-49e619c6463mr14713435e9.25.1789083774266; Thu, 10 Sep 2026 16:42:54 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 23/29] parallels: reject a bitmap L1 entry outside the data area Date: Fri, 11 Sep 2026 01:42:16 +0200 Message-ID: <20260910234222.3039975-24-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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::331; envelope-from=den@openvz.org; helo=mail-wm1-x331.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: 1789088541268158500 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 1789089643516182.24468426335034; Thu, 10 Sep 2026 18:20:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pwN-0003xv-DW; Thu, 10 Sep 2026 21:20: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 1x4oQ7-0001lx-EL for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:13 -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 1x4oPz-0007HD-Bw for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:06 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49b8ce9b733so3085345e9.1 for ; Thu, 10 Sep 2026 16:42:56 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083776; x=1789688576; 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=caFJLeInJyvRVlxbo97whX/gslJm9IkQRLBjIs8cyzaT2yaRwWGaA7/njdo+AZfw17 OpZVJdpIsdPyhoxD1jFE4OtjhfKO2IPH2Tw16Pjdx89EAlhAch87N0+gt34PozZ1iGqj dN9Ue9TmYm60F0dBxQaQ4GCHRB0jdp8DZCOU6LTr99L/p1+F+YgYAK03EIGdMzUo0TEh 1TPF59zEkSuQkfvq+vi28NNPlsPv4WIzarxDO7sZN+QcZ66jqcO7LvkP8GuZ4iGhk4pV cy3GjszAD2Wn9h/B9zzDJfqEXmyQnY+V6XE6h2Ql72MDBQdx0aOeo5EKUlgIpfZWPp0j QvxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083776; x=1789688576; 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=Rl/2oR0JhJ60+T+wgj82+udRV/6Z6aQQ9zcLqifcGa2EQMFvqdwWQYd/y/K9zvJ/KK tQ7rmoBJfAocj6ULQ34Smje2OwQxocc19iGS3qmj5V3jOexEWf+XQVAuOTs7KXLh1vzZ wU2kMGhlp6ojVmJJhUCBfaQimtfbW01LKWoNDnSu7lzK6P0JxdxOIn11CQFADkhSZgjI MLJXiobaND8Hd6hW6MHcphiIq6Yzf77WUibF0B+vYu1rmkCI469hr+1gu8IEGQ+sTqrJ KSs2psZ1i+x0lt7SVoJ+MckCSn3E6Ps7kOgk2WykVnG4O95uHAJEvr8Ea3JYq6TDjpgY rQkA== X-Gm-Message-State: AFuF++k17wcfV5pmy3Z1GXT6bF75tuG0p8W63doiWPv2sUWOKjbfR5xt fIkJWIFIYAtVbrWVFVCElZ8SpR4P/ZhvtQhNiajr2wcdWZLxGD+zTsSCG1px6Ji4ihY= X-Gm-Gg: AYBFou2solu6u9jPUojIo0+bTBqhqZuomRwu6b3MIeOddxRt+Kbzc4Jg5BB6H1GkL/M PLSmE73NPeeFCvlfJnpxmZFL5vSMybdSLCBVGrxlH7p6E/r98L4cy0GbUTio+kVg2xbOtM5947B kSWMtUgJW2DHLjS4nvlYXWyqcEntWC0BwHl5WOOPscghd3v1PFhVnVHHCImmcLGzwP5Ob9YnryQ /Pi5OUA7n6JLe/Foj+NUhVLSFxfzNifGFsQJwtLoMIvWSz28tPMY2OKqeaJ6RS4ZwSUy87GTrt1 2ZMTqDurazj5cg++00oga/12uJaurFtr3VC5X1y01BxUp7hSvG2ooHnsNgvNDUfPalE+eXTr6is lsGLR7UmFEI/Q3m7iKAiOpfvhfhhxQDMDPS0GhGa591oyraKxzjka+rARbo5FeYFY6+oCTsQs6G PTcxUBGErknkO9i6SypPSUDSsaNaH4Q2Xm9BLToTnPM1MSzpupmgNGrl0x7q7gJ2u3YCpt X-Received: by 2002:a05:600c:628c:b0:49c:fc7a:22d5 with SMTP id 5b1f17b1804b1-49e6188840amr15147475e9.4.1789083775932; Thu, 10 Sep 2026 16:42:55 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 24/29] parallels: do not trust the bitmaps of an image which was not closed Date: Fri, 11 Sep 2026 01:42:17 +0200 Message-ID: <20260910234222.3039975-25-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789089644402158500 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:50:58 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=1789088457; cv=none; d=zohomail.com; s=zohoarc; b=e0OluRk12JbupJpDNPpm3wNYl+n0Giq2UBwliT2OvT04NeYoLICHjgA3qZgEN82lLrHJnu3sEvkOYjkZO3F/DHdh+4f95FaCeUxx3qpjoGUjWfQ3ebLKXs9PtBFK9Pfhfv+wxsr671pSH84qzo2E4pKqGpEEfxujj8AJtI3o64E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088457; 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=fMlcK/FuXZ2OpA/PYLHDtu3Gv1KaqS9BKHK+5c8eton7GDkbnkEj1jy4QtGAA1+XzdEI3D4rQ9hm07Bk4bEsHXvFCXyunFZ0UTqE3jRqYt0cVMNk4v9Cp2VXTWXLaO4k23HORlyglB+7pQurVtEPNh6FzQDxWGtCe43rimw6v7M= 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 1789088457980479.1546994074183; Thu, 10 Sep 2026 18:00:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pd3-0006kD-DX; Thu, 10 Sep 2026 21:00: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 1x4oQ7-0001ly-EQ for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:13 -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 1x4oPz-0007HX-9g for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:06 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4998b5a63e2so3765755e9.1 for ; Thu, 10 Sep 2026 16:42:57 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083777; x=1789688577; 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=gN52LkROxvqyqYhkrWHxveV6rpRlw2LBcfTqmrCQvxizJiIVd1uvZyNdcn8FSwpznF l86l6UPL1Pj6xgr7s6CpYbI72z4vr9QfG1xXB9kbCBK7HW3B9lMFnZcZg7GzVUSIluqb C6/d4mYtvWOdtGquG4lSDbL5s0epzwsWhUIZpE1fSQp+pUpVlWVANOuY3sIXbQ93VyhY TZzI02DFg63NLmRfqtxlyAiMhUUiFc2Xxz8wrKppOuZEt3ZwRTyprJA7vVbBtQAveJT0 VxO3cqGYbAJdEg+xv0dNV5lWGeQCsWgUU9gBaMg4xCT1UV6/EcnI/oeWrJcHaMFFuP22 Yngw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083777; x=1789688577; 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=G+irbRl6thtCbL73ghQYzl9tweDRa6sFfNhGCRzw1V/HMAQmQ6piAw2iDgrDj4dJp5 Np+z/SblDknk9BnPYJCvs6TO1LcygYZFEheh/j4tWMuFWP65DxXDbGmLla1+U+lEoiAb OFGFpHV9JNrY5b1jme9SiQFmzY4Z2fzVslOeca3sQCy8D9uL3MnR6vmtPKj+t6cSWXQN a8TF7r742i2UpkbXfJum/7lyG45Fhs9h5tQy4TsPeRrg3Vt0y+kdk9AivSbMzsL760sa dKEFIoRm8Zb0/VzRs5GWd1sL+7JrrQjjORgCGakn3M1d+PfsxevsC+Txa/VTRt8J9gNC qpfQ== X-Gm-Message-State: AFuF++laj3D5oIC9fY+qnpiZvt/HsuTY/uX3sMcpCw8rKGEwO+zJyh57 GUs5tBulxIAym+aYirHD3uq1exc60uQH79nnNBktaUnSjzccbezipbbabEwCnP/SNZlPjxwb3sP bQ7XY X-Gm-Gg: AYBFou0wrN5WouKQV8Tt3M6qDNm0Z+ET9tJZSmI83Tk8f1qkZaSFzlBZD3n9Bd18QVk yxbqt2aFhqcu74UKVBN6qVP+jxNJRZ0NqQeuUXMCAyPGtN8QZ9jQ3qOyP88mWkLJMNw5lC0/yc1 dDrsTWfNe+7yeAHeeSOGytEYzQDRyjGpOnjE2dkCDjb0K/ukfhoSMY/owxnOzAkSGLzUuNVSA9J jljDJofK/LyaPkyO6y9jsdIjRb0F8Bo64HIePxiFCmgSvRHuCPyhY9KSklvTElfobTUQSppBfEv pyOtC8xgy9evCBF1udh5I/sX7PydP1lVEWBOgLyqBuOYpEYLY51CxRuhVDefzXqAXbb03puwSUV GZqcHzeMowGjiZHJQOhal1SYRmrZl6l4NNU4h75OBZdua0L11g0La0Wye1/5FVNFAhacuzRppnc 87TTtxkzyz5jNwcblu88g/D4u6xdMlAdg+wWOQQA/GdRa+u+Jt7Dy1P9zNhUXsgKxczZ+VFOgpi 9rQiDGV X-Received: by 2002:a05:600c:3b27:b0:499:8b13:3a98 with SMTP id 5b1f17b1804b1-49e6197f60cmr15795895e9.4.1789083776764; Thu, 10 Sep 2026 16:42:56 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 25/29] parallels: implement removing a stored dirty bitmap Date: Fri, 11 Sep 2026 01:42:18 +0200 Message-ID: <20260910234222.3039975-26-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789088458866158500 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:50:58 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=1789089784; cv=none; d=zohomail.com; s=zohoarc; b=BPEAdCRm2bF8cF28jGPlKhxJ8tks4asbMiycfR6qq5kG7g/Z0AiAoQ+sHe3wuYCeK2Kg9ojw7KkgFaXkVFJOeTZms1OQjcA2U5hkS9vvHnMtBdOrZOgV+BzgCPp43mLOhJUf3G+BP2lTA97tOgwaDNeSaTFJ+pkU9ISGAOj5XXk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089784; 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=VeNroPY3Xs1tPo3UygOt/ssq0zJBhv8F+DLTT9CrgSb5MQiqARvE03D10+JfHxfTFdhDGsSeOvTDljvBpelGP9f3qeP+U6fraAba1aco1B/p1S2pWqFuAjezdUU3PW2IFnWZxD/dS37MloghTOPRdlzSm74u6I/M0u//gudfnwc= 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 1789089784178322.3605580988485; Thu, 10 Sep 2026 18:23:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4py5-0005NX-9R; Thu, 10 Sep 2026 21:22:17 -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 1x4oQ9-0001m7-1g for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:18 -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 1x4oPz-0007Hs-Cc for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:07 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-49e625d5a2fso750245e9.1 for ; Thu, 10 Sep 2026 16:42:58 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083778; x=1789688578; 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=XvkbJ+6UZce+Y2U5p7yL5OXZ778dT5M47tZMtmN0AJuK9Eews1rMKMWPMeyjtSSwRn KHk8o/Ivm8ZDhA6tT2boT4Sz0/dQZM5oJ2H65nX222ko2tfl6oL0eQ4RKzVKp03vl1AV 5+Sh0h5PfPQYfl6lAo7MTq0yEscA+e6Ws8Rq/gZSnzwdCmOJ/+vkinXhjwMOB5e7DFZt G5wdxjwSYXjoCG8U5NE2+4OWnf7FuvphQzAZ8hdAUKtfdvQmsiKkdMmg2ZFewQgMfr1S +HXmAFn5TlYdESpKievJ054q93nSxr9sSQm0oZzQOo8bHE7eXtUn9nKn7Yd6zep9QztP L+HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083778; x=1789688578; 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=Q4dFvCyYCAkAUSznNVEjrOECcf07ySh6uBeKtJPE9k2Idl8Q3Rm9GDxygoSrQDbHHB khTzh62HpMTSBYoG/MEH93RzQxmU3WZKj956Bfi73ewPIcj7TeieDsNlReiYAb/t3/Lm eQN3y1pxz8Th746SPNpFuDPGpku9euRDDTTSX+/83YJhDNa1jutOxmlRS8xcqMqin2wO VR0NF/0XZR4+uCjr/u2W6XLEynzsvlE4wpBBmti0hV/ZB+3Q7wX/vQ5UHtX78FMSFpNb /Et62F5VWCCL/bJQ6S88sxEceseb00kV3V+TfO1zqDAIGxV4kNbgdiYto4mb4r5CBNmo QAEg== X-Gm-Message-State: AFuF++lto1M3O+Uyhenys1nwT636/8FCwGif1aiafMi0sCJp0PdLkYPy xAOIfGd3Je/XxPKCtCdyLi65JPJ9wzVkxiHjgsT2aFRSlkMqcupMSpWbh8MSdgkKO7g= X-Gm-Gg: AYBFou0WFfYgapluol7d7M/QTeyWxo99t3vFERjd2ekYX8OvrFv665laxVbkuR1ZJ7u 9Q9AQJj/0Pg/oo77E4Ah5DVqVXUCn8mlp/GNVnULN0Zm2nENbzFfVODMCDDwZkxmHI1Z5yGG/QN pLItVEFi5StJyYpoJltUWVMQOq2bCi0ZAypMfumc+PehGP7H9ApC92IIJYO0qfSBSNxcj70YWo0 HF0t+U5myl8Qihi9QbDAqWa0pP3p4438LjxArTnIFAHOKYt9AE/aurHWPg2VfqwigTGXAT4JZag 2PsNpzSdlmpzuCVZ/qhIqhCnGIOD2hfjKhlBfQz8Khpf9kIWdpkxtZ+FsI13CeZUWh8Bh80hlEW mBDEmTcXPLvSSgzgp03+JW7Xq8Apx7e15ytJwEsqwwOrEBvf9wEY0KjW+26lxY7K59PBOhCvsHZ Ny/7aV1KYf/OJBW1wVbOJqmUoGlogeSKpgny2qTA8QW+VGFSkTPD3YDDebY0jALIjrmdIzEw== X-Received: by 2002:a05:600c:6309:b0:49c:ff3c:973f with SMTP id 5b1f17b1804b1-49e619c45f9mr13340125e9.24.1789083777646; Thu, 10 Sep 2026 16:42:57 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 26/29] iotests: rename parallels-read-bitmap to parallels-bitmap Date: Fri, 11 Sep 2026 01:42:19 +0200 Message-ID: <20260910234222.3039975-27-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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: 1789089784504158500 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:50:58 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=1789089181; cv=none; d=zohomail.com; s=zohoarc; b=L04DiS5shSxmrGQfNeqMmFCnAW+FO5q9NdES4RldeYK/aYUvqStoKaPt9k6hl/2HZ5EqGT/XObrEze1iObdrj2td6gyNgAzm/oZTiaxOx1aHQT7jNp0DJirf3Dcj481o+/LSMgzMArIhR3js/bw8m4cBECVVtsqlq0rxEF7NStE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089181; 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=KBQWjmnWxK5AGiIPcjxX2HpmXbRZCDWYXApPrBayYlU=; b=ImdIqD+qLLIa6zzYFfOBsZj3UJ+JoFO9uEvBmaxqJK0fhQl81dGw5uNcpu8X+1nsyh0hoObZ6tsiQCHnEAdImYh0W6TNCv3jeq7fd2cd0pyemmdt2rB+VDxVVa0mkrsXyUqltFaYHZL6y0ro8YU1rwm6iONkDkSCNr40VCHdhz8= 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 1789089181296149.72035780506428; Thu, 10 Sep 2026 18:13:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4po6-0006u8-0H; Thu, 10 Sep 2026 21:11:59 -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 1x4oQD-0001nx-OM for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:30 -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 1x4oQ4-0007Ia-M4 for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:09 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-482ea739de2so192139f8f.0 for ; Thu, 10 Sep 2026 16:43:00 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083779; x=1789688579; 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=KBQWjmnWxK5AGiIPcjxX2HpmXbRZCDWYXApPrBayYlU=; b=lYatt7Z4RUFsq9DhDW96CGhmC5Gx5lh6Tpx25GAxxwThm8mENAqIuXyx6AdOaU/f4n eZCl++SuVkz0sJgtFERI33BQH5a6EiaSQEe6LHgs01bwcOJ7HFa2aak+TSz7JEz25JlV nyTUacKG8w+2+69W9kLkwgTZiFGDrI13Cok5l5JlKkCe9CuYH6hXyuiJ8MZNoafWvqEO VxwI08iscibEIeFveGWT3Qa7rsgLTn1poVM330+YE8FBQ+Pg791H54mQWvXmIlDE5OSW nIIkJilTuEkOD+UuIW9m11rTsAOqYh7Fapm1M+l6salin0n24I1vk8CPiIbNWOMpZh+P 5hJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083779; x=1789688579; 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=KBQWjmnWxK5AGiIPcjxX2HpmXbRZCDWYXApPrBayYlU=; b=Rf7hCArBKxhZsnr0BRJ6GhcF2o1A2UYbiVhfMFdMmrHpHJU8bMF48YpAJhzWLhG5hl Jb6OIXCei+VjXeKVPdinK180y/zaMCqGMkv8tawcIVsOM7ThP7/Mqh+co+uTVeJYtmZ+ RAqg7FgJna8rBXEG+GogVpI79mrarWFtxI5+VT6tcFkhBvvrdDZ092tx5nOT/bRibDA3 X6xcDtsXvsneX3r0rGP9XWtx+pMetdbzeX3ea/0iofmqIqPncirDcDKrT0QQGI+VeP5a HjP5G/xmzVF/34lUbYEYMknyx39sSSuMr7xV5aofqy3LuinkM+ZDVVB5TgkSVsoOJy1z fnIQ== X-Gm-Message-State: AFuF++lZo3PkCWqx9n82P+ys0TNPHkOXNNwHZTO1kbOEyeylu+bSfmev QgYm2XHLxQ5gDMTqZnEbDf73lJE1HDaCiz80f1Q/81wNhOxKWL/5H5Ado6jtXxXR7T607M/0fs2 RIXqU X-Gm-Gg: AYBFou1gMAtNXBxo81aCG+y7BR02HrKS9Jr8xYj14btcx/p/PH39NqGvvT4oAWNdygA nVXOGu0lfauutFELVme+1DpKC+kFNFqwgCtG4SxYNv80HI7xBOt2Dr2Bbhd98eoFITyfhNdMZc9 v/MnJ1v1Q1rGutJs2npR6kojaL2CYu68nbvFNdwPS+gypJrbJvD7Ne7WUDdd52S3PihnsQY2m1P V4z3mCZh/28HCso/5bsoABcRdFJ4+iSB6qX4098aGmd7wWftPxH9lZONKJsllerRvOVC9bBUy4c Rb/jQoNk4AfwDMEMmFsYAq+5PjX11/y9RqIE1vRYFVn4IwYYdS460mxMcDNWAXXZkTAD8futOj2 wk8zrLIQKoi35Z1J9LFDhmmuvpAivYsjs+0aXzJmK2YX5PVJcbww4P+gY9u/vCNWhXb/QX4t9lW 8DEV74S6RTtmOPEbZvvjVTRW8CkyHE1sL1+pBYbq632EYYJ9vcZL1cHcQk72rVMAj1q5fG9w== X-Received: by 2002:a05:600c:6296:b0:49d:191b:88be with SMTP id 5b1f17b1804b1-49e6164a26dmr14599855e9.0.1789083779399; Thu, 10 Sep 2026 16:42:59 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PULL 27/29] iotests: cover a broken Format Extension and a combined repair Date: Fri, 11 Sep 2026 01:42:20 +0200 Message-ID: <20260910234222.3039975-28-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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=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: 1789089182427158500 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 575b736e35..3e9928c9c3 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -437,6 +437,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 f390ea90d4..871a88d924 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -283,6 +283,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:50:58 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=1789089261; cv=none; d=zohomail.com; s=zohoarc; b=bKkYwgGSfA6weUkJAhnKnSKduzLK8nzlca8zIrBbi9AJYItg+dWzWan6JSbeA/85rmtc14zj4w7BHenw27EEIdsRUzgchobbeWsw8BSZT9GBCmaWijc4+IstirA8G5lCUPaIh3t9cS2Emaz+U5Id0Qsg97ivr+BQ2OhkTKS/kto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789089261; 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=MGlbl6DW+WvvCbKMZ2NfTE68nrBG4OqOWCPlBK36oYajwILjFCgHlgXEXqcNzyJ8ZSrtiBGx9C6DkcTJKwapH0tzqtRhrlwaom+i7ZuLOKSNQpM5Ch/HIFITcV4HVMickFwlZofDADAyfg3UWQA5j7gOei6UU2t3KTNRtGxuz38= 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 1789089261522508.9535422729773; Thu, 10 Sep 2026 18:14:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4ppO-0007cX-GK; Thu, 10 Sep 2026 21:13:27 -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 1x4oQD-0001ny-PS for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:30 -0400 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oQ7-0007It-7K for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:10 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-49b0d78a801so3505265e9.2 for ; Thu, 10 Sep 2026 16:43:02 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:43:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083781; x=1789688581; 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=lVrmdp1LMxvSVaWL4msmkJ5uOa0oIgh89MiCTtGHZkhz8gh1kPtDRNnb3F3l3tNY6U hzGtjyO7k46+4F+epLRzP8+3LELcrsm4/3XlVUQ70dS2ezjn/iVBrYrIElgNRRSxPM3c TsyfNjp7XFLUJP4iDLQe61E0IiYVADwCc19SWtuqG2v+93jEBCQNbp3tP37o+4/babna Zy/Edc0QX6i+RG7DRP+5XCoePr/0DTAkpCGby+nvunolrlgcJU66ibYbHg8G1q/4okUR aQavHbugPY9USpCew5myGg/hZ8AE21o+b7j17e3P89n6hpPyMKvIGtUnhrySwv3K8HzT mj0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083781; x=1789688581; 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=JmCAUhnHHOv3PWRhCkoLzCG6/xMiPEbtjTPsA9bmR3KieoYCGwx7E9STQhOoRjHtmO u1H6P2uKHvtxDAALPRwek+SvLDdlTB6AH2FI/LR4M5KFEfhkrVdy1UCpdOt1aJ4+t2eI i2kSnph2cgg/4RtiY84nAHT7N3o1FWssiCtnpXUhAP6dfl6Z9it5Q4DYBWrdk/FjQkFo iLfD92RZBlv1CAZR01eyEMuMWkiRhYHeWXO1wownbX4aDyrnKBbKc3FUsbPqe0QTAiJ5 dCY7vV9omxwVK1Z8D/yZnmD+SVB8vTaOCk8EAzzGc1pqSqLRa2pB/Ekwrr/zgfDLh+aJ hVlg== X-Gm-Message-State: AFuF++npNmejEzzPdgfyyUQMWmunb6aWAoeLSubheyTTnv6JCTOFh7Pp f9zeUqKOUvFoCOmLpOKlKNxaxU65YtTH22GpTi3edQrUbrY/fBa3eduz4JwaNItgBIY= X-Gm-Gg: AYBFou3xnYP9OpUQziLj4DhTW7SYS459IskDfJ62PPCDYK9MdTKFY3yTjyLDeU84HFK 4dMTDNk6yu9kpMyeLovahE85p46EZDrQB9I2gleYkhIWib8pf3GxsWHG5XQ/h6A3YFZWFaK5f6L OhZIxX1scWCZQJ9GzGaX5GUCH4YI8PwjuvH8pWIJqq8Jmvt2DNEJrQx86OCdhaLwLN0QbBaFQVl E/QkPBWXttBMLSHPgHvquD71gXeoEUb+L8/7XD+5YS+ifVqvRNuFbB/76ajsP2mLg7xICMW17eH KBG1DZgTTcTI72MWdofoH7bqL46oNsMsBZlavs71uCnbDKrihm6SzUT8fDDjft2B/nnGz5ob11C wECuLg3cyrtqDeC2Po9Ya/9mmz+YwIcqzuRK8ouWMq6Gw+bm/048WpJn5aZ17Oshh+08dYH6Qhd DaNkGo55WyS4AYe5t8mPfOXKx3VZZcmvjegvTUFUHihkfB+O4/3hhEsEb87AplHY04IRx+ X-Received: by 2002:a05:600c:3b1f:b0:49c:cee2:1697 with SMTP id 5b1f17b1804b1-49e619e0f85mr14174575e9.16.1789083781264; Thu, 10 Sep 2026 16:43:01 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PULL 28/29] tests: Turned on 256, 299, 304 and block-status-cache for parallels format Date: Fri, 11 Sep 2026 01:42:21 +0200 Message-ID: <20260910234222.3039975-29-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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::32b; envelope-from=den@openvz.org; helo=mail-wm1-x32b.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: 1789089263013158500 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:50:58 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=1789088604; cv=none; d=zohomail.com; s=zohoarc; b=LVR8wK4OMfCK6LFzAXYdmg5qREhe7aWmvShhHOmoEmDO66k+WevWGiojCWQyDmgX+hNVnIUdO5zgCRwWJXATUwgccUG5VwOYJukQn+ecQBIlpJWjOviezro2iLcRG0apg0o9XPDe2aFEXbw2OdPAViee027J8BfCbp/L54a9oBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1789088604; 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=2rJYFRyBF3ve93GuQi7uuw0NLh/T3juFuRfoIczr1YA=; b=Df0EF8MUXFtCRjZZbD0Iy4IXnhh+U9/VJnICP38tE0wwE8gkiaTipsb7obTDjQaf9mcj1/O4La5H9nbROIsOsg0A36uw6P3z+jKCpJU84YUXdbD2YQJNC8KSsubHhAG0DhH3daJHjW6yluPsd3RyhsAU8FMdB7TDCjlgCCtGfyo= 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 1789088604013732.6609988299135; Thu, 10 Sep 2026 18:03:24 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pfT-0000Ts-NR; Thu, 10 Sep 2026 21:03:09 -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 1x4oQV-0001rV-Cm for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:41 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oQF-0007J4-IR for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:43:30 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49d1fb0cf5eso2907195e9.3 for ; Thu, 10 Sep 2026 16:43:03 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.43.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083782; x=1789688582; 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=2rJYFRyBF3ve93GuQi7uuw0NLh/T3juFuRfoIczr1YA=; b=NEMgJKZivp+wHOJj+SO9xdYhCTS55scSLU82aX+NyIfMNsSemheGapq5eLfEONOwgj 37St28KLDl56HIK0SCiHbJ5BJ1erC4JKWEf/Zge30xipJL4n7SfyArwhq1SaVY3JTw5Z B4FhEpUGLNMuXoLHaeujw2TkFQvRHuDtADOVB0ftBK1orFC2n3QIp2HPyO4ap0wv03ow mDp8koDhlmN5BOjtSTBuKEdWAhEphhk/zpb10aNN8C53Kdq4HixaJljoei9d0wORkL4G QA5/3fSM+E/aGAyLLd6/d9u+aXpkf8dw0cu4Wds5zHktc75xOcONzGpHn+qtgzH6f785 XjHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083782; x=1789688582; 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=2rJYFRyBF3ve93GuQi7uuw0NLh/T3juFuRfoIczr1YA=; b=q2EyHZXt3xpEP4ZDEnJD29nYSeNYAIBQtJBE3N3Osqvxrd4wJ8n7zfI6qz7grKd3nV htw2jK47ocMr3cFgd4iZYk8QzT/fsBfxI8WfOD6As/oqld3kMLYq4SG56z0r5WmVG+0V A1QXdcONYOlCJIdM6BFkwDmrAJ/Rc4OzJBpg6ru29bHl0CbEJPKr6S0rJKDiamw/LjiJ mFUuoZlG90wdfFHZ2Ycw2gefF1tFqKhl0g4UtzB7qlWKiafHRWiS2DZ6R/DQZIynpsHV 6sqNeFzL9bDANkxU6FWkkLqxplPBdOoRDAkqATGYkmJN3Nr/oaBnrYZaMIp/x/0RQQbX p/Tw== X-Gm-Message-State: AFuF++mUWT2Dadxtc7d4CUi2aohV5hoqmwQynsvJRWkjCx6znQOM99vw +ArCmZct0OkVUMliL7SIDFbubDaQI3ClcT0nDkGkVTAetEbRB0gWA2NEB5GMENsk2Kw= X-Gm-Gg: AYBFou35nU3/C74j4YlZ7v7PHrVQneQZdDOX9WQdq3YdkXx+uPkXl5FrVkGXN349Gsf EgN8dNY2Ri6h1TlCzpgRU+WtxIt+GpEgoxmcupTmX7OiSwIG8VMO0pnLMGdaytb2JGGIu7ifYp2 MU8rP60W+KCq38noxzRNHEIWQKl8EFLzjphokB/EeHNspyPtBc1LVhPt8DNmqiJ6+MGyhITfjGD Y8HJtIqu9VM1c3jY7Ul+2O+WPrOPt/AZLuiIWWhjjgJoZ+rTS3fnGESwU5pgj/EHmCvhkq/szJe LakaVLbBTT4pkaMsq2N8ZE9aCBHLSsrqmYwbI+Q12dj6wyMFkEp6veQBl8s3DTrUk8dJzVhUegE YOdt9qv5HnyQoAkzRIq2lYzyTaeorxoFwMw0U3GZzQJJ/JNOtcjDt3mQyV2i6e8vu296LmarHkV EdoqzHjNxgIOQ7HcayyE9qxGl+G/4j3gryBjgJeeIxgegQPghzZSMyY8m9EdWZTwldxX0w X-Received: by 2002:a05:600c:1d08:b0:49d:2450:68ac with SMTP id 5b1f17b1804b1-49e619b57admr29752575e9.5.1789083782218; Thu, 10 Sep 2026 16:43:02 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy Subject: [PULL 29/29] tests: Add parallels format support to image-fleecing Date: Fri, 11 Sep 2026 01:42:22 +0200 Message-ID: <20260910234222.3039975-30-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-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:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.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: 1789088605930158500 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