From nobody Sat Sep 26 23:53:29 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=1786993219; cv=none; d=zohomail.com; s=zohoarc; b=LCYOCSOcZCxYqvcRZprdB6zant2byJCb7/hNB+rkxSnrEC74Jey71IyS7C0R6TNDNDm0dQjWrVh4GLPa0imBvM1aB8Z6CLSCLkZNqf1KuxnSbe57HasftEnjQOMy5qwKRPargF01ZV4SrB/fNS82cXR6sLffsHOyK28cujfBl7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993219; 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=j7oXXoFBbVhiLb1bPiDkubDJnGTFiSt7HdWEJNfqSxtCCm0VRe9NLmlYiHtC1JbZuK5QoNuhdvx5hwjvzzf1prPYYQXeUoWhRCQ5qWw8jQby/+e+RdUbRcXNLSjWC7pkVKuF5PQsucYGNlhwrF2CO1ypEAOhdASoLRkbzfwbNzQ= 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 1786993218963211.02181785318862; Mon, 17 Aug 2026 12:00:18 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2Z2-00062V-GX; Mon, 17 Aug 2026 15:00:08 -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 1ww2Yp-0005zi-Fw for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59: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 1ww2Ym-0006M7-Ky for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:51 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4954f5e8020so19821835e9.2 for ; Mon, 17 Aug 2026 11:59:47 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993186; x=1787597986; 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=lkRWq6d2Spbda9GOmt7lgnylBnxjCfGxKOl4nvINx+zu2SzAiUs7z4JWDK7h54HEAz WLlpW0IEdlQxBPCygNbpWsRVpqapRYzKmEjtKJzjffM55AN32+Za/uJyC6BXoDiM6LVe TUU76II0QlEVefsFq+O8CEhv6vjgL/3T0I2xYFgQXpJMcYDhLcekAKLm5xfwYQjOEiBw 5yf43IuWMedRR0nCslDpgt7qgoT/bDJkkUWNl0FPT+AQwvmhQK+3JzofEVAHdpa6LTaS ru2ExdSo3Kv6SJ0LLEvAa0PUaDVw1DvZjEbb9gyD85gBMpKtZorqGmpefqnd6RGHpfeT 3w7A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993186; x=1787597986; 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=f1oCRsPdAINUr0mtd9T5LWacvvZXwilIE9zjCz/HRCfXxrhWTQzLsUVQKKRku/SKth uBsEmo04bENBB4/jJFctpMlFyy1akGnA8od8FwM2sERBtG+OzoWO7EG2eccaDOK7UuS4 8S0IOHdmiFe8UUUMmAGj1vX8642blbYQtr3pR75gpO928HJeGfj1CnZ+3TSu7WYDyMtt qt4wlNIl7wRA5GKuKSSaKVlpCGwzp7zxXzssRwV4okSVZfOmo7Zjqz2drvnv+xJ/gyv5 UCxgaMVvk8ACLFounZCFOI4iWL5HWd9uPjEarfMT46rcrYNnndiv2DmpkAp6FXKpJARk k7BQ== X-Gm-Message-State: AOJu0Yw31iu+0OSbsvLK6iSDVgy+XArxcZRu28qma+FinYUahuCgCBII UmgEHinjKJ7CCb6757gMoUVI9MeF7d5WBF9fN15QQzYBw4VZ4eFCX4aQMfsreWbkZKWix7bv99W lOzfZ X-Gm-Gg: AR+sD12cWL12V9F82kRdaWKOHtH7XX21bsXoUQOEjMZ87T6hdoStx6Txwd6/Vmfl9t+ rjMQIaY4u3hSdbQxRZA49L6RgMpfRwvbebMbzK0bhAEEubMCDQrAKFDIdiWAFshB1KuBxyDBoAt 4sVVHZmpmSyTATqhEdqhXY+LEUHIIAjOg2kr68MSSq5OTs04FExsJ5QHl3BWkM588aF5vW+r1vg nSo2ddRaApqlUTqM/ihrQEOaNirKlbk8U71NM0bX5lEtT4mhb7z+sRfa1ZgR1c5eWWE7+buEUs6 875OKuqI53Hliu+p+83EjP4MOIppnCyV6VLoYWHtOjYAnU3YsTQs2uk1X7oFof0o5O/uav6rciq Bd3lfLGqSKOWHakX/rWpzfdeDPte3Js9XOEubXeAXdWm7m9+9u2rfO4FUidWxgNJL9Eb5PXsJxx vUBmZ6w2cJqwUo9cfwuJNSEywHIDXH5d2hf+Uc63UsgXSj0foWFTTQVl3fPjV1 X-Received: by 2002:a05:600c:1988:b0:496:c93d:e2f with SMTP id 5b1f17b1804b1-4998798dc17mr405865395e9.15.1786993186129; Mon, 17 Aug 2026 11:59:46 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v6 01/25] parallels: Set s->used_bmap to NULL in parallels_free_used_bitmap() Date: Mon, 17 Aug 2026 20:59:18 +0200 Message-ID: <20260817185942.1065143-2-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993220416158500 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 23:53:29 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=1786993249; cv=none; d=zohomail.com; s=zohoarc; b=OBsdV9FtukJ7fjx9xnLo1W5bBIZn+554i7OufYl4a7qnpZxgRy1mTGB6qglD6of/cs00u165VanT6dM+yNKjcoxWwGBsCYavewA7xM9qK+EUTHlx43vs4ONcNJCFg+UKTKW0JMoSarp9cFTG6u/yUTD/CvmZLlXqhrRRES4PKRk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993249; 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=Oh+186dtrl2ACL9DzCSPXVAuLXC+w59hvgFEZ1nh6C4xmmoKyRjTaGXKBvVMEQ8sSngcT5GvoViN8EYVyuLr25JhKryhdw4iJog/wBQe/MBs33z4BiUsucLrrQAYIN1TzDSTnMp0VwcVMhTzIQpuhC7NAOTau8i7XT8uRzZlbCg= 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 1786993249606605.3368473428895; Mon, 17 Aug 2026 12:00:49 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2Z7-00063W-R9; Mon, 17 Aug 2026 15:00: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 1ww2Yr-0005zm-6d for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59: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 1ww2Yn-0006MJ-40 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:52 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-490cf322ed0so35286085e9.1 for ; Mon, 17 Aug 2026 11:59:48 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993187; x=1787597987; 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=XhsmBffP54nyKnIDG2jftfIDEeBFfhZsNC1Z2f2IhhQ5wautog60HiN08uQxxciV0S /NKIEla0u9vVW5sXIDDWn3ceLORU2Pv4fB3elw9KBbDqejTY/YxpMobQAgyCP6nWcehL 4nPsYQeVKXhI19xbxiGILFP1p3HMvWDXRylQJwC1fGfmU4w5qIdq5PWy2w+y4wD63ZtD jJIGD/GtgE2uQnW5B85CztanJXIxpdOf4W1z7mj/U/pwM6vFy2PdsaSFDGtAERHxcYCr d/49+ZDjvqp6nU2mhkhk4cYOgyMBKogXXSq5XLiP/m+DSU6tns9uf25d2mcPB4N2nfzd eZBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993187; x=1787597987; 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=l1AbYaSMJ/CUBfUtngFFAdL1lKsMOvKd3p/UdNWXPEQnhTcAQTXbF6rU39z+nmDvXJ O0Z2d4vgyWODTElSqo8QsyxjiheVea55XMRbMYxrCVw/i84DqA5ysbkF2xIiNofDDHU1 LQXcc5K/bGwYy/Y9C6hx6x8NzRn5w6IQlNQRcGeYJMVjh9ClPoD3woAWrVQo4Qbf82vK /aK9nQZUFSNudp1TAKa6mGTbSlpnYlyMc/1ukuZB4m8ZAyQjbseoy+7IteyLx5phkpLs GuwzERoXZphbZ9NLQk4Z9E/xJ/SHvepvoNmJ6EteQIOZcdJZwOPwpNuOCXA7ZqA98I1Z tU8w== X-Gm-Message-State: AOJu0Yz0iqM2Ont8DXKC86L5yWVSHGvghJrGukYmVKKToZl2xFqh48Sk ILL/4RRcW/n28PVd+ME1+nC63jB0efbPNDCdSOy4cdIPwOEUPmc6n467gH8iB1rvofOqlIKWNhC ApQPl X-Gm-Gg: AR+sD12/PX3bLQqqa/REvqn9LfJ8yXz233luFLjKe4++i6Q+HBbBV3fjfDvy/RMZ849 77w0mak72dpwYOxi32DpGfIae2s5PDh4A31KuxY1BYZCy7e/w4ALt2mpQwPIiTpFSaEKVAQsGDn uEPlxStgbmToMR04Nijnksiyba9z0FrzaGwZoQqm+5H9Zv+WVM7GzyC9J1BQNKMyWqG6N1TDMxf ES9R/uuiP55l/6/9Y/nFwjt9DN1ium5kqmmoY+9bjuS+Fp/41rjV2YPPcFaNKQ+v8S4P5xTo/6L +bN/sj15ZfRxU3CGWvnfpAs9arYZnboOe4e9GMlR5//Sn/mIdJ0g7slNaZf3+XsiVQ739b4oVMm ttzzmje4aaYsc9bSll8jNbX4LqUJ0ETJlfsD+DPK/aM58aM7cnQIvzseJoU17/BVK3sgH40RshM aXMwCTP8jn+SA79Aiu4drEYELI9RrL5dgFLdU/0WS9eWRmpigJyjJiaaxezPhg X-Received: by 2002:a05:600c:1387:b0:499:81ae:1020 with SMTP id 5b1f17b1804b1-49987971c60mr305940965e9.11.1786993187240; Mon, 17 Aug 2026 11:59:47 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 02/25] parallels: split inactivation out and add the activation counterpart Date: Mon, 17 Aug 2026 20:59:19 +0200 Message-ID: <20260817185942.1065143-3-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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=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: 1786993250952158500 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 23:53:29 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=1786993295; cv=none; d=zohomail.com; s=zohoarc; b=QyLAb9A06GoQG/sNNgAXcDXRagtUrRwYfyypBlpIoMwJB2B/NnfIJKpzumTKyRICZ5aq5cbtH5S9ygLHCMMyeBK2z/yKhINpsPZs2YQ7QVkjls6yu3XaldA1kQj3D+rVNieqcNZ2W2uFtJLoQcFwONFcDXQ/dibX4Q0EdSNB3D4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993295; 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=jTB1V7zK+/ipDCsWgoyaofGyDwKvbgfAmLyT+QMpPvA=; b=KoqsIgSr4SlXqJqvtPQGVuTGh/EFXC/KEuW6kxFGGlRHNmDylncmzmpDCIjpbzj1irIEw3HxMhNWQOW/7J93OQjvg7owFyWfzK0iKG/j0gObX63wO4B0D4NAryV2OYqnn96Pih3DAX4enV5m2rGFb76S19p4TiQLTY5vGDEZNSg= 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 1786993295595886.2736358813727; Mon, 17 Aug 2026 12:01:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2Zm-0006T3-9X; Mon, 17 Aug 2026 15:00:50 -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 1ww2Yr-0005zl-6H for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:54 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ww2Yn-0006MS-Pl for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:52 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4998590d392so40036145e9.0 for ; Mon, 17 Aug 2026 11:59:49 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993188; x=1787597988; 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=jTB1V7zK+/ipDCsWgoyaofGyDwKvbgfAmLyT+QMpPvA=; b=lDcn8LmZphGItvDxf4/RfS6I3rbvzZDXrFug6M/fjaYUG+5X6i1V4yE8pbrr4UulUi 2p80qa1JbVnsIYUMCC67COHWRXxnVa65m+EZEFBvDIYBTWcBToEBLiEZp9NLi1LLqO8i dyH0egO94eB0/5nvQQAjf1YAcGQFUDc6vHDvJ9LNDJyc4ES149n55dFLFO0MjdiQH/4v 2nxu+W+LDxlyPBci5LXRh/9tHP7upfypCULfkyXfbkPXV0OUEdXcvlGFioVIxwfQD5jA bgPEP3Q6jW9Ra4HpG3Xsvbeg6DgVYAUWmyzLEEVNvE1tUYYzLdTciaDMs4PnnvTYnqBu fEAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993188; x=1787597988; 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=jTB1V7zK+/ipDCsWgoyaofGyDwKvbgfAmLyT+QMpPvA=; b=mEuyEDydHuTw68mtHK3uvNYrgW7dbQUTuNGLGcGcIM9226vOElmYMa8TNmfA43NKEt 9Ub79jSU22I/tH+/XBUKeFH5c39SObNQXRbbet2YdEWwoCf4EcRDPH7wHHKJjz32X3DR oEGFOXeAAGJbUNcUXVfO8vFXGs8lYHoYtzY9MIYkfRiwK8h769jEDnhvPriUHWD8NSZJ Vn3LmeKnYFlZ1uYSW2KYLRUVp/dmCnYK6eQNvihkk1dEVp9p9ouDyJWHN0q4P7igv0tl gJJC/J2dUD8WzMos7Vf9M3YRQGLto3wKfw1p3jacbbi/pSFtjbWymbOJC3olL+VLlyQW Mpog== X-Gm-Message-State: AOJu0Yxf4Q1dNgBB+3fmqquaemG2P/GGRSnnKpH+aLT5GgfU5mUmgUjF aIlWKJIRyerf+PdHUUqeDHdtzjx7ztVoe+6t109ch5B1xAO+LVqu7ONqCDJFmsrNlpRXAHcekWH IPqd3 X-Gm-Gg: AR+sD11FRpggOPiWyTZ2w7MKW5nU3f1tejYLJv3l4/wPG7kjVvTOtiyT46tBdIDq2gf JP1v6g09mOjl0YWhFG9emQmdp/vNDurtX+0+OAcEq5lUQF9AvLhCCA8WWPPRBtwVjIUk7/onsgK t4FC6UJpCu+PPyj8eLXr311+FJtxN1G6h/+gk74tPRi+DixjT/m9g6C8Z3HqwvdiepK6gD+Jneg /ohh7yzfgCuSWnS65KXxESaypCjQ4Sbxur2fmbDfvnWOCnRpDMGoNZyrCMgMwG+dn0fJiuNtPhj QsCPTnXWdKp2CoWtzz87NldzU9wiiPHsovWSm+5okFkGFr1b9K9T9qRjJ3CR5OioFW3CXc7oFg/ z2jSxOLmpbSqRHbDgd+H+wc6LzeQuXZE92xRyM9xNZJP7PbBVaurw2uQFisU4W/wVLiMcOXxEj6 xXpt8re6nl/aa5oUCH1hnxsnIHWViz+EStqifVggRJsStSbFLQyg== X-Received: by 2002:a05:600c:6089:b0:499:7a15:fcec with SMTP id 5b1f17b1804b1-4999fb847b5mr43101955e9.13.1786993188308; Mon, 17 Aug 2026 11:59:48 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 03/25] iotests: cover inactivating a read-only node Date: Mon, 17 Aug 2026 20:59:20 +0200 Message-ID: <20260817185942.1065143-4-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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::32e; envelope-from=den@openvz.org; helo=mail-wm1-x32e.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: 1786993297192158501 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 a458b4fc05..3c43020053 100644 --- a/tests/qemu-iotests/tests/inactive-node-nbd.out +++ b/tests/qemu-iotests/tests/inactive-node-nbd.out @@ -227,6 +227,14 @@ 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 23:53:30 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=1786993300; cv=none; d=zohomail.com; s=zohoarc; b=gXA7PMZhRxVZobi7dNfZL8b5uKqKD3DaHLTN7DRkQaj19k0P9n+lhWK9Q1PtCoGwMTavChasXIX8rajv66YHzU7lRXEFzSWB2Y8agybxZ4313f1/lHc5ZyaM8P/1FE2Ii7sLkhkX6+2bvW+/tRpz+SXi3nOP2wocwqbDYD28hcM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993300; 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=lGB39fByQDncn3ulen4IyPxkZGhdyYArYFptg5lwdUHmRZsYJoQ6msC/dJxKo0OFi74SHuTcqUYWGobXsBcCNA6Uq+sE5nUWQtmIqxaNPYgYdvRA/376R1PdVF5i+BAcxptq0o7ZPKY8mP5VEJhrqSqrusEFPGVqXg+RXv3RnQo= 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 1786993299920480.764147247461; Mon, 17 Aug 2026 12:01:39 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2Zw-0006Xc-QO; Mon, 17 Aug 2026 15:01:11 -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 1ww2Yr-0005zq-8y for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:54 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ww2Yo-0006Mg-TJ for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:52 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so30517855e9.0 for ; Mon, 17 Aug 2026 11:59:50 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993189; x=1787597989; 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=lHrvxy8LZ91O4vcNmpKz90523yi6XNnNRobF8qlQ6K+uGdXMNRgEyn7wfFFC1ea/Ir iJZx6scoxIz8qdhRszSfmDRssekP55TOsITiDITf5I7EsobZNARUnvKx9P9Xa1g/qYMc l19kG490bA0h+58Z1YyZ7OpvomenIwBjkNjJ12VcpeLS0DtWBP5UcRqOXoEIDwU+xTC9 qFiqZzW8fRqgfbqzQHOFE+lTonUt5crslodynV1Eyd12xvQQfUgDHl0Y9KZA2RLew+Ti +1QTUj4iNasXaB0yZyJ4Q803vI+dJX1QGyuIwdLW5yUokoSoYbUKKjVBKuW0FDCOmXt/ kAWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993189; x=1787597989; 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=kQlw5egcLWf6/HAZMtdwa5WUDO9kcn/ZkIdp2OG/zbGXgZZj89OBWcegrxQw4VnkFm fkxxz/Qx083cvP9NONIpDXUgXXtMHb24TbF7hvCJ+feoj+07BuoYjcY3of7ygCEIJXxm +w7GBULLz6s1i/NgcQYSHUazv9V4jIUuHWVpxcnssuNooaTRmD2BBdcgCHUyMPIEQeX6 KG8orsMUoo+AGbPlZm9TDG0bK4TEhmaqOHI+OquSxXN4o4Yt4pJ5cBaX8sOHboYY6Kd0 efB19Xu+5nTToa+vhrTJocm0DCN16tU+Xxv0+kg0ZIAatXJA0siTHHF+xl2Q7lD2aGEL Ga3g== X-Gm-Message-State: AOJu0YzIaq9lWP/6AeJEvIReKr37TpojPbRkxKGT2AgvHAO28SWhehcn 10SuQGngK6DPOnMrZFTJyaRZ7cIkTzmPAHI6oO3Na1VSiBJ1ScAkckWfQJvZ63sP09qA6MkURLl cXs3c X-Gm-Gg: AR+sD12E+ER2dVIsPmmEcSzZqUmYbp0GuwKCsc8/3pNOvsnIXfeEjlEDPVjLWCGf0uF bSZmRYjxSufwoBEh9m+uNn/6jloVNZ4yooopvb1d7Gsv0ju+/YS4etwpHg60JPBRAw01ml+iPXh XEJ6iWXSNKjgVzz8mGAQNcxe4hLlcxiqI1XlRxScxFhubitVw38yISaRTW+ZBGkolemZcR0fYVH 67PbyCOrQi0nLpKrOv6oEP8qKM1IIqcbvqgEgcF2E4A7nnMv+B8UR18mb5tA4LW3+QJOMcgDFe+ ZAuTVi6YoTci1BBAVUcZt6JCEUnwQiNEqOc771r8nxlE7UnbmFe9g/uE4PyV0C16gSBgpCBALlX x5EAGXvLTaYfw0f/mVe4DepqqjlaUKS8M4bI43r+wBSCw4CDTcMLz5vTeGw+hIBrED2mLMn/bjR yNkFCfbijvpI0EjLTyIpN8Sdp5oBZNfg4JvzytnPgCLBDkZ4OiLA== X-Received: by 2002:a05:600c:870c:b0:497:fecd:5b00 with SMTP id 5b1f17b1804b1-4999fb3be85mr42906515e9.9.1786993189325; Mon, 17 Aug 2026 11:59:49 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v6 04/25] parallels: Make mark_used() a global function Date: Mon, 17 Aug 2026 20:59:21 +0200 Message-ID: <20260817185942.1065143-5-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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::336; envelope-from=den@openvz.org; helo=mail-wm1-x336.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: 1786993301150158500 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 23:53:30 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=1786993300; cv=none; d=zohomail.com; s=zohoarc; b=AwmzAUXcKGYpUgysPZ/cm7ITH+l27arBoOhY0BNCIXEb2yvAC57MZaE1nh1+ecaMO7QjTNUGBZ2a0XACNbfliFc+fYSv3NOz2P4av0yE6EuUtP+HAxwqrdoCr75X0wIpEHQIaZCMF6XWu3Bqg+GjqHDliuqXrSo2peqp64ldvnc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993300; 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=bNluZA1H3dpLN/dTCAROfp1/OCosoVnqXdp0Pn9XRfbm5orEnQR6fnY4b4UQWYroN+c+tSoXuwUb7QA2e5Qg0bTZ5FxmpJ3t30OfY097XA0jcIJVtHDseGCpSm7zSe1OwaFkOBAe+qqNkuL30W3fkhl4YpHzo5Cfcz3AULdUXGc= 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 1786993300931612.8958599725291; Mon, 17 Aug 2026 12:01:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aS-0006yY-0B; Mon, 17 Aug 2026 15:01:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ww2Yv-00061l-0S for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:58 -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 1ww2Yq-0006My-VJ for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:55 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4953e04ef16so41620145e9.2 for ; Mon, 17 Aug 2026 11:59:51 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993190; x=1787597990; 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=hrvhZxZMAhSGTTohcarf+PJ4eBTbs7o2VRaPzsTBHChxjKKKQktzf0EshIyP0LoPJF sTUvoFxYVQ7gF4aLpSamo2/KmK9SgH+LJpa0lokwkMzhY2n1QQsB4EX7oVqMKaK+4TGV /EaArEXG++E3jC7rwowllCmYeh2Jn5Pu1XEtAlneyHPrIA232K3tah91h2lxy3/cnNNE JjIC6LXL2CuNjDOx+jFWXwLl+Mt0lB9GDpaP6AZz1HbQlgo0SHOz2CftyTw9SVBCS3w5 Lb+HfQn41EOvT061YXX1i3J/jL4yhHFVuAuMOYi+BIzbLx0gSodrtPa+hP6RL6gxu2lz BuvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993190; x=1787597990; 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=W9lT4hqwXkni2Yi/LNfHW94ohOoxgYojhziWWDyG0gvqaPlB9FvrhOqIbQiBJ7NvxU LQfwLyFHVlUYOuOto2GaTp4J8RXPAcvhvFL4Vi76Be4VepszWPf4uAqT2CX51p7QL0y+ c+nKsNghbOQMliH8MFYRTztqFABzVEvLbo5wjpb+rYGFDGffVqIXCs2Wrl/QLJgSLa9w fB6wTpOnK3reFlypySidfdU+kjq7c34thB6qFIcKRt4Rl6pCSHfeg6jk/ba8ivKOqLYK /d2nJorVVDcS0Sb/Dz5VB7993RX0FoNDuIIEtLVN+7r1h35Kp+W7Dw7PLOHrGj+dO0nz 0kRw== X-Gm-Message-State: AOJu0YzjLu1PdhM9g0AObrqzMhLkvievxuZL/uEcLiJAdkw+9MAze6eV qvikJLBGZhlij3ytrnuJdl4V07VDC/dam5KQOQj6PRHU15O/QvVXt8IXkOPQqMBcpCbs0KXjn1i WeR6o X-Gm-Gg: AR+sD11xIUJxRMsPMy/6UWppqiM0ET3lMXgS3Bjdksk1UNXOMpSdGD/Nf2Yn+cEuF/3 MORk2CdwKDRqRlJ1XQigDQDQCVGxFgcTfzvuJauIb3GZ37gloq+TEdNHEBNF4/MuKe2iKDlqGhi omzaSTcTKOHmp1mvP842MuSY50+rDGZCw7BJqx4HiZ6hed4YdfMIsGvQNheTL/DhVtlH+eHsmRu Y6NdOicaywNuZpsXkiw2voVhh+8AsQVKluqsxckiGeBmLvDO9zo1m9gvFEtvwluU9MYqfPU+sZg v6SY95A/ihNhWGdxAfe6u/ahKws29oPb8gpVP8MQN1EA7Q2X4117UiAFRUOKZNYGbjzFXgisLAY P/mn7hNckPOnGSrGFONn5Qt3UWV2Uxh4NVkxdRUvEkT6BE6z3f8ImLVNICX0UlEm/W4rmvVHyqw 07Q4C0UV6u4NZzmTJjrOPjwApZlq4PWyIn4dnxGL+fdE9WcwaPKPOtofI= X-Received: by 2002:a7b:c04e:0:b0:499:518d:ebd6 with SMTP id 5b1f17b1804b1-49987972ef1mr259276795e9.17.1786993190290; Mon, 17 Aug 2026 11:59:50 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 05/25] parallels: Limit search in parallels_mark_used to the last marked cluster Date: Mon, 17 Aug 2026 20:59:22 +0200 Message-ID: <20260817185942.1065143-6-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993303048158500 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 23:53:30 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=1786993385; cv=none; d=zohomail.com; s=zohoarc; b=cbPEMXui8DDKgUVa0ZFDmuNJyHHRJp2Kbt+BT0yz+iZg1b82GUCN/RJJBBBsdr1l+8zCdh0gM29j6nVCtYKe3rS1i8ypkMp9y/KZgtmrIcsAGVwH4zc5C1LPEGXCJC3DSRrT5krZLrF0ihtKJ75S9tMDtLDGlwd/x2iZd7JXtW4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993385; 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=BpC1XtfIfdOrQZ8Yb5Ku4Fa/dYKcHfRXMtwKqGq7GXejLZoprZdH6T2YhIyflgsykv7jeBVtjUR7DlOmjGSK4qrEKTYWD52gAiRkj0Hp+g+PTH8/6s9MKN6T79qDVR6PNbz40URMqHVRd9l3ve3A50R1LxUY4w9Jp6e+3R1kEao= 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 1786993385966378.93922392730985; Mon, 17 Aug 2026 12:03:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aV-0007DB-V9; Mon, 17 Aug 2026 15:01:36 -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 1ww2Yv-00061t-LC for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:58 -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 1ww2Ys-0006NU-3Q for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:57 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-495590dde14so47149895e9.0 for ; Mon, 17 Aug 2026 11:59:53 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993192; x=1787597992; 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=tSBiiXRmx7w6IKWfHg2ZeUbkughuY9dNNMI9vv8NjXYxMd+9XgpPP9ZEW34l5A68o9 MMS8uAZKg+dailO1HpLGuRLXyVSb+jnCiBM6ckUtLWFBym4oVO6qDrPwXpJyt9lS7F0z AnJqw0/CmfzqqS7Gn9MxO3YBh5THdFi7S1b5AGBVQzn0NZR3HZ+VGAuCLhh4E85YkYZu 5wEqFZGdgMIwLr6UCZMbLGTk0FqYRdogaRP87WGOilqV3y1OHOigWrl/wq2LkKRtKPBi q9IdX3sD/GtsX31nMV3BJUZKbov9I2Tz8dLYgJdsrkZa3Rw6FcS/Wao8J6ccZczSVU/X 6bmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993192; x=1787597992; 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=DAy/2/4IlyPa2wvAP7VbWtGceKtMce8DwjQkoSRZSScP80WPVRxVtjuZb2tpwx6GK+ a0XbbNj9RB/q8VpZ4RlM5boR2fhGgoi72RELtue5qCUrjN7zRas7a3hlzUE2O/nGYufp fZWRTyYhel59r+nbzgw14h4XN2ek7EWZc3Nxh4JlI97+maWFG9XhJ3F2ATIrCcOTSOxn IMnQ9wro92n6hzhrQPEFrmmPWJJKmCLqVTptPiAg00j0bmT1ZleYai6WlM3G6KvUxAbk vdQxKCOguJdixdMkHQmEni3aW/YNZoSj6sy17rpSQ/DyoEPPhX8u/qMGTQmvpAyFFzUe kCug== X-Gm-Message-State: AOJu0YyanyKoxQXqM2dIcxyiptEneJ8Y5KwLmJay6mTz//RhkvyjMKns RxpxnPT8ZFIC2zn9dmFZCK3BR15qFsBn5pdHFgxlueRowYR5XIbQDcLBSInXeiQW9k7Te2a0I0v kjN7S X-Gm-Gg: AR+sD101IDFY+hNPnxzzioeQNkN5qghkhDVTAiSJbTApfgANqE31ZJHPV0DrD2T1o+l yzLGKh5391Dw6eY1QQm0wcGZoat9vYHwTmfgGIP/6ZuAoR9W7h5ztCmiMbJZGsbWt+wz63+U/bo dCVT2vVY3vdRTqhQoHx2mIhPxHftcAW5Cj3yDBTkhWvQC7WAo/hWs4iXO+wwisajBBag3ZZO2Xv VsEQEL8S4IVgU9yRdP5ZXo75nktcvpFv7zk0FzxD0zGfU3s/9mc7UNX2kMQzFej2SKHax6eXI94 De5S7HT4b0Q9GkEoWOb6vzLH8y712q0+s8A4NHtJ4oxVqgwSCMz4IBgORKa/KcoCbMxyLd1uG4G pePOtjnfPSjMAp6fmtG8v0dO11NXgze26Nj1qjCRMDemx0GR/Jksw5jiMrlNxF5uZQyV1rgpWMM kNwqCYWvJBO7n7hV7dGZv8OJUF6razpZQ8zM18bMksUfEMs1xRww== X-Received: by 2002:a05:600c:848e:b0:499:7024:9d4a with SMTP id 5b1f17b1804b1-4999fb2ec1cmr41163195e9.8.1786993192028; Mon, 17 Aug 2026 11:59:52 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 06/25] parallels: Move host clusters allocation to a separate function Date: Mon, 17 Aug 2026 20:59:23 +0200 Message-ID: <20260817185942.1065143-7-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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=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: 1786993387779158500 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 23:53:30 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=1786993268; cv=none; d=zohomail.com; s=zohoarc; b=SqTQzUr4xzScB9NS2xchtCD4MrXBQ1BEJV79Dvn56tt2Z7r6VF492fKdnLVCxUS/+6vGpsgeRs/Ht5WU++Hup2EsX2DJ1JfFS5KuQta4T+YDzTKp3BDmDw1igIqoOIFCcMES5wmcvUhRlm+QqS6CseecvFEvn0A9zHKwko0Leto= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993268; 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=PD4iTnSLHZp5CR8UH3Ow6exJY939CdvS2aDIgOTy3eJyHT0zgDJ8evCcIctczZp/ntqtvY+ocwFRIcdZwjdNtePuguFHW4ThC6gHQNLaa2ZO6O6+NECrzWYhikx85r+OCK/+ivklCX/sejubZr1yvxrc53MGMOLuxCpZe9kd2qQ= 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 1786993268047208.87150358712643; Mon, 17 Aug 2026 12:01:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2ZT-0006Ku-Dj; Mon, 17 Aug 2026 15:00:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ww2Yw-00062O-TW for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:00 -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 1ww2Ys-0006O5-Sc for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:58 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4998b5a63e2so30996585e9.1 for ; Mon, 17 Aug 2026 11:59:54 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993193; x=1787597993; 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=NS+XjIORujf9eZgXPxWa1DcIkmGY3QO4Hxyv7aNUEdTSP0bzIYbdD2GTyFa57PFTPg TSsqU5xJrC6GNnbbFv0AEA8nyWSvfO618/fJ0fDYrbk7VSEMZA1Rup9hIhb/kHNdTn1p hQcAgZhrp/1ybG+zwtuuKBdWqdN4blVx1ntxOtbFjKf//jMgaTcCKoRQ1/wGo2Fdq1Pc v3saDCOjnfGg5ovNtOThlEfseaerDN9igrxT6aLsPdTtIE8+QuOn7LhHgRxQxm2tpR4v +Si8qC4vqrXj7bx2SZHfv5dKc3THiSp/6VUWS5KU9TuevpdMNGdT4pf4PvQWhun9BUra WQ0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993193; x=1787597993; 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=TOwcTWuKSW8YiU9T9iOlFU5YsAhkS7GzHymp5RYZlEOtEPTkly7f1hrspOcCIGlIHa kQ/qC4KnCbfzs+JH+kdYkMIjNKnJEmL3djGkix1ltbWO3lameRBELtXEqLfZC96qgJsI tsZQIoJBMpKFNlA1OUgv+RYKKennOz4cpIlmQjFuoZYo5/tcWI78S+Zj6FLDUcLJhDm2 F/LFNDl8VHqsSnaAJwv/Kso3LgJY4MOvqSS62UREnecOjsInpoiS2mZsV2PqONF5/E0K pDyc/7758jIMM9RG+l16Hv2H3YaFn1uHZIal3d59uogq4M+M89C1XUaSbu827OfikuGK 6uCA== X-Gm-Message-State: AOJu0YxHintFsD4YE70wzOrAck/VgClJZptc/927RAS6cHUejwDLLfWY E5LgQrqlCX+kwoKMiaatB/JWkn7ZYYQvUPcS3cngbsDxk7ZtX9guszTrB5y5quS33T+5SeINM8Q BxvWs X-Gm-Gg: AR+sD12ZC/n79i+EatnWvGg0vyukECQ58FUunarptFyxf9+/eQrghuw6W9lQFN1ibBw 1TXzMnPtaWy522zlUXx/sPBSLI6mRLE+ZNSuT9UZFuqWNixH9X/DY6S3zgeB/HhiMauPBqF82Ad MXlDf+4fXFCgj9RwjOyJL+iTCDQiEUZgbZZPS1jCG4EfsShCBCsB1eGhJlb7y78myagEkblIfpa EGmL6RTFelYn2Hov2x7ULc0z8GIbirm1zpDkKcRVbhXARaen/PmFWWdr347NwtnKPurmoJ8IC/d vjLyMuNlUj2aMLRvpb1+nfHRNaLULCFViMHNtn/9A2DhdB+C5CMkuSMTHUjSuM9GBjx2Aw/FH4N w3R9KkAIOgdAAC2MG3b9izYyeH93h74S4tpo0qK9F6I5QSkijoG+8A15HafZeg4bM2BjNqyYr0A 787UHO6C7puTr4ZRApP6j4AIBhYIPx4RG24t7EtcbDQuFnJUn8zWViv1t5A+2s X-Received: by 2002:a05:600c:5392:b0:495:48d7:f178 with SMTP id 5b1f17b1804b1-4998795d6bemr432472575e9.11.1786993193014; Mon, 17 Aug 2026 11:59:53 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 07/25] parallels: do not let the check die on what it is meant to report Date: Mon, 17 Aug 2026 20:59:24 +0200 Message-ID: <20260817185942.1065143-8-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993268991158501 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 23:53:30 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=1786993311; cv=none; d=zohomail.com; s=zohoarc; b=nbIgnMzm3Mp7VqtLiAdELhWq/RkvEx4FxXWsuM86ZfoAfLcFPiAjDUX6dvcvMupkNw2cdAZI3EDvjkHHBsSpLi+BVr3l1Np14wYvg693sdkgeDJhfLPLUphKjjJ7+EtXTMxesLa8pWM76ebOEup+fueZIyrCKdaVaqpasvf391Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993311; 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=iJ2ZZY63xNRLDaETOLvtKuBVIkWkpTeYlVjV7AGQ2TNh+iVTwOJQlXYmhCb0hXATqDPFFUGaSp+xG0vmxBfG+Wv+xxYkO6m6cuIqF43g28BUyDoUwx4ffaaBHSDlmxANZLpltvdc1Nv1nFoxy/E6zYhNcXgwB4Aao0R4OV0ag5Q= 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 1786993311772982.6619852682107; Mon, 17 Aug 2026 12:01:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aW-0007Gt-2n; Mon, 17 Aug 2026 15:01:36 -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 1ww2Yw-00062N-Tk for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:00 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ww2Yv-0006OF-23 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:58 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-496bb7cdf51so46949415e9.2 for ; Mon, 17 Aug 2026 11:59:55 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993194; x=1787597994; 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=Xof7EbmV9ixjs9LMcI0MuDht/XRdICSHjpX0tMSqmzGTtuzUdcSCHFXg+TMiYkY3GM rq3ur1XEDOw16ArxTpPPmrTCZwRKjS6A0TT3RV130CWrQtTqfigQA6VLI/PlqTEKas/X SwZOrmAZa5D7EDYLOcxf6fbPv8bZ2WpxtVuLtiXP2Q8qYF5rChBLCQYziNl5F/7ujg27 DPQzb6apr+CzxvI2+OLSuCTf9Bim5IAAEanmdkIZA1pd5dXQTgQJjBhLmXSj1ml1/8Ji 6WyktIe4wGhJN/HSdTDjG3cG0WagP5MGGU69x7vzq73cOk4Uynuffa0aSFXxwL3zoHus 8YjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993194; x=1787597994; 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=qAhw/ed+iOgZpHd/23yM7ebJQLwv390kAZlZi5QKeMFGJ/1LQslc4Ezn37RW+Ajmnw BUvluPIRsuZp56z90UDn1mpSIAGZkycBYL2I+9XD/1D2eSizmAZy+ObWjK/WEYNmPmom FaEHJvLX3KHamIFGg1r+MJlaM6y2QaqQwGc/jCTFqDvMDVF1D2cheb0up5qg1mtCqinE 5tcYDiz6tTa+2U3qD1rhMCshztrqZ1mRjLBAHRnVXyolBY79oFulGGUZT56bYV5BS2Ba 1fq+RlQM+zXlpC6gYmhLwht1ZJvi1uroN7VxYUaatb9XCvtBv6swVutc14TbW9eht7WQ pIWA== X-Gm-Message-State: AOJu0YynLLNx6Te9i+T7Xh9tkupe0Ni77k0CDv3/tW4Yn8RV1nksFBpZ 83Bu0I/5k4QpFJH9n8Kih5Z2EJGfU5Ltg2OEAm2J5FG7d31niITXy2dp58nikzQdAoh8J3RspwQ qSM9C X-Gm-Gg: AR+sD12QMWyEYQHx09UWSEprgtE9Jdr+8ZNCGo0rrO0gGDGEVXGFDcrcuNenyEceAU0 YN/82EVRoslOdg4+1evs1MzaeBf6SvQ+TT1/SL3PYyFUZnHo9ajuGfGYp2ARXZ2cF2h09pCiWGD oF1htALgU/qat6sBUQIKySSRp6o/GfLeEpG9fKzfv6ko7rye4DRz6M+n5cqH76qoXoINNa3tvJV eNM/q3riofKYYrNSJaNLDYc3jFN5WnDKvFqQkDB7JNkoHWK6WNMYH8MGLeRkfaDeUGvp88fjyxe utTVgoQ6yFKI3gmLYJ9bQddc64V1H31o8poE3fi3L3A6HCl5AdBy53qiggqLNfYrRO/PlkgxieQ VleTJpNaUCoo4NX83b1DLOyGyYTbpaoHv2xXREusOWpB8x1zOd04nOA9WtzjGH62x5APkPkY/7E gIopUSmuMWCJQvq3KNgdFYKIzKVx+6OaDVPHP/ZqXOA71ZInZKCA== X-Received: by 2002:a05:600c:3b8b:b0:495:4fd4:619b with SMTP id 5b1f17b1804b1-4999fb04106mr46471195e9.1.1786993194201; Mon, 17 Aug 2026 11:59:54 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v6 08/25] parallels: Create used bitmap even if checks needed Date: Mon, 17 Aug 2026 20:59:25 +0200 Message-ID: <20260817185942.1065143-9-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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::336; envelope-from=den@openvz.org; helo=mail-wm1-x336.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: 1786993313156158500 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 23:53:30 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=1786993407; cv=none; d=zohomail.com; s=zohoarc; b=QD8/aP3rtNbkYPSjqMpa8jlySWCSzkj1uPiflCldO4q5NDujO991L0TLqTSuhyHa6szwYRO242r1Vsc6ahoXjLxzl0A3lLf4l007F6uPRMk122OSakJwJ11bmDLl6vne1cN7DhKCVIjgC1R4oVL4OSkB5J1unQgAhU4JbsS1rF4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993407; 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=TiwdUnQU0UHTjdG52ZzCf51tn3efZXEXsYSNN1Gq9Lkz4m6bxZcIFhIbq3KSNZrPX48HiPEOZ4ljkIJIUlUrcMFBAKPdDeTx6ydVSIkFlGXK35bflJC/3pJOcmOAiS80QcR6WgJ069Bqq+AlR8mAPDaIu4M/3hxafcH7FXShLMM= 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 1786993407922402.623082552547; Mon, 17 Aug 2026 12:03:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aX-0007TA-8U; Mon, 17 Aug 2026 15:01: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 1ww2Yx-00062X-Gv for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:00 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ww2Yu-0006OS-SJ for qemu-devel@nongnu.org; Mon, 17 Aug 2026 14:59:59 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-49802c418b5so40342215e9.1 for ; Mon, 17 Aug 2026 11:59:56 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993195; x=1787597995; 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=LoZCh5mDHCZVTVjZusHMLbn0l2vYv25K+iXkBVjc+PAFDZTBZi8on52nEfNbo/YJkO MDV3gNabhI2tsE4XkX9dzQDN72rDBNDm/RGtBIw3QzR47eAn5T1n5x1mPCuFTIiWRMDW TOsafd4R6/fvVmNk8X2O5uWCCFo3NMZcHwqtOEEicH7gU5d475BQzhFXCVIZqTshG9K5 Qe+0wqiSHOHKOi5OWp98TFoisukTIzPIEz4onf4yNMQN40yBWvMpUAm7nrhBvJNkpmCi 5lbF1FFADqmmWC51w2La3OFovn1yVkuWsOZAGyAkwHnshlkoHUy15G2Zk9UpMEuIaAyN kwzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993195; x=1787597995; 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=oFvyb6LV5p+XMyArcc7kYwoLIuoIRg8ekpB/CFniLl5jDHWigDkroSaw/aZY9VGa9A KYujgLroTyrN5cb7JvA0qNKSfwASFjfU1uISrgJhnJWO1XjvTfZoZc7PBhPNY8I5dob0 hoe9Bhc9dPErb3lNS/0BVs6309l2dgtgGXf5I7LAg5PZo8IYC7ztbOGtEktMW1UehNA8 zVO3HUksFmJFgwn+oTKIxDU3DID0/rgH4RCfWEtyNsVxVoolctR0RcULYXXpXOxP48VD WLOiS8RLWywok6o4Ku1fiLP3vXo38IRi/PdO0s12wel2sGJxmCrkC509tZ7c8zRwc37O VIYQ== X-Gm-Message-State: AOJu0Yw+P0aEVQaajzpTKaf3saH308f3W3VbUf/18Bj+SXm9pzpjrPm9 3kRu7E5C7whXs7jUK0H8tAI09UpC9nZ3Gx9Hke0I4kgOYbxQJq8bV5qDKsJsTgZ7zKVWXXhsLZk +0zck X-Gm-Gg: AR+sD10Tk2pXSR5nEWTQNl8jGPtMkryd95qHisl4tNWuYUSVWGQtCgCVbmTT8Tc4CpC wPWxmpeg9paMHhkUjPvcsehFnV1PLDr6HSUE7RWnXo7OZicSxauo3c+irvT6MjyzQ/eqtcRPUEh ci9NDzrJVkzG+BaHAJywO6Zh/U/7bu6fJadiP25f8dFjrJHY+si6sZMryhnlxDiNBVTe+DtmGAA 1IjIfq4lxd4bJiFAODj8lalm9S5MsTG3jXsr6yFWsdvg56zs+Rwh762V+Mjna1TQ+r53YZqT5Bf 6oGXrbeFAFEikJBnrRdF9nh/PTgwJMQj2lD/4cTuyjydjZ3YR7qr32Uscy/0oH6Ts26iKpDHzUW Z7SuHUPmI9OJ9YBUByIMHm3jZmRBGi5HEMZBbjIexjF4UcuUD2g/62Iie0nVu2DFqPlx4HcytRO bclcaFQWveyxkxnYBvNBGQ5lSBNb2b4AL9Re/mLTXtNAXrjxRFGQ== X-Received: by 2002:a05:600c:3b8f:b0:495:4491:b8c2 with SMTP id 5b1f17b1804b1-499906ce446mr325234215e9.3.1786993195281; Mon, 17 Aug 2026 11:59:55 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 09/25] parallels: Drop unused clusters at the end of the image Date: Mon, 17 Aug 2026 20:59:26 +0200 Message-ID: <20260817185942.1065143-10-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=den@openvz.org; helo=mail-wm1-x329.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=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: 1786993409955158500 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 23:53:30 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=1786993360; cv=none; d=zohomail.com; s=zohoarc; b=d1LVTVSar9Ia2xKl64EO+0QSF1DQMb7cnjuTIcu/KSIAHhTnKCIvi0JhtKi9+w96OghroRU+0YRMkylKb2KUR+Ie9YK74RoqZ2zd+zjW7SRKAxzX79M41F4yHJEifgOX3GifP7uQksX0P6ah7cx+tnw9t1TuXDq68PUnAq4M1MY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993360; 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=G0YDb2jnW4fVhuwA0KDSS995xejmPG5Du60kc5UIq1QwmTInJWgzLvS3HiLBUzerx0g8boZdojDITcZCZqMMOnKnolhnJrg1Qa0Ji7H/AX3XTQb4Axg1lKePz6RsPyqAlb8vxk+JAiF/7OfQa0CPRtfZLwyFJ7J1xZ2g1l0rwjk= 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 178699336067027.395910308121984; Mon, 17 Aug 2026 12:02:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2av-0001Xt-2R; Mon, 17 Aug 2026 15:02:01 -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 1ww2Z0-00063S-9d for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:06 -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 1ww2Yw-0006Ou-M2 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:00 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-495437bb891so1863435e9.1 for ; Mon, 17 Aug 2026 11:59:57 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993196; x=1787597996; 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=czSdcy7VawBAY+8QUhr+suVHlzUok+Q2kgOtliCqWfQcUCW9k/rROhbvLgd7Hg91BV iWuHp7p9PxsHjJaFZ8dbwX+RRTyVuJzFUUONj2t9Fk2dLmTIg3F4ODvUoFS0HF6aSrLe 510vzOrTaJme6NrX102cfBfXrYI3D4Zviy0BTj1Zspx1qzJkd7QkKJwglkFovm+6rnvm 1sniqM0NgJNXnvN9E97eRizDyzXC0l1CoMmyJTA5i+zJGiAe8+jljItfZXiY5m8fQTjl XIUIyG+EVSfzjfrBj2Z2kDQ79Y5/UJ7XSfheMZlTgjJvEGqqm9SJHsDlWkn0NjbOa76R f2Lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993196; x=1787597996; 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=js7jy3kAVGAeyvi9Z8h3qXunvoWzX7c8S2AN38ph6Bw43y7jsnJwJ96sPn3+OeutON DTPD5S9g+7P8E9Yv4fgwrSJ74YDmG6UsUjmsSq/oHR3/OcN1ERUVygSAu5tkkNbp1foa WmJQ61iX7kYmneNxXZ6xzjWNf90HaskE0SlM71bYUig3Ib8gwwRps2sn227B2/iKsOSv FUXGDsVhY0EL7VILFnGoEuJxEkKXx/IaB4copxn48WtOLsXi5R0SW1KU5sFLFDtoWfxa RAbAs7hFe++MTUzqtOmQgNXt53Mc7hjk4S4Bkck8wPR87YbQGsh5bdbScRPc50BqLiR/ ICXA== X-Gm-Message-State: AOJu0YwqDRum1efbGdqm/uxmrXrIhUKwsYIm+VfFrHOv5xkdxPMUpnoR 4KB7RiBI+F0uDHB6kiiYMq35Y/YOWnZubhyXw1+1I3apyyLJ56R6K8uubpFjmOEduy7CFMin7PQ HtLPO X-Gm-Gg: AR+sD129kplY1tizAz+FelI5S+cCSYmHo3yHKtczi14tfZqlK2l559TsZOZeT1j20VU fXUk2L1dKcolBmc7LO3U1+sqOEukveZpUudZGBnuoKgPyRaaSFhvYYucjrEJYDUkFdOiLRz0VrA Vl2ov2pJJZ8AB0gXyjH0qsR9ax3Dx4A11M2qQbk3/QGNEXnU0XG6AgojsfKSa+0xYkRE5LDUOOY pncNLl5XdCefoW0jYRMJzGPV43+ck/h2nJnD0f8zO68T1IpEJtBPvKGj6vvmcdwNQSxjVGrtqII fjhBvFvGIV0buJ+8AFJx1MbQ4QyamagAYrEpMOCrKuA5I7t2Xv2ND1R9wLVJlEHUrVgO26MIyJK n69W1tB2NshJgZe13h8V9bYljXMmkfaNgOsmUDqdEtRB9e2TGT9q/mGe5P6BKQchg6AhVP2T+V/ hwunpguMcc5aFzSWaQScYMfBWVVyY2tv0Ey2yi71iO0Ue46VTWCMI= X-Received: by 2002:a05:600c:348b:b0:499:77ba:4b6 with SMTP id 5b1f17b1804b1-499a1f65e40mr515655e9.9.1786993196390; Mon, 17 Aug 2026 11:59:56 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 10/25] parallels: Remove unnecessary data_end field Date: Mon, 17 Aug 2026 20:59:27 +0200 Message-ID: <20260817185942.1065143-11-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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=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: 1786993361538158500 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 23:53:30 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=1786993311; cv=none; d=zohomail.com; s=zohoarc; b=mauSQ/Xr/MwnaYapNtz+pe85n2gpec4RHh5luGhYuS/Ih3Af7LQxNNyy2oH8+8+aDEGkIe1NMY1Tz7c1JqbTB0VvT2I/GF9pMsXjGXHRx433f2F6cjQD6Wt0c+0SUCayJZD3ufp4TQUGLErMx3ni3EhbRa0DP3kvxRIMU9tjogY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993311; 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=FJ+69XIVv1q8f9rJbsH11M6y66Hg+i54dA0iL8F4kojGS9VX1j9y+sWYLZ0QovwwUUx0bmo6rQzoh4NAXU90rcBuTh3g1qzEXyLzLkoXDy28yr2WD7kR5izYOerEUf3V8GLMaBLDblVg1BEPHccz4b6XqRy/DgCiPzbLLmBx0Z4= 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 1786993311905665.104724777257; Mon, 17 Aug 2026 12:01:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2ah-0008Ew-RT; Mon, 17 Aug 2026 15:01:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ww2Z0-00063U-E5 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:07 -0400 Received: from mail-wr1-x435.google.com ([2a00:1450:4864:20::435]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ww2Yx-0006PI-JN for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:02 -0400 Received: by mail-wr1-x435.google.com with SMTP id ffacd0b85a97d-47fecbb7000so2019198f8f.2 for ; Mon, 17 Aug 2026 11:59:59 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993198; x=1787597998; 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=SBE1ocr3nRYZvKHWpfJIcbHrM0QUbdqfQFlLG/+KbGgFtXgrh4nY9Oj/+ZXUHcdizm W0OxbKfwAkWD5kJQYqHChXGGuirqOBi2h8kds4Mku5z0xhUwc6U5HEzIyNEZVwZpcocm OcpO9fjLkVB7vqkMJQBSeYv4oWW+N2Z3WBuMweY5GW4y8UNgsOaXAn2S5wmChGQ5X6G3 ypl1neO7VkBP3kJMu/2YkCU2ONLHy1+/ltVxcwHMYaKHRR2FJSjk+e85jFk6Ds8882H6 nuT6BsAo4k/lzeslZV58V/8G2ECoFK9EvT5CMI+7VxUrZf16JD6IZFEt5Z/9Mtmk8ac9 PKIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993198; x=1787597998; 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=dfaP9NZx9bqfbGVAHdTDvL8X2R8oScIzI36x7o9cnDHEdQEA+1t7D9hpdleAtRaEVk iM8dJnOJGnntKsbM5rSouaLDLO9v6XaYSjpJ+h/AKTs9qNUgH0/0lg5xeZo91HU+5gMh Q6FMXye53AAjeFINEeyGc1MBCWFv8V+/n5IG19eZlmARGczrc0DEvMHn3gtor/DjXff6 /+2KOwfY4vqPOok+9avoBshfMRJja6wh5nivVTrk1zAfGLPGdiHBPg7s4S88TZp38QBM iuVh7p5ATNRiM0i92tIiryaql2VwiPtAvgEXMHQh2qCHoAKT/0CEXCpq1aSREfyGOqGy hB4Q== X-Gm-Message-State: AOJu0YwhTGWuFDRAWuTTk8t58k09xNQkKRtK04lrzZT6rDqTDILpH8oE zksfJKsuGL5w22ptfqBPp91Eu/fzrCp6WKmAcf5oKFcPUMAzmWetuUEAn+XijJG4L4gXVQqhzOG Tx8up X-Gm-Gg: AR+sD106oXNTq9xNfwNcL2li8P8fd6I475UQkdDM8ZwGcOxWG7CVGSOegGtlqNqMcX5 +OExMJycFWNEo2E5cnrlNRhRUqmbjqAO71ai4ePOFOp5OXkeA+G/Dc7hCP8ENb01JLfF97tAeTc 7lVnkC2HWBI6tiByWScOQiHJAE5CwkG0gW9+zh7xAE3hW7wMD2OjVDmuoA0+ihMkha77X5qcUPO 1b1qNeD8Zali9Uex6gdqnVxw9zqFs940KCGCCLCpvi8XP7IFKiYXtOk6asTbGVEs3HWakapDYZS 6bIHVojw24Qe6qlvdmRgsK88eTc8sZ0LZauFFQvsvguVJpM+EYuzobncOQUPjElJ3xJBe/MC0LV jeTzuW9SdX9FFk458Gz1ONvzSymQm6Nwzy698WpNvbwxUXTb0+n9zcOfDxgOjJbvnB0Ud5Itl9f k/zLrr7uvcqw0IuwoSDP9TxkB2UgeDQYcjt2g2W8iClAAtN68s3Q== X-Received: by 2002:a05:600c:9a2:b0:493:a966:d5b5 with SMTP id 5b1f17b1804b1-49987937932mr277138835e9.2.1786993198066; Mon, 17 Aug 2026 11:59:58 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 11/25] parallels: Add dirty bitmaps saving Date: Mon, 17 Aug 2026 20:59:28 +0200 Message-ID: <20260817185942.1065143-12-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::435; envelope-from=den@openvz.org; helo=mail-wr1-x435.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1786993313258158500 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 23:53:30 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=1786993397; cv=none; d=zohomail.com; s=zohoarc; b=lhDd3+9zzHtRnjmdGQPtzuBjGUaEharX3eEZrwC2Q+TROwhaa2ONFZeKij8aLXqCuWy1R/6OV6NiYWKR+prd2zXYqF6knA97wIznSpBH+4EUWI78VD8ivnX4g/d8I+qa3edRM3vJ6+Yq9qfo+wKrJqgq94OZpRGGmiR7QUloGWE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993397; 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=KKueZu+GFSkWyU7T0dX3d7sLIihGkdnqnU65zduwsLQ=; b=Tpp8uEAGdAnTPFXnYY+kbLte7AHug1ngu7Neo4rjAL6EOVTq7Jrf94xlBq6bKz1dFV9y8vcCM1fQR+0/GzyoLmesvDP5YeiF+AAfkO7llH0z7h7h+RDtzMHzW/2dTkXGQ7S/rUPxot6pOpFlLo6d9D4R5n/WgZvy1Bui3U2KxhA= 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 1786993397025279.3071116118466; Mon, 17 Aug 2026 12:03:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aX-0007X7-RS; Mon, 17 Aug 2026 15:01: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 1ww2Z8-0006Bq-4r for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:10 -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 1ww2Z0-0006Pu-3C for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:07 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-49545ba3d4eso18569295e9.3 for ; Mon, 17 Aug 2026 12:00:00 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993199; x=1787597999; 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=KKueZu+GFSkWyU7T0dX3d7sLIihGkdnqnU65zduwsLQ=; b=Wz0ldQH8bQ++RnVvTYzBnbPheS81rserfTn9YikkFKeEYVBKDbHpEmUE2joIe/kPmj oPJsiD7n98RAoAWWCrY81eqW1T4/f2vrSdhR6hvlcrtKrSCRHCqJ7VZNHv9lf1DlPvT4 2LUKkVrZlp5KHHGmOQFgDAzVpMq4zb0y5X1i5oil7swemu+d+00BGjBivbsvP2EGwqHM SsTaZqK/dJOMoEd8dR9/4IcOSTNmRIWWIIeLpeeO/cG4QaX6W8pG6q3eeu7xEwrBsI1d BqDbGPUrCVvm81wfoUWodAVoHxYghZWnMumkGu8b9pkfqIsTDM+GOL3JY56l7hsb/nSc xgDg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993199; x=1787597999; 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=KKueZu+GFSkWyU7T0dX3d7sLIihGkdnqnU65zduwsLQ=; b=PQECSSuPKF7oa2ZEEGKKLvtHKlMPyadh4dIcBaXsl95CrTLnut4JKszSss8jyYgezI KJgYXXlg5pBq8kiwuk9QzVTVUY6VDS8WDXI2ElxwhAGzB3vyb/FzFg/5eJhhVDfdSNrJ 57lAphHMaRaknbj7Z62EVjebC/7Bubk3GDBuLhnT9Emoz3rs58OzX3dMUtLjIr1Pkhre KdSxgsKAzJe71Vlhx3GQ7JCfFxg7/331uig5/Bj5nj5+SrRbOxs+cxGMlL1jFze2Ls31 PIDgjFy6QCtCEzxGh487otm62KjzoSan8VXr3lI2HSWKEfBXgmgXE2lQO0l4ojsA2jh7 E2gA== X-Gm-Message-State: AOJu0Yy+C+XiWObMd8wFonEJiJkQEYx8hDleXlItiwwXHuOmfb4WZpQL PDiAhDu8tw28hYn6eZvDF6g1JuJ/M5q+WG/l/uOtmCGPUYcVHhFsRehluIf6GjYX9zNJfINOvcj kwoZF X-Gm-Gg: AR+sD1332rklbPGcpsVxgGFpdxHRzWh6jhKbko5LGt1U10riVU4M931v2jjHkDR28FB lCsv/CqW8uI4Um5CkkFjtrzyVgiZJop3WDzlA2p1zwxTvGV5tP/d4CS1ew/wyDc5g1XEn5YIbV0 Uiq25HaVDggmKSN5BFXJhWU17qejsiY7ZZ9uq8kN0GSxjA8D9s9iwGEA1hBuT0/nZkrNne+Rf5q mH54uxx8XfzVhPbu3HOVkaFus/8pUgwJPT/qgKGplS/OTUlc7qhxbFygcg8rDb7QtIaJbAgr1se QPUIDC0kHj659PjZh1oOdTtQCG9A7qchwcajRjINLkzjryO8e1Xz8oD9SMdLhP7+taaK4aST4XK xYOg3QaScAd2+fMSVzHrKGYBy8G99ULr7xqguLqjbFpj5OmIgke6lwWNH4yYRD8G6872g9Y+kA9 Ybunv1VhykZKKgG9gC8OK6mPyDs0UIfApITJ5wlvmCVT1IxSN3jSXN63lWuB4W X-Received: by 2002:a05:600c:1389:b0:499:8174:9f39 with SMTP id 5b1f17b1804b1-4999fa88216mr37334025e9.0.1786993199194; Mon, 17 Aug 2026 11:59:59 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 12/25] parallels: Let image extensions work in RW mode Date: Mon, 17 Aug 2026 20:59:29 +0200 Message-ID: <20260817185942.1065143-13-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=den@openvz.org; helo=mail-wm1-x334.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @openvz.org) X-ZM-MESSAGEID: 1786993397915158500 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..c9652fcf3a 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 f: + f.write(parallels_header(1, SECTORS, SECTORS, EXT_SECTOR)) + f.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 23:53:30 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=1786993298; cv=none; d=zohomail.com; s=zohoarc; b=ZAhNLAdjJFQclZFOlua+v9cVc8tHHM10r9I9JRzAw2dUKpSTmKYuXBGfacoQnlITSi0fAh4Il24RcE7Zs5SndwSZ0hgtdMWBE43wll59U6pgrU3+fls8+jTQo3jO6fJshboEbhYWwrOv4dk3dQU4x6gXX1JGz7Gt7puyttib1z8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993298; 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=Xfii+Nc2enO90HGMhm3bbT6K2+/mL7ZG5xlKuBR3EcIS3yrcuyMEx0Jp3xB4uqY/Bq6J+9QimN4CKACJE3yRe4HOembz8iwMueLRFOY5MDPr0lgjzRCowMSUqTOwhoz1K6VTLbyGrDjZMnvXfHnlGvDbM4BJJqhU1CpH0tEqODg= 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 1786993298288105.1228465612412; Mon, 17 Aug 2026 12:01:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aV-0007D1-Sv; Mon, 17 Aug 2026 15:01:36 -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 1ww2Z6-000672-7D for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:09 -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 1ww2Z0-0006QA-3C for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:05 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-4954a9e8490so1276365e9.1 for ; Mon, 17 Aug 2026 12:00:01 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.11.59.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 11:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993200; x=1787598000; 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=aeJ7Y7mzG60YVPCSCtCcrbxEeaRIGrb5mrOKxSIx5fkui8sPNMrAygLN4TVD2tTfMz cxO027SNdEzg3h6tyVR6hmeA7SCdJhnuEMya3KslTB5NCPXRJuvCPEN419ss7yndveaW nqURRzZVZiMpuEh71DmbZc4mumLOa0IaDG8PUQtl63b+rzr5cyz63KwiusbxanbMYePp j6VQBV+aB2eBlacwWPLgv9FLEAfr59OIpnP3un9TF5iLSgFME5fmGVHV43zj5wIMp5IK UulRb/F47Tao3Nd1IJFE2rStt9htHbkhBT164TZ5uOoccQs4GYPDriQUAwW+WOTdGoPe vH5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993200; x=1787598000; 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=O95YYf3gVlX+8UPhXB0VsQ6BmqShDzhGs0meR5xr6rdTK+W3RkynI89bZSyEaiMlMb lENhM3yiCz42xPvuI39O2HSuiZTSB7YmnZttYhJ2Y1hd6NZXUr0CzmleUIa9jPbTc5gJ bMzeRsSoMVPjlTiLXjW9FBlYq1GEWFiWbFqN/6RYCuP5k4sHTQxcJND3GGrLuVH3Jciw IecrZPU+4i3F3lgPYngP8T9lUhprDgOFOjjDdJXvKKO7srOwndOIOMeCLJbWfOeqibFu HjMZSbwjfPyJmMsFyMtlelgLl0iDRE6ynoXSjhar9LKdCy/2g4SBOWYRF0ji9pbq4/AF VrNg== X-Gm-Message-State: AOJu0YxyO0n543Wa+ib9boJgXX7qb2lXzNaHlYzNFFjW+eOP/2Tia50l wzH+O1UEFU10QS4dihWduRdb5BB+qe/HwhhmSDkpAxUY2B8G7MT9dohTJbFbs9bqNVCd3QdEgii slW6v X-Gm-Gg: AR+sD13lHIkVqvXR+gwNU5aAK0qtyVNuNw2DrOk0dab9P1bDhxugShyFmlVwoRsVDHM ZdVpH7SYGFXEbSN+IXmnwreQ7nS7L/AUidxbhMx7mFLAr9ZUHaXF38MDhEmlcTGzNIxtiXoIg7+ fuh8jOmP85+vb070XXRftvY1GW8l8CX7d7Q3Kfsyqmfa/+7oHjM3BYbG2WiIHAwKC5wFrzBE3WN ldlxtSQCh2OpX9//MLVV3PPE0oS3TxzMZpyj3U8L6gPyz6q0dSQKyLPseHWbh2L6fC3uJb2W5gP BctB3grIfS46wuwLySMFPR0tYZfRdBoqQcP+VgW+BDovHBl9QQTaJuic/LM5VU2NUkJsB/c3RoH LxtNg7dxM0gZGE/znG/SjnjH4tc9L7ffwQLNM81rLZsTHqnf1vEsqaA3dOqKgKhHC7lDPCJFAmR +U6MWuydGPvc32RQnNULZvrq4XCFqXCJrY0V5MJfLAUWH7KDVZF8g= X-Received: by 2002:a05:600c:4703:b0:495:69eb:27d3 with SMTP id 5b1f17b1804b1-499a1f6549cmr342205e9.8.1786993200296; Mon, 17 Aug 2026 12:00:00 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 13/25] parallels: Handle L1 entries equal to one Date: Mon, 17 Aug 2026 20:59:30 +0200 Message-ID: <20260817185942.1065143-14-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993299039158500 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 23:53:30 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=1786993328; cv=none; d=zohomail.com; s=zohoarc; b=biD9v7XSsuct8DtLKFsExJaWBqkcYL53J5TAnriW4pBMBBMYtKu9RxrMRe0rXag7H5pSSAY5Fm7IeGQ3aPylD6Jwles6n7ksi6IP/GpyXO6zHItBWgEdmBp7l2Sn6MYo3mnKMMIg4DRje76eSWpAfRlqnXcsf/0vOKmG6lpu48o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993328; 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=gwZ4F5PLvjIoP1G1HxUHqUfp0tG1Cfurbqv233SS9XxT3Kx3GQo1lXQW6Rrfs0bl9NW3L00Ue3epNb3Wa4bTouB8nMiX1eJcarQ4lnR50iSTF8CsCKCicvYLl6FJGqD8kCleGH10wvnarfVSFTfvuy3952veFPJTiOf1FMb6t30= 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 1786993328506851.2442041159311; Mon, 17 Aug 2026 12:02:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2ar-00019H-Iu; Mon, 17 Aug 2026 15:01: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 1ww2Z8-0006CZ-CT for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00: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 1ww2Z2-0006Qw-AL for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:09 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-49558ce01afso29055385e9.1 for ; Mon, 17 Aug 2026 12:00:02 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993201; x=1787598001; 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=Q/0zM8npu7fjZ7EDKB2hq2u6Qd6FT+5RlAmHucRBWs859u46Vn6xdnSRzpAFu1v79c xX6TPzWENjQ1HWrw9dSsN5hAO8eNlTNKelrL0are71SDisTYCOx+Dl++WpJWOptd5sOn rp6QqzIYnv2Idfac/h+QFQ9e7D4Cz7brxK5y/+8X+NWbTmDGMGddCdPy+0TS2WKD6zlo 70O7jeszrlaqOi63mXXT/7GJfYE1PfhiE4lrKAS5RSJqR1lBqWj/5ZbsCsMUaAWy6Qh7 ZHzYv+IQZgxFPZimawXzk8JOzghINm6mHpND/xRNN67rh0JPk8JBGQ3q8XdTJtg2jf03 j4eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993201; x=1787598001; 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=F8fSol2uyr6ir6xASm4WtVKGNWV6gTUbsEEOHB4YNtSn0tEACwjxrUcUJdJFVbV1wI ELXzR1M8GRhKaA2zRWneCfpSA52LEbyvP9dqJ0AX9c+sED4VtY+cXhzLhgsnQrVUX3f4 RIo49ucFwtzUlAxa8TraVrWVxj56sUPG5h+DEn8jYUQBVI8Wolt773YpPAIUtUrIaqC1 1B4dmg1ARyQSwLA4NK5GouFP8DsNRYLgkhMfwD3wZ598NMXaJTs4GOznaYa8m65cp9d6 72Riz7v12LQ2F3lA8KntAgebTRqzk6SN8ZBv4r5vgu+bbneYE3k1aLbnixe4z+D3Pm+j 1DeA== X-Gm-Message-State: AOJu0YwOCHORL/gqfipySs7pJotnzWyl8Cs5VQyNNwysoMwPq4uJBnoq FtSE7vfgsBfeTlO+GpYcZ4KNPNXrYAJlfSYacGYS1JF77FttQUWvp5dg0ZB7zXSXZQ2Wc2Tjacz 9YXlO X-Gm-Gg: AR+sD11cIgcd6b2RcRzF+hMMK7pxFPdr07hJyBlLsv32gV5iCOXxH43y3zzKHnfXRt0 Kt7aT2zYj/Rr2vVeIQDMIZGvunpJNAZSotiKsGWK/cpnzKURVHBU+7nIuOnMMDTOk0X5B8jEyxI DX7Y11RMl4mx6PwwvOMVs1oBDWlkBw8oQjou2fSk5Oc2yZA1IHG+GtSSIGpyu5LDZioGbLtYbFt O8jBLpVEFCdDSQuVu9ytK4imbWv20dGU7Q4xCYKupTtCJ6Vvx4q5kTpJDOc2dJXEcJMh0GuzB2y mjGLI//WM/vEuzZxENTEsDp5FOnmaWzAyljqX+nEvM/7NauXGavWMvbcDE3KyVZpKV4J48ZzH8b P4hEh6uKeS5a1jdD/pdY6vz2OgxpgcO2nywBktF1VB2Ej9zBG/LLniPiVxn5k0N81L/U4GCLS1u RcCGCTYVuWbrkCbaedj7O59pFYmlW9FTGj1XlcUoN7UjKegKjS+w== X-Received: by 2002:a05:600d:8654:10b0:499:a07d:a482 with SMTP id 5b1f17b1804b1-499a07da4ebmr20208615e9.10.1786993201380; Mon, 17 Aug 2026 12:00:01 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 14/25] iotests: cover the Format Extension against the leak check Date: Mon, 17 Aug 2026 20:59:31 +0200 Message-ID: <20260817185942.1065143-15-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993329313158500 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 23:53:30 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=1786993384; cv=none; d=zohomail.com; s=zohoarc; b=ga0j3rgr5nefIuoCvBUjBXe314UNtBjF/SQkqeINaNE7/qCf+HH0uzWyx4sV8wgaPJB/sMxMLOo8pkqI6e8wxD12lLKW99a9CQ7VEc5bvki7QUCTG7nwfwFltLxu7scg8FncsqDox/lqki5Y8pV+Fp5JFhpcTPXtxbeW6Xdxcck= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993384; 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=eOtnlSthIyUbYDQE781eStCJFY5oDrr5DFrAQ1ay8qU=; b=iv6DBiMtETl/8gKFjnbfmj51M3+Hv/0RLqnAw5+5S3RaRjmGLzAkg5BZzidraW9gLM5+WJhsUnq0MAWzjhtgwysaMSGH0HlQoOgQ4p7iSlYjn9oZryDEM/DJLTpTA57VUqIdbkDQ2EBzqt1RW7dVfyQ+Cd4BXU4Oc+htNYvkkas= 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 1786993384129117.20550174684524; Mon, 17 Aug 2026 12:03:04 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aZ-0007mx-9r; Mon, 17 Aug 2026 15:01:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ww2Z8-0006CP-Af for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:13 -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 1ww2Z2-0006Rt-AY for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:09 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-498028b3d5eso48212075e9.1 for ; Mon, 17 Aug 2026 12:00:03 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993202; x=1787598002; 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=eOtnlSthIyUbYDQE781eStCJFY5oDrr5DFrAQ1ay8qU=; b=QdUbmivJAdP9crxZivNWM6wulqMqnV/ucJwgSR2IhW/Y2u66ztnd1/oBFcySbIniZH 1rP7PIgxLwFXNCYNVWFu5GGVDfJRbfnvWm9+DFwG9m33svAJW52y1OuQ+oG5uXzB+xfQ OSesiy0bZGmru1pH7Lm6U6eqsNqDhHa30iopvV5Mo2tlyGRhnHH3xDylDkeGwGcNXYqH 2nmHSAj8lcwi4kxOkTroZmEp5zjWLlYcflcWkISn5WxBUuF1Ce5oN5qV99U2ZHuhOrri io8nLzixgOSDCf3h1mxPIS4or0RbdEQgUkBrtPRWstgnlmo1fYPPP7bD5bSd1gCyVCx+ J72A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993202; x=1787598002; 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=eOtnlSthIyUbYDQE781eStCJFY5oDrr5DFrAQ1ay8qU=; b=eJdZUhSlr5AJ+kDmw7zuYvrLD8Ay/rkM5J2/z1AObXEqsRgxOZCNR1jq1eXbF2z4SJ Ye2BLSVzXu5XFC2dLUwCcxU4mZ9y03ynAMQSr6jdSg8R+aAAmJxad9rMeEQbxug9KMhR VEzGSKvZElS1qMq5eywSFr0N7tMJDhf4pjfuNs4NVhJNv/HkoLI69lbpP90Uidv8Khct ilSKOrSE6EkpNmR5CyXv8jxE52yRKyrh4Yp6l8OyNBPf451TSBg/u6PvsxFjsOJ9cNHV ivS9z7OKKN2U/W1om9ory174CeQiUxtkHyAul+dlCEsxCbbHYwQjbEbWu8UaaxUhg7TS +keA== X-Gm-Message-State: AOJu0Yy8nkiRS5/HB074NwSjK03M61UMg0eyWeI+1UxPUIEzJJse2tNH k5Op5H+qS82bFTy0/ikkfubySAHqYrRjGu/b33bRgu7OS13FsPseo4xVELWdWkGqAxBzpu+f6LP aBLG+ X-Gm-Gg: AR+sD13BtXxN96i7ouDbNGXaMncxtJ7HQm01uF//Wu+ygFiWPLvsJkLd420snkcwuH/ RvacfNBZv3jN7TKtSBuBaykQzavQAjbL+Xq8Xj8iDEbB3wfP+RY6NkOqhPWWlxWk6kDdXdga9vq cp1yJRu8mw9EjuwTGAZPpoaw9uyxfXwsfVPxs1J5ht3MCgTZFE9wc+g3iqWgtzX5kLvCUYHutqu ff7C3fxiR1u7qGSvwnz+9VXY+4SZlqg2qkHbNeM5LXytiDxTMI5DlAU512g26TmC4FTjzsc1h7h D0PvadhXj7+QwwMncik48VgxyGvLI5NZrr6SSZspHwXE286FyvoRnnkBbinFUEx5uuImU1yEoNX ycOm8XUkBpxIbxE953Uwt4CJO27IccPN2vSPo6D4uMRYfPjGTLoF9Qt4d+nzIPptav1mBHRj5gA HvIzYInukEgd6eIX8lUHWgFPeZOEU92rGcCpeVfSc3YBs+GbN+SQ== X-Received: by 2002:a05:600c:1546:b0:499:484a:98e7 with SMTP id 5b1f17b1804b1-49987974700mr403413505e9.14.1786993202627; Mon, 17 Aug 2026 12:00:02 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 15/25] iotests: run the persistent dirty bitmap test on parallels Date: Mon, 17 Aug 2026 20:59:32 +0200 Message-ID: <20260817185942.1065143-16-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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=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: 1786993385677158500 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 b3b1709d71..5fd411974d 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,6 +160,6 @@ 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']) --=20 2.53.0 From nobody Sat Sep 26 23:53:30 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=1786993335; cv=none; d=zohomail.com; s=zohoarc; b=Bxq2/qLSW0nfuyWkD1JPRF1FyER+0xgAw/gJqNXjcZOfvqL9j1TrnZFPJBEgcvuno83yOEptogki/0irsCGvk0Ky0fey/ZFm61s9ItpuxiPbhrT+3QaK3OQxssAbq4JqMDjbOjIDUMjv6fBHRJvlUFrJYAipiq97OssA+gZZdAU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993335; 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=J7IK84s9N60LKb2CLjtIwINHC1zgkHdpjv/PU750mHc=; b=JMl9McMmyNKDZxMH+RgbhVa/7FdvZ/6QAkuGBeONb9tSgdNMEgaI84CRrsUowqRtne7cYRdvmrofrNcKrXLTyhdEznMnap0IZ6FgBUzgW6nh3fj1MNzYC5YlOTEWNwL0SrVljoMWtVHjR0XKAeIoVFpWOqHrth1IZo9FqfO0Jvc= 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 17869933353543.6462999604110564; Mon, 17 Aug 2026 12:02:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2am-0000OJ-GA; Mon, 17 Aug 2026 15:01:52 -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 1ww2ZC-0006JT-CS for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:15 -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 1ww2Z8-0006SJ-21 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:13 -0400 Received: by mail-wm1-x330.google.com with SMTP id 5b1f17b1804b1-49987fb18c0so19702855e9.3 for ; Mon, 17 Aug 2026 12:00:05 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993204; x=1787598004; 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=J7IK84s9N60LKb2CLjtIwINHC1zgkHdpjv/PU750mHc=; b=p6aEzKBr0+eEYvI+3OC8PoZonJ/J+tgKOWla0/VZjoMEhz9yZvdNgT9ugDWP8OIyoQ oRxXYCPYv/5g6mQBQztMUdKCOxfQSOd4cuAQEciPzaBLgYxYGml/eewkwzViLpFz9mw1 5KrEOOGS/hBV8kX35VVOK2RcrX/RXts5r4bHi8DQ49KCyXFrf5VRSK8NzQ5xcr+SD0bU Tjn5jpygrDu5QxNLYoE2detHIXxF5eZgPXX/wB0zhrFfCAjhgNCHs9Dm92c0X+9NXha8 89wEeG0S6hyY/iBwg9k6DvBsGtAlitjDcNBr1sq7WbywPIapCu1M3v9lzCeSKf+qRm46 y/gQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993204; x=1787598004; 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=J7IK84s9N60LKb2CLjtIwINHC1zgkHdpjv/PU750mHc=; b=D3h9/Pa5FlLde0C7u91kkI0Xsv0SsUa2BHkjoCMNnEEQflXUVkkcxM0rH2RLV5lX4O d0UtNaPZrMEHG/pBu+LWGvULaXmyH7GLtsVzY+egXDHYsCB+nGgONabLp82bJvyaxQ/E zRZByUtujITybiAlx0DfHCmjbkILHLUN4BPUhWuXjM4n+xY6swHTBO5Z1y/CLrGPV6R4 SDI3xJS8CF/lsTgrDOuj4ZQGFkx7RNDcTx8w/VTKgndp7VfrnBspF361sDUK2t7nIif7 TMe7T4R4gBikg4PArifNN0rZufWFquEtLMJOCXWeGVa8YLbJjm8f41iaSfAvaDPx4Ibl m//A== X-Gm-Message-State: AOJu0YwFxzXh9xggMZ3jMTRnb2jRqwvA5ZokeKWkA5CwHkgsTHzHbQ3/ MHDWfML5K5DtMYjzS0T58r9+nKO+J4dcOu3YLACL5X45n6I0UkQfy+M4uxMIBzygjF3ai+4Dy2Z RTNuI X-Gm-Gg: AR+sD10cNwx06ZZvPxagw99wRfGQlyAnUlX2Gmb/ApZJ9zyBBRmBeM0jgQl04gLrVYM cm9RXEfx2XUkrJ66wyBFIrgfnXekkbs7+UZMA8MErwXYKTvPDNTKU2IJDB2ftr/N6eLpzRmtb9E fNtAdpA+Qs3DP3SymOMJFHPLV0D3S4uwFBFfHbbEUWwSGpU6kZRNiu1I1RknKXI54XZmiuNWUDz ts3um1wb3bXW1Qn6Oq0ifAbFj7vLVK1aVkvSKQ3jhA05QIjI0peF3jzsczHHysONoxNM2G1ES1u uvFrLyKpLHyHCM7CC7PKNIY3RRXP+d4Nj416NeGqttYxQNUIq5FSvH3LrI8UPXiUJXPaie0SXVW 7Zj7EJaTtKnAggGDykWFbuaD7YZeUve+Jtf5MBzzmkyafdrbDo5Z/ggqM2wf18cq4GaxjOERhgT uoFANidlqnMkfkWQqKAL4i8++/YQ2XxL22Rm4O0doE6a/S+IDXtQ== X-Received: by 2002:a05:600c:870c:b0:497:fecd:5b00 with SMTP id 5b1f17b1804b1-4999fb3be85mr42934295e9.9.1786993204244; Mon, 17 Aug 2026 12:00:04 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 16/25] parallels: reject a bitmap L1 entry outside the data area Date: Mon, 17 Aug 2026 20:59:33 +0200 Message-ID: <20260817185942.1065143-17-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993337430158500 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 c9652fcf3a..ee071714a5 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 1786993388164397.6153870717749; Mon, 17 Aug 2026 12:03:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2al-0000C6-5x; Mon, 17 Aug 2026 15:01:51 -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 1ww2ZA-0006HF-F0 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00: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 1ww2Z6-0006Sb-1H for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:11 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4954f5e8020so19824165e9.2 for ; Mon, 17 Aug 2026 12:00:06 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993205; x=1787598005; 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=bnodjSAzjDULOoHrxt/3zq90Ldw0LIHvEoopbIGCwKk=; b=jCeEXwSG0umwEjaipDtmeMhtq7I/k923OTWWsPs0BSTrnou6UXdeJGNwqMKLJ06byx Pfem3j1DhOxxru0YNhproDk+h6FvlCMXieHE5n0R9cCHbOmvJGrJfM3/K3GeslC2Y4+7 +qXjJAIp6eNzcO5aXxhwl/bBOP3UylVxAqkVelo5rz96VKQvIuR4iHz3D1tSjRkLt/Pi fqI5/oDf8INweSvXqMSy/K29rS0Xx65bV1Rzefnm5qJeoNBeOVKq5WsPjOT8OBk8CLtR aNQR1wn3ntrYpi863SOlLHwF8nB/8RYHd4ocByLLzcFidAKBz+iYUrfeb7yaXG5eLRc0 cSgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993205; x=1787598005; 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=bnodjSAzjDULOoHrxt/3zq90Ldw0LIHvEoopbIGCwKk=; b=Wn/zIy/ja3aG0pTkjsHAYAOZOHVzU6U4OCHil8dfcOJz8Re5GiWKwhVVMTkWCdobPr jlfRuR6aSgno3YgZoJIjFxg+Dn8TlVH5BB7sJgcMLtpVZxja6E0c0w4c1T0PxYhBGtYS DEqkuuMN7weY0ybFGs9ax/4gw6aKhOa7aNZV7qb4vvBAmh9N5SuLgBUl7QyZrXvMAq8F ialh75xw+Knt1ly0qrUbzJksEFRDIcKWt5Uz6MSj2ply+kv05QAVxRhXgtchTRkJkpGy V1A4tmmISqPyorPvdbkE/+hQBEvRFvaHAfkVmwCzgLz/J6mb76fFM9Qxy4Vz+pVjGGBZ E8vA== X-Gm-Message-State: AOJu0YzmuXnHwmA20Jni/hUTvEoTqRGqc41f3bUpwEbS/on3w5pJNSml Gy/YLjPX3fl63CTs2caAk4BEmKP8+Q/NzZMZV5fhsRNIu1LzwIOzXdNUvPrpqO/W5WGGmd2aDUB dRIKV X-Gm-Gg: AR+sD110E+h74VF7BfGLnqA2N6R1FQJRxG6zjsOGlZDWafLCeapnCAdq93XYsbQyFOG zEZLn9v8w1DoKxmnk+EVvgwxMsQoiplo15Yx7dSulCJ6qTnV79wMFfUl1w9tHy9Zn4RTAy+p2V9 s5d+ly50kh8aS5iMngJAhYTPw2OBLgPocL9t6pxxYJWnkpoD5AlIOOB5fiFWk3joL9/F79uIST2 3gLNPyps3ufcF/NJh4lSITt/NkdUrnpLjM3D/Thco6CNOLXKbpaPG+Rvwl1cdTYa+VBzuKaU7Hu V5hx5v+N1pPGvWXpw3xxkz4i/7Um8vX3nRmLoDMU6dgSy5eo09bxoUebkUhVmpfKhBKoYlIY662 w6Fw99iW8T+7jCgEmSvB3WW1N01Zi625aAaW1IHCirO/JoFBQuNDlLcEXIgz9qe9LziNN/PYqZU B48XN0p268l7OO+w3btv/OEJtfDy9a6DDbiOJ/yAL7lXoJAra4Sg== X-Received: by 2002:a05:600c:8509:b0:496:c9cd:e7ab with SMTP id 5b1f17b1804b1-499879337acmr489135255e9.5.1786993205196; Mon, 17 Aug 2026 12:00:05 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 17/25] parallels: do not trust the bitmaps of an image which was not closed Date: Mon, 17 Aug 2026 20:59:34 +0200 Message-ID: <20260817185942.1065143-18-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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=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: 1786993389750158500 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 | 27 +++++++++++++++++++ tests/qemu-iotests/tests/parallels-checks.out | 17 ++++++++++++ 3 files changed, 55 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..916d423a64 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -414,6 +414,33 @@ _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 a read-only open still reports it, it is only inconsistent = =3D=3D" +$QEMU_IMG info -f $IMGFMT "$TEST_IMG" | grep -q "$BITMAP" \ + && echo "still reported" + +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..4dfadd68d6 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -268,6 +268,23 @@ 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 a read-only open still reports it, it is only inconsistent =3D=3D +still reported +=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 23:53:30 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=1786993312; cv=none; d=zohomail.com; s=zohoarc; b=XqDSoI6hTh0xp65gWiBFGso06XVS2zlPBYBhZYmV8eKSHR6fpACA9E/KmR3JN0OJ+B55ug7KIdjCISNJoEeF2nbmcmZgpGvCTUKGxKfoZEI+GN6t+zZpaknKPdlUmHn1MPXe63IIhusPtUWCSULyA2DaQOIryhFsX0dzAkky0jo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993312; 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=Y1BwE1+vB3Ozyh0CEV+JJWcrBSNAEza+dSTEJw74TL9TZPhBBTt5sfr7GeYyiz1pWonpS/veQmo4BhVLng6+EsbRRWrxJHDPB8ifJnJ5Gb9MRx3Xj0cxAxqixEM2jyvDVqrZ/CU3s+nDbozhsTJuOb7eNylPdpM6yeRfkhk0Tfg= 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 1786993312121808.1401349142241; Mon, 17 Aug 2026 12:01:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2ah-0008FF-Vn; Mon, 17 Aug 2026 15:01:48 -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 1ww2ZA-0006Hu-PT for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:13 -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 1ww2Z7-0006Sl-Pl for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:12 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-49557167508so38436015e9.1 for ; Mon, 17 Aug 2026 12:00:07 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993206; x=1787598006; 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=PaNbCvkEYCdgqTVAerTm6YZcxea5DWAWAPlnDip2oHzWOT4rzdIe8BIcnPvKljnV3W R1NFrw0oIAnSjFXiuQRC/HFWF7VG4XSBYEt0vipvnsOFs8FQM/gV5RNezNLiN2ggSyKl lZyOLiAqicjwBTdqhqr113oYM4n1fGkrmDriJpTIG7nHAAUwHbmayhG9X31hhLgqSmpi 8u0HIfgI/E0chb09QPuRWLadB3ysxooKEg9zp7JlL7/yECJecbcomv7y0Enng9wjYBzI pmJQggzI0x1k50DS57xKt4OdgYziPx/RWFr+o2w4ogq3jNz64YpPHzOuL0TM3PK6X2Z2 cSkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993206; x=1787598006; 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=ZCmX//yTspe549fsWUo+adD22TvWr4rg33B597pT4J0eHLdtc5wBx10dzwXfKQ0NiC QGRQTTMk4UCRnqfS3CBvBPEyhWtL403iScvQE/aSuxInJfZ/FgXX6o0oyIddr6LNj8Qb XBdKwXubvAR4OHYhqnwMk0ONjIWoIWUahlH1wCRVPWUsJZY4MCcFLR4a6NzCyKRATwYU VxiWhauGZcg4F4039ZSrocjxxbacUezU3Kw/Gerola2Rq5hPjeikkgbunU1PAxUn+zyV FOLQwHqjcFJXooM5Q6LMuwKuyVr+k9pAg4r3yN9dqTlOx6H6HSOuCuvcjH3sIWdspirk plwA== X-Gm-Message-State: AOJu0YwD+cKvGS5K35iNTlBl7dKfM2RBxpeDpYdyPnhvDA6pfk3hc6KK zHZgxfQzHiTr1JgCJpo0UXmhU0o4p0mEyLfdQ8QCJi7Kac/a5Ld47j18LFKgd++vLy7zeQlDJRI U5bFw X-Gm-Gg: AR+sD125d0Mcw+1uW5pBjGRNrNem+0nYNMBfKhOKXE2pEVFW65NKz5WLoCgqbglghV+ D1cjYPC1denbQC69IeNc0zuDParc/Kfk+gX9TIQDjgRB+jEYsfSzao2dPjTqr5nzxHkN2hbS2B8 AgzFmXPiYyRjo1/DNMJgqVfZ32XPWJTPi3NsGGim2V1KNTrhKygeWYWIzHAnvTt3HYAE9n+Y534 kzgnsUuUSNo9GRJFYyoqZZYWf6DuYkbB6qi5F785u6ieKtxS9FGOQCiAutORDMMjT8GonXp79uJ m08lQHX1ZtF5Y+MlxSq9NAq1cVc/K0O0dd4KRVeE9Ju9fh9OycDDs3KgMVMldGIPa5z/bPxNmxX KjU4+O1IAFWOrp8LaVq8Ztj+ZddF/0y0uILbydVOUXSgkB1ozeaqUE8SOKWxXW1no0qQV7oEack RauxNtv4fMMrpIAEhbPJ7UyJ9GHWQd8QNf1z6glxcGWVtRTCfbPg== X-Received: by 2002:a05:600c:4745:b0:499:9eb7:4558 with SMTP id 5b1f17b1804b1-4999fb6d4e4mr35678435e9.10.1786993206100; Mon, 17 Aug 2026 12:00:06 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 18/25] parallels: implement removing a stored dirty bitmap Date: Mon, 17 Aug 2026 20:59:35 +0200 Message-ID: <20260817185942.1065143-19-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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::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=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: 1786993313227158500 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 23:53:30 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=1786993372; cv=none; d=zohomail.com; s=zohoarc; b=Yy40e/tk/vg1Nj4AJSBcm+z8mVPKFQfWNPQctNB7GK2oczLr7snbyOnxIsTjmjeNzDFezkzQ3Jj7kb3hLqqAAzc/AXmDP4sBsOsymw8fJ4pb+1vLD6DeV0Qf+8/d52jin0ct0+04N9wT+GkCIcEBDowFZwu14/h+SJ2LsYEM2gE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993372; 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=yXQS0EBGFNdPvTyVdgIL9AVWBxhmkphkllpyggxSxkI=; b=IQv4ODUCqc/UheOemQWIey2LrKxVzIHQoXSzblwznFktsEbkeNOZiggFO9eWxiGLRbATGzVGcChRtQAx3tzNkAG4SfUbKQ95W06ZXR9C/E+Oxg57CzRLrUyw1AaH8SdTEBwwHy9qK6QXju8NwMeDtBRICemdIrhgvgl6RkFdSI0= 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 1786993372730386.1126123393069; Mon, 17 Aug 2026 12:02:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2ax-0001rw-LV; Mon, 17 Aug 2026 15:02:04 -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 1ww2ZE-0006Kr-7B for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:18 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ww2Z7-0006Su-V9 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:14 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-4956242332dso39995265e9.2 for ; Mon, 17 Aug 2026 12:00:08 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993207; x=1787598007; 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=yXQS0EBGFNdPvTyVdgIL9AVWBxhmkphkllpyggxSxkI=; b=Bzetl2BWfKJsCW1WRu1dEeEvqL+fiOxACPNp+bURhtjkvd19Z2kupE26brdnfOsjqA SD2xOhV8BlcCS3vFlaaBLRel3gwxwS/PnXmUcVIZIiY30rDyHpl01wgjzlOCdtxpXSKE 28wbP+am7Ap9BNjLSdVOCwDjIVmqtDiAzIBis+9yixHEu5cHC5+5ReVrvBzQBTUFYbNc /Kh1NaNsqdVPmE+RWD3qLMD5Ct6+JlQA7lxyKmXjSTGPaNmqQ1wXsoERYcY1VeG2pDVS L1nMvau8e4jCWPNEIh0ymhH4yOfbE/HVtqmAsw94QUg/gW+dPcnrqODT4UGEdsGFOcDn Mr8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993207; x=1787598007; 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=yXQS0EBGFNdPvTyVdgIL9AVWBxhmkphkllpyggxSxkI=; b=Djd5+v7OwrvDbgyxZ9hVEV/tsL8M5ur24Fju4HQHxiymtU1XL43odDAaFosolAHumL d+Pv4CLtRC0lrDPD/rVR6KhJnkzUAwffeVmP9+n2mLAxCYr2CIwE3GJ/kUKuuaL4oP8J nR+29IStfzvkqjaGGcJSssPiS2wBPYwe/Yb02G1hgZlVscViWnGagHVhaBoJGt6moTmN uwJ2hy/D2+VRoHh8tIUErzFTVRVmU09m4iFjvpgVcViKPRSnt4DFREc68nwIHczb7IFG sBGeBSXdAyuIZudL1gfTplsbMpIWDa5+urYXE5iDEP7kmtf4qtjuYOBhi/McZnlYy0Ui cWLg== X-Gm-Message-State: AOJu0YwpWOVM5U5VCkJ634rGF0jVE7vd4tlAzLUkGqR79a4x7luh3HN/ k5VMA36jmOSbVJ8HlEKdOYTNHnU5yt2mHJGY1lY+gc3IZR2RTpAWtlM4c9DKoeHBZMuDiisF0QI pzaOI X-Gm-Gg: AR+sD13EN1BtFDqd9EtA6aT3H0ouzg6n4EwTC2mmXIknp7A3hXboEGH/pErzn9yiamQ pu6M6EPNtmK1HqUdoriJ92T7WCEs1Mx0gxDC1RpiN/w6a5p/1hCgOrmTiyREreQM3uyA92r+30F wh1pDiYXK8n5UUXWVATW0kstekCLnufgPJL9H+RJ0zMEC914Ec89SeBzPtvItXsUbd+nuZzInKA 9w/xge11l35OHeBbke8OIQP0DWkOn0kMyNp+MBH0qSTMy6XIGlHqLhbtv1OGtKu4+zF4GX9A/wC kh7emkccaXyCjYquS6axw/TKvCYRThJRpi6OsjPGHKuFPXgzP3IYpsJ3FP854j1FwHA4LB/wklD HclA7yyBIfP/+pyTAwJ+JGrAnLIkHIgkxfnFuki/qQWYnqWKzR9NVroOMt6DpT/aDkSm067G1ss Eshp6mV70zEVhdYaKzzPHbmwwDAJfQWR6QZfs0WNSwnUPQX6e6fw== X-Received: by 2002:a05:600c:6051:b0:499:737c:8a8b with SMTP id 5b1f17b1804b1-49987980774mr288986705e9.12.1786993207093; Mon, 17 Aug 2026 12:00:07 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Eric Blake , Markus Armbruster Subject: [PATCH v6 19/25] parallels: report the stored dirty bitmaps in qemu-img info Date: Mon, 17 Aug 2026 20:59:36 +0200 Message-ID: <20260817185942.1065143-20-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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::336; envelope-from=den@openvz.org; helo=mail-wm1-x336.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: 1786993373726158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev Nothing tells which persistent bitmaps an image carries. qemu-img info says nothing about them, and the only other way to see one is to export the image over NBD and ask for a bitmap by name, which needs the name beforehand. Add ImageInfoSpecificParallels with the bitmaps and their granularity, as qcow2 reports the contents of its bitmap directory: Format specific information: bitmaps: [0]: name: b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 granularity: 65536 The list is built from the bitmaps loaded at open time rather than from a second pass over the Format Extension, as every bitmap the extension carries is loaded and marked persistent there. On a node which is open that also covers a bitmap which was created but not stored yet, which is what the field says: qemu-img info opens the image on its own, so there the two are the same thing. An image with no bitmaps leaves the structure empty, and bdrv_image_info_specific_dump() prints nothing for an empty one, so the output for such an image does not change. Cc: Stefan Hajnoczi Cc: Eric Blake Cc: Markus Armbruster Signed-off-by: Denis V. Lunev --- block/parallels-ext.c | 22 ++++++++++ block/parallels.c | 20 ++++++++++ block/parallels.h | 3 ++ qapi/block-core.json | 40 ++++++++++++++++++- tests/qemu-iotests/tests/parallels-checks | 3 ++ tests/qemu-iotests/tests/parallels-checks.out | 9 +++++ 6 files changed, 95 insertions(+), 2 deletions(-) diff --git a/block/parallels-ext.c b/block/parallels-ext.c index f687f2da7c..ad87ecfbc1 100644 --- a/block/parallels-ext.c +++ b/block/parallels-ext.c @@ -736,3 +736,25 @@ parallels_co_remove_persistent_dirty_bitmap(BlockDrive= rState *bs, =20 return ret; } + +void parallels_get_bitmap_info_list(BlockDriverState *bs, + ParallelsBitmapInfoList **info_list) +{ + BdrvDirtyBitmap *bitmap; + ParallelsBitmapInfoList **tail =3D info_list; + + *info_list =3D NULL; + + FOR_EACH_DIRTY_BITMAP(bs, bitmap) { + ParallelsBitmapInfo *info; + + if (!bdrv_dirty_bitmap_get_persistence(bitmap)) { + continue; + } + + info =3D g_new0(ParallelsBitmapInfo, 1); + info->name =3D g_strdup(bdrv_dirty_bitmap_name(bitmap)); + info->granularity =3D bdrv_dirty_bitmap_granularity(bitmap); + QAPI_LIST_APPEND(tail, info); + } +} diff --git a/block/parallels.c b/block/parallels.c index 2a5ceb8978..e7d65d0458 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -1624,6 +1624,25 @@ static bool parallels_is_support_dirty_bitmaps(Block= DriverState *bs) return 1; } =20 +static ImageInfoSpecific * GRAPH_RDLOCK +parallels_get_specific_info(BlockDriverState *bs, Error **errp) +{ + ImageInfoSpecificParallels *parallels_info; + ImageInfoSpecific *spec_info; + + parallels_info =3D g_new0(ImageInfoSpecificParallels, 1); + parallels_get_bitmap_info_list(bs, ¶llels_info->bitmaps); + parallels_info->has_bitmaps =3D !!parallels_info->bitmaps; + + spec_info =3D g_new(ImageInfoSpecific, 1); + *spec_info =3D (ImageInfoSpecific){ + .type =3D IMAGE_INFO_SPECIFIC_KIND_PARALLELS, + .u.parallels.data =3D parallels_info, + }; + + return spec_info; +} + static BlockDriver bdrv_parallels =3D { .format_name =3D "parallels", .instance_size =3D sizeof(BDRVParallelsState), @@ -1653,6 +1672,7 @@ static BlockDriver bdrv_parallels =3D { parallels_co_can_store_new_dirty_bitmap, .bdrv_co_remove_persistent_dirty_bitmap =3D parallels_co_remove_persistent_dirty_bit= map, + .bdrv_get_specific_info =3D parallels_get_specific_info, }; =20 static void bdrv_parallels_init(void) diff --git a/block/parallels.h b/block/parallels.h index 27d8c3ac83..012f47320b 100644 --- a/block/parallels.h +++ b/block/parallels.h @@ -32,6 +32,7 @@ #ifndef BLOCK_PARALLELS_H #define BLOCK_PARALLELS_H #include "qemu/coroutine.h" +#include "qapi/qapi-types-block-core.h" =20 #define HEADS_NUMBER 16 #define SEC_IN_CYL 32 @@ -111,5 +112,7 @@ parallels_co_can_store_new_dirty_bitmap(BlockDriverStat= e *bs, const char *name, int coroutine_fn GRAPH_RDLOCK parallels_co_remove_persistent_dirty_bitmap(BlockDriverState *bs, const char *name, Error **errp= ); +void parallels_get_bitmap_info_list(BlockDriverState *bs, + ParallelsBitmapInfoList **info_list); =20 #endif diff --git a/qapi/block-core.json b/qapi/block-core.json index 1f87b07850..4bc8b45efe 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -200,7 +200,7 @@ # Since: 1.7 ## { 'enum': 'ImageInfoSpecificKind', - 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd', 'file' ] } + 'data': [ 'qcow2', 'vmdk', 'luks', 'rbd', 'file', 'parallels' ] } =20 ## # @ImageInfoSpecificQCow2Wrapper: @@ -255,6 +255,41 @@ { 'struct': 'ImageInfoSpecificFileWrapper', 'data': { 'data': 'ImageInfoSpecificFile' } } =20 +## +# @ParallelsBitmapInfo: +# +# Parallels dirty bitmap information. +# +# @name: the name of the bitmap +# +# @granularity: granularity of the bitmap in bytes +# +# Since: 11.2 +## +{ 'struct': 'ParallelsBitmapInfo', + 'data': { 'name': 'str', 'granularity': 'uint32' } } + +## +# @ImageInfoSpecificParallels: +# +# @bitmaps: A list of the persistent dirty bitmaps of the image, +# including the ones which are not written out yet +# +# Since: 11.2 +## +{ 'struct': 'ImageInfoSpecificParallels', + 'data': { '*bitmaps': ['ParallelsBitmapInfo'] } } + +## +# @ImageInfoSpecificParallelsWrapper: +# +# @data: image information specific to Parallels +# +# Since: 11.2 +## +{ 'struct': 'ImageInfoSpecificParallelsWrapper', + 'data': { 'data': 'ImageInfoSpecificParallels' } } + ## # @ImageInfoSpecific: # @@ -273,7 +308,8 @@ 'vmdk': 'ImageInfoSpecificVmdkWrapper', 'luks': 'ImageInfoSpecificLUKSWrapper', 'rbd': 'ImageInfoSpecificRbdWrapper', - 'file': 'ImageInfoSpecificFileWrapper' + 'file': 'ImageInfoSpecificFileWrapper', + 'parallels': 'ImageInfoSpecificParallelsWrapper' } } =20 ## diff --git a/tests/qemu-iotests/tests/parallels-checks b/tests/qemu-iotests= /tests/parallels-checks index 916d423a64..4c8fc17fa9 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -382,6 +382,9 @@ echo "=3D=3D dirty a single granule of the bitmap =3D= =3D" file_size=3D`stat --printf=3D"%s" "$TEST_IMG"` echo "file size: $file_size" =20 +echo "=3D=3D the bitmap is reported by qemu-img info =3D=3D" +_img_info --format-specific + echo "=3D=3D the extension and its bitmap data are not a leak =3D=3D" _check_test_img =20 diff --git a/tests/qemu-iotests/tests/parallels-checks.out b/tests/qemu-iot= ests/tests/parallels-checks.out index 4dfadd68d6..7aaa4636d7 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -241,6 +241,15 @@ qemu-img: Operation add on bitmap bitmap0 failed: Bitm= ap name must be a UUID to wrote 65536/65536 bytes at offset 0 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) file size: 4194304 +=3D=3D the bitmap is reported by qemu-img info =3D=3D +image: TEST_DIR/t.IMGFMT +file format: IMGFMT +virtual size: 4 MiB (4194304 bytes) +Format specific information: + bitmaps: + [0]: + name: b2c9e1a4-5d3f-4e8b-9a7c-6f0d1e2b3a45 + granularity: 65536 =3D=3D the extension and its bitmap data are not a leak =3D=3D No errors were found on the image. =3D=3D extend image by 1 cluster =3D=3D --=20 2.53.0 From nobody Sat Sep 26 23:53:30 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=1786993360; cv=none; d=zohomail.com; s=zohoarc; b=O8I5L+l0LF7Nu5psFqpudhxo5R/joeZqCfUtvMY1Ks067Vl5HLVduKz9ZOnTqNsZXv8l62B9Syz3DbCW3yRbwJ1aA3On/3HPrhDBKHB5IKYyln9Eg2dgPXnMACh+W8p7vvxd1hy/PpDujOy+DLMTQDuC61uSi8jA19FLRqWXgxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993360; 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=nDL9CAOnygcQr6TXGuqu4JiUlKl3duwzZkyPxwmpAVE=; b=FTckyaQEXmqagJSHIk92sdDDggm3XQNSfXyjzdU8CoCLjgABnSzk+Xbp5ZmKwfZF7wUL+AYcEcwKHHWDxXMBgOi/q7p9wXhWZjNOJqlhgZV84yjdpbWzgo2rIM3EP66u5Q/8l09C6BTkgSt2GqW5zEAK04GOIzZyq+HwQfVgnHI= 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 1786993360490585.0376752620208; Mon, 17 Aug 2026 12:02:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2ar-00018o-Fe; Mon, 17 Aug 2026 15:01: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 1ww2ZB-0006I0-Hr for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:13 -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 1ww2Z7-0006TD-UX for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:13 -0400 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4954dff6536so27776715e9.0 for ; Mon, 17 Aug 2026 12:00:09 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993208; x=1787598008; 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=nDL9CAOnygcQr6TXGuqu4JiUlKl3duwzZkyPxwmpAVE=; b=k+6UNobgedDTRaW7t6LSBltypDzRGoo/VjrLD6eXUkP9W24ika0Xk+suXm/eNzrZNr zSNK7Ss5y5VXCNLbgwfhqNKkuxNGO+2zsOGotHeU2Um3DeNlrODx/MfDecUG0Z6c+oxz nSaWLUTVxE6dAHJRPqcEkpM6FfvZJjMP7ePCDu/FfSqqbapuN+K7dbAWyOBSyTFYkz77 29BM0bQEcjG8/eEIOwg7XQPwe76Y/8D69LvXqb1wW3dUL4FYB/5B07UGwJ3R4wcny6Wn vZ5qwvwYWn9F+ROoxeIbCEid5PA1hkB2Q9RYykiHhqdM2nJZy8IEttvtn3kaerid9g+y 5bvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993208; x=1787598008; 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=nDL9CAOnygcQr6TXGuqu4JiUlKl3duwzZkyPxwmpAVE=; b=EW+IZpicc7yI0cWfsbP6LmfeUdp+NE4epASVIpCMH7bHqD/0NUts/qjEC9oWKDNqDj TEUD5FiVaUdiVS8HsxK9f/uTqBZI6ABZRzQlz67cEof+Qz2kIc6SXwPOKGzlo/AiHYnu KuauVupFY8eolZlyj+HJg7wx2bgGFBLOw7yYMPf0MohDWcDpElAGTyefGfRklweru+Xd itQ6f5U0sfPFhcBlOvWwvNsfJg5s0Z7sqp+8jwajiPseilK95q2/ETiMA81K9i65Ntba CGw+zd2cKXQi8T9aIF7LfX3purx9BEfuhqhiSjw7kiMfQnccaN5eTpgN5yawuxqCSuy7 MT5w== X-Gm-Message-State: AOJu0Yz8x5Jfd/UR7RwocUQQAI0UcFdP8DkJK1bZCkZAvmpo7RwVEas7 bh94UODHBo30DMaUGaKSwTTPp1ALCGSpjzjZxrOelRM34F7gVbix//sAGzztbAggAIlg1tc8B4f bdDOu X-Gm-Gg: AR+sD12YTkL9CjYSda7MgKv1Gxk8GzeM6W9BgydUGn2e52vXJUs86EE5GjTj3sDhE1Z AV3jx8O0x3zpyfdqI+WYXewCH6JGZww+cFIg4Pu8o5zjZ7HCGJgvL50aHW4dpXtOlYTVD6jnpbB Uvy/SdAFJXQMvAjXJxicZbnbQOVYSeBN5vACkHvU00FW76jGfd5f50hTWpUtBMqTOnzQ0wGcQBn nI0Ta5nYmNMgHz4WCXiK/NiwH9aDPbvewhFEczBVo5ianebXtcRW8GpPOrRZHsTvI512LZ91mXo mHNeSpNIo5ZzJIC42zEy0wUgX/pK/TREJTVSHdMvy6IdzYGV+Jq3WU9pMRYygAchwGqOWCKqSXb 7jSwU/i/7gK+yxw9sybqi1qb/Y4ehE18C/65LrC9Mz0qSlg1H/R1Ec+PYEXVp6Rwd9QvhlbNoKz Ao1Jvu8ov9W2zKQyAkCB0V4z7R80CUXe7ZbNegVoYvPmcq/ddTig== X-Received: by 2002:a05:600c:5392:b0:495:48d7:f178 with SMTP id 5b1f17b1804b1-4998795d6bemr432495255e9.11.1786993208089; Mon, 17 Aug 2026 12:00:08 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 20/25] iotests: rename parallels-read-bitmap to parallels-bitmap Date: Mon, 17 Aug 2026 20:59:37 +0200 Message-ID: <20260817185942.1065143-21-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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=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: 1786993361436158500 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 ee071714a5..601bfc5228 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 23:53:30 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=1786993406; cv=none; d=zohomail.com; s=zohoarc; b=h9i95iBLoiO+jnRhuca5c8FTCR6aOgXrtE/ArsZDPbCdLVHyTJB9uRhO7mSEyjE6NV0oCADan+sy2u3bYIWDV7TVYfsaNsonTnt8U0m5tdKmQuZWBrlIgfZBCuPouRhU8hgAPUPue+hwPsNXYgaiD9EBGFDvQDQOY3XkAOobNQU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993406; 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=o6yZjBL4vkE927udb0cZYGdUDjMGKn9+RSUoNO8M+S4=; b=FzZKj1EE8kqFH8yTd1euRIsyMMrYghuXssrWjHUz4GIpVJLkJauKS7ah1XgUYuWLVxztNzZiP7whe0PC3ADlvK59RrPvVsouLAzj0yYvyIHoDHl9VbcGDQnuU9rcOXNDhKUcDRZQo5xe8dBEhep979VbQDY/2e+2cXTBNl0k3Xc= 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 1786993406593114.23518044848731; Mon, 17 Aug 2026 12:03:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2an-0000Z6-J2; Mon, 17 Aug 2026 15:01:53 -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 1ww2ZE-0006LU-IX for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:19 -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 1ww2Z9-0006Ta-Ur for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:16 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-4954df200ddso26531405e9.0 for ; Mon, 17 Aug 2026 12:00:10 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993209; x=1787598009; 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=o6yZjBL4vkE927udb0cZYGdUDjMGKn9+RSUoNO8M+S4=; b=cJiIZFdiDzwNkMdFKW0sJz3lVAbHh0IkopZnl/GpH2BwHnO050uacsv9b8Z+Krv+h+ FidWJk6xvYjTBxJv5E1y83GgsVZ+C6piqVngS2egBzSL61bso/Uk+tWHlzUcDVkmz09a nCHgXtfTV/DS8PS4YnIQavL/0er3FDzmbGGdFY/9SeJyNNl2zQbc73uZJOWuauxiQDvX 33XbGUvX0BPBj/iekYRqV5a//JhoJDkag85xTCpRd7rtRruOey0F2RFojnI+fj/DAIRY L/9s+TUbvjSLd46ZMvNEqWfczCiDHCdy5xyl9AAqBtnYLbdn6itUQd278H2LwXuWS4Q9 oBsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993209; x=1787598009; 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=o6yZjBL4vkE927udb0cZYGdUDjMGKn9+RSUoNO8M+S4=; b=gONU2UH7eAwjEi7kurABRo1M9laWu1P+Q6ZqhsbGDvuVJ6kVNTYuX/T1SukDwjQKHr 0uebJ+rSpG1gvwSA7tPtKBdZEGDl1WNI9Wasf9L7rtwBxHn77ggPdj/BtDP/LpYdg/50 n/zZAphbar4kvQEHKQ7HIOGaqiKzMNTlFqQO5nOp4uM7Q8CEjTOkN+YR7L2Jpz1rVs4n hYeFizBEsAiKQacCaKfU2zKRvPCTmW1oG4j5eryOt+A8sb1CVNCxz1uoz+VOqOopWW31 kCvyqn4YFy/Wu2tc4XebEG/mXkO2y1JeRVpv5wv+FjENB9K5lyETGP2PHHl9rM50dKt4 NK7w== X-Gm-Message-State: AOJu0YxK9/02JZ6Xz4ZY2gVP3o/mRDJv5+Ny0M6Ru28+3GgITQvNQYyG SL3zvs/z0zGqUb6iwhVDdeFruA1Qsdyl/cVYJd1pYO4gcq3/rzriejYDlf5rRUrTB+AsKGbNjYN vbH7/ X-Gm-Gg: AR+sD10kM791a4S49aEAneEqk26evRU3j8rwK+F3fzDgBvknBSi48DiA9TSMeXvgAKi Nv9zC3pzsPfIff+owO8WshESecxiWrZIrRUssR+/g9wjl6wCBec/aN+yYV1k2o7RwQhSQUpFOHp 3Sd9XZd69XEN0NFbFjX9meIMKFg9f4yh0gPa49xMhRxOKrFqSwIdpZA24Oi7WR8UqjahtBiEeVg sLX2PbH3+pFnLyzjBhiysXzO2c7r/ahTv/GwyvbC492dB9TDRlaMBmwRsSKxcptLU0x/lnVWVjg kCVRkm6kHo/Dc5ar642xJyQNMLrb5K7UKdcLoWFco2lovDUkeiEA7IqDlJLPGv1rEVrOtRv+TA6 yPo9t+X5kn4uBmmF/MQOO9f4Oc2GTASYkTr7PYcXlhqwhpNsYR4htVzp5CKNzq7mlF33h5mYox6 zd0AA3FFuokHVHSsOCU9dRLd0T/Kxgj9YomdQ= X-Received: by 2002:a7b:c4d0:0:b0:498:1595:be7b with SMTP id 5b1f17b1804b1-4998792f242mr315784085e9.4.1786993209111; Mon, 17 Aug 2026 12:00:09 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 21/25] iotests: cover storing a parallels dirty bitmap Date: Mon, 17 Aug 2026 20:59:38 +0200 Message-ID: <20260817185942.1065143-22-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993407908158500 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev parallels-bitmap covers loading a bitmap and parsing the Format Extension. Storing one is the other direction and is not covered at all. Nothing compares a stored bitmap with the writes it describes: test 165 compares a hash across a VM restart, which the same code produces and consumes, so a serialization wrong in both directions passes it. Write known ranges and read the bitmap back over NBD, in the shapes the storage code decides between: short ranges, a chunk dirty as a whole, a dirty run shorter than the cluster which serializes it, and a dirty tail. A bitmap which does not fit is refused when it is created, as the L1 table shares the Format Extension cluster with the feature headers of the bitmaps already there. One which fits an empty cluster does not fit next to seven others, and those seven have to survive the refusal. The rest is read out of the image file, as that is what the next open will see: a removal has to reach it when the command is given rather than when the node is closed, and the in use flag has to go with an inactivation and come back when the node is activated again. A bitmap which can not be written used to be lost in silence, so blkdebug fails the write of its data cluster: the loss has to be reported while the guest data still goes through, and the flag has to survive the failed inactivation. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/tests/parallels-bitmap | 174 +++++++++++++++++- tests/qemu-iotests/tests/parallels-bitmap.out | 45 +++++ 2 files changed, 218 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/tests/parallels-bitmap b/tests/qemu-iotests= /tests/parallels-bitmap index 601bfc5228..1cf2fd2add 100755 --- a/tests/qemu-iotests/tests/parallels-bitmap +++ b/tests/qemu-iotests/tests/parallels-bitmap @@ -25,7 +25,8 @@ import uuid from qemu.utils import VerboseProcessError =20 import iotests -from iotests import qemu_nbd_popen, qemu_img, qemu_img_map, log, file_path +from iotests import qemu_nbd_popen, qemu_img, qemu_img_create, qemu_img_ma= p, \ + qemu_io, log, file_path, QemuStorageDaemon =20 iotests.script_initialize(supported_fmts=3D['parallels']) =20 @@ -258,3 +259,174 @@ def check_multi_l1(): =20 =20 check_multi_l1() + + +# Storing a bitmap. The driver has to produce the extension itself here, +# so the images are real ones rather than hand crafted clusters. + +INUSE_MAGIC =3D 0x746F6E59 +INUSE_OFF =3D 0x2c +EXT_OFF =3D 0x38 +TRACKS_OFF =3D 0x1c + +stored =3D file_path('stored') +copy =3D file_path('copy') +STORED =3D '9b7b8b2e-1c4a-4d3f-8e6a-1f2d3c4b5a69' +OTHER =3D '11111111-2222-3333-4444-555555555555' + + +def read_header(off, fmt): + with open(stored, 'rb') as f: + return struct.unpack_from(fmt, f.read(0x40), off)[0] + + +def in_use(): + return read_header(INUSE_OFF, ' (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1786993403460411.0198559383075; Mon, 17 Aug 2026 12:03:23 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2al-0000FG-SK; Mon, 17 Aug 2026 15:01:51 -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 1ww2ZE-0006LW-RN for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:19 -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 1ww2ZA-0006U8-3n for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:16 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4956242332dso39996295e9.2 for ; Mon, 17 Aug 2026 12:00:11 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993210; x=1787598010; 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=CvpNndt5UQYV0DMSUg/YxV83XuMVe1Vd7A60QVj55t0=; b=EzLxsQ7h7PKMvxqnybAEcm1h1BMhqlr2usywChhukH6xlamvkKYO+AMpHXkAPEJhvW p0sLQIcI9/JzyadGYsnrXTVsSug+UrjsVWst4N8XloFIAXUyWnWiQJckYldeWuCnrk3d 0hP/q8Y24dH4cxF58A63GMf4pR+K0ShrXRthNPQqnhpQ9NWeQPYo91WGV2A18QzL0H+X sxotWaczrutgug7ot1mROoKNcmEeodN/8WLZpZAGsBM9oA9IDMtcROMBdkFVhg4bJyao LNIrUJK/jP0bw2BSksByy3g071Od56IwCzn6qpPwVgRLw00aWCHgQe0BklJhQkxI68rO qjJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993210; x=1787598010; 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=CvpNndt5UQYV0DMSUg/YxV83XuMVe1Vd7A60QVj55t0=; b=jRqJX8hNHsmQD+FdQWrMvR6N4YRjuL734+BLQDOvfvz8hJ3/DlS08EvbdcJGJPdoKf QbDeNa5/3rI2ZbgGrI4eZyIa3uHTFWLCzhAGFTPCOdcf56r6JVuyk1/6LfruHaga0vqY iMeLBA5XbWYgmJMxthahXwmYxlEc+xbvSuaw/HYhik2f3mJEcK6+WwYs6xqc9k9TV9yy rW2xvhM4hWeuYeBj23A+5eO1124CSHGKS0z/oEijo4x3BUrnIMwJurQ0CjASwYzuCXZL PVy+MLRSlS+wWFLywX3Ki33ubSZ5P8S44YEF3onDSFl78GGYVprdcwdLEBsDehNXgrmo brdA== X-Gm-Message-State: AOJu0Yyl/0sjyDkAQCfL0zeTRmYQlOVmFUu/DK9hKTV99xzzqCs289+T pqQ57IpaHMz9saTFLthiVryNtWBXwUmCc4ZScQ7vAyaTCEQcfGtnKV6QRe0erLIpjNk8UMkP1Ub U94YU X-Gm-Gg: AR+sD13hIoaC4wP1BWnj7COJW1uFLMpsL1ZC5sAH9DL3JKx8fAJNiwN02T6afHyKlWu qhytwdB6HZREaBai7BUxxrNxoqYfcHCQwVnuK9QTY/7DDVuuAjylqEYfPd+F3elIDCdEE8g8cOF l01KJrt4ln8gBWRHc8i5f4KfVrZ7s5DO9NOEaIuySb4jAC82ql9yw/bNzogJojCw/+xtfC913To lEjoOj3pASdMhqDLydts/nrKnqZEsxKBVglauB0EbkJIZbLPuSvmifY/3E1StcM1qiezD43prW3 R1eeOFLC5Jg8tCVcQBfhVOcJxp66hB6R/T7JN4ZVfkjhzApdyOAAps+U7c++M/Ib86ZqEASxxt/ IUgFjnRZVzaSgoGy8+dz1tca31RCygALq7zLGgYT5AD+YSRmJb9vPLQmPm5w8BDd3gg7tYhEzHk z77Y7DamjwfiC6RTZKyZPxf1iZ0Ibzrl4Re4ho4UZ3IqgLtZUjyQ== X-Received: by 2002:a05:600c:8b6b:b0:499:8f9f:e9ee with SMTP id 5b1f17b1804b1-4998f9febbdmr348902645e9.7.1786993210441; Mon, 17 Aug 2026 12:00:10 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 22/25] iotests: cover the qemu-img bitmap operations on parallels Date: Mon, 17 Aug 2026 20:59:39 +0200 Message-ID: <20260817185942.1065143-23-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993403867158501 Content-Type: text/plain; charset="utf-8" From: Denis V. Lunev qemu-img-bitmaps drives convert --bitmaps and every qemu-img bitmap sub-command, but for qcow2 alone. It is built on a backing chain and a rebase, which parallels has neither of, so half of it could not run there and the format is left with no coverage of any of this. Cover what applies in the parallels test instead. A copy made with --bitmaps has to carry them, and raw has to refuse them. --merge and --clear leave the bitmap count alone, --remove-all sweeps it to zero, and --remove-all --add in one invocation leaves only the bitmap which was just added. An image which was not closed correctly is left out. parallels-checks covers that already, next to the code which drops the bitmaps. Cc: Stefan Hajnoczi Signed-off-by: Denis V. Lunev --- tests/qemu-iotests/tests/parallels-bitmap | 39 +++++++++++++++++++ tests/qemu-iotests/tests/parallels-bitmap.out | 12 ++++++ 2 files changed, 51 insertions(+) diff --git a/tests/qemu-iotests/tests/parallels-bitmap b/tests/qemu-iotests= /tests/parallels-bitmap index 1cf2fd2add..37367defa6 100755 --- a/tests/qemu-iotests/tests/parallels-bitmap +++ b/tests/qemu-iotests/tests/parallels-bitmap @@ -273,6 +273,7 @@ stored =3D file_path('stored') copy =3D file_path('copy') STORED =3D '9b7b8b2e-1c4a-4d3f-8e6a-1f2d3c4b5a69' OTHER =3D '11111111-2222-3333-4444-555555555555' +MERGED =3D '22222222-3333-4444-5555-666666666666' =20 =20 def read_header(off, fmt): @@ -430,3 +431,41 @@ log('--- and the image is still readable') res =3D qemu_img('info', '-f', iotests.imgfmt, stored, check=3DFalse) log('image opened' if res.returncode =3D=3D 0 else iotests.filter_testfiles(res.stdout).strip()) + + +# qemu-img-bitmaps drives these for qcow2 alone, as it is built on a +# backing chain and a rebase, which parallels has neither of. + +log('--- bitmaps can not be preserved into raw') +make_image(STORED) +res =3D qemu_img('convert', '--bitmaps', '-f', iotests.imgfmt, '-O', 'raw', + stored, copy, check=3DFalse) +log(' ' + iotests.filter_testfiles(res.stdout).strip()) + +log('--- convert --bitmaps carries the bitmaps into the copy') +make_image(STORED, OTHER) +qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0x11 1M 64k', stored) +qemu_img('convert', '--bitmaps', '-f', iotests.imgfmt, '-O', iotests.imgfm= t, + stored, copy) +info =3D iotests.qemu_img_info('-f', iotests.imgfmt, copy) +data =3D info.get('format-specific', {}).get('data', {}) +log(' %d bitmaps in the copy' % len(data.get('bitmaps', []))) + +log('--- merging one bitmap into a new one') +qemu_img('bitmap', '--add', '--merge', STORED, '-f', iotests.imgfmt, + stored, MERGED) +log(' %d bitmaps stored' % len(bitmaps_reported())) + +log('--- clearing a bitmap keeps it in the image') +qemu_img('bitmap', '--clear', '-f', iotests.imgfmt, stored, STORED) +log(' %d bitmaps stored' % len(bitmaps_reported())) + +log('--- remove-all sweeps every bitmap of the image') +qemu_img('bitmap', '--remove-all', '-f', iotests.imgfmt, stored) +log(' %d bitmaps after remove-all' % len(bitmaps_reported())) + +log('--- remove-all with --add leaves only the new bitmap') +make_image(STORED, OTHER) +qemu_img('bitmap', '--remove-all', '--add', '-f', iotests.imgfmt, + stored, MERGED) +log(' ' + ' '.join(bitmaps_reported())) diff --git a/tests/qemu-iotests/tests/parallels-bitmap.out b/tests/qemu-iot= ests/tests/parallels-bitmap.out index 994c67390e..df6f676106 100644 --- a/tests/qemu-iotests/tests/parallels-bitmap.out +++ b/tests/qemu-iotests/tests/parallels-bitmap.out @@ -92,3 +92,15 @@ read 65536/65536 bytes at offset 0 0 bitmaps stored --- and the image is still readable image opened +--- bitmaps can not be preserved into raw + qemu-img: Format driver 'raw' does not support bitmaps +--- convert --bitmaps carries the bitmaps into the copy + 2 bitmaps in the copy +--- merging one bitmap into a new one + 3 bitmaps stored +--- clearing a bitmap keeps it in the image + 3 bitmaps stored +--- remove-all sweeps every bitmap of the image + 0 bitmaps after remove-all +--- remove-all with --add leaves only the new bitmap + 22222222-3333-4444-5555-666666666666 --=20 2.53.0 From nobody Sat Sep 26 23:53:30 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=1786993372; cv=none; d=zohomail.com; s=zohoarc; b=ZkxQYmIXl3gP87QzFz3R1DWRTeyj7RkP8wPRl5DyuVyLck9GJWdig6nv0XYTUsxZWx4f1DNEWGqePbdCJkJVJxTlnBsB0dVRxy3xP2k5r1f12SEiHIx0dysF8AXeei7HSEw1wxgQ+vm+DdoU/am9NINGnMar07TCgsK1t+UpcjY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993372; 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=1I9KPDeH4n9Og1iKxEsMFcR+jZAbO/7dXYA5zvlc4Gg=; b=DwfYiq+d7MjZ642rVIjUVwu1fVFaRYPT0PX4oksy20kYSKDNqvdwMf6VXziP3O5ICIUS+wiQHspgAmry+Y331VHF63vHzl23+SOBlCncTK6eoD/YoUMjpeOf6sK2MMlpmq5pBJsOoYfES5fesPNuIk8lf/l9ZrfmO5HB8ehH71c= 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 1786993372666925.0019344879377; Mon, 17 Aug 2026 12:02:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2az-00025Z-NK; Mon, 17 Aug 2026 15:02:05 -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 1ww2ZF-0006OO-Tp for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:20 -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 1ww2ZB-0006UW-0F for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:17 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-4921eed3fa2so30520975e9.0 for ; Mon, 17 Aug 2026 12:00:12 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993211; x=1787598011; 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=1I9KPDeH4n9Og1iKxEsMFcR+jZAbO/7dXYA5zvlc4Gg=; b=kI0/wn5mlq3Cop2X/NCWmt4MYrgEv/n8FfG3D/mT10nsEz28lCOglcDXioBLL77SEX 2ULG07v7I4LL1r1NPpEAM3G0pyPIjL+ZVxdIOCAUEK960ywElkTzg4dvCC00R4DzEfDV Cr3Qg94pM/1Ymgzn5SmpR6301z74TM0P579tn3nc2YryDj1Oaj/8hakI4CWsgq4Vhmlr ZqQgc6ayp7BjUuQCRLtM+l8yx1szfLcb2VsiPcfPTZFv5c1SBTIRrtoHqZDvxaNpgYK4 LiWn5ujf07jPMdP7DT4DCKGRDZhIWhJwsOcJeCE6U7tvI4LYlGXKoCnO2Eiiny0kd2OA CDkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993211; x=1787598011; 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=1I9KPDeH4n9Og1iKxEsMFcR+jZAbO/7dXYA5zvlc4Gg=; b=U795JZmh2KUEJefTQvFYXUZZtYaFbtk7BwdfMtVeUapxSB5+vcZagneuEJ3TJOZnme b+iaA7KxKUr9UmOjSAwqVrMm4lMEPTRlYvkRgzuqhgKj7qhekks48IuKIlJ0W8hqlpEJ fndXfJHjpDeMADuaRbg24zVMmTo8IBtee2j9qvHBTGcfXvWxWMnVGy/ci0h54sZgGuVe x0u+OWMPTWWWsbicH/hFFEwzE3ai3wr6+sT9MuH39XZK17wuIuv6Wq5JHWSJdZUKgNiq yJD6FRm9mlq7w6o8QIFJJD7j8lm9hfuOIooRhSQKL6WRWgXsEYUjY7p6cz+ZM+cBkFEH 3JrQ== X-Gm-Message-State: AOJu0YxlJWeiMdphGAFNdqDozlwL73QWsXYgL8xNZ6kg1rxTL8OlpQNS OuUt35sVcq+nWVfgIjZFx4fCBNNzZkZexth3Rz4NBYXweizgZl3YLWkxNewLLyQvfCKAzGmv/qB xKA4s X-Gm-Gg: AR+sD10vtIjBlMvYeUN8IakAovO3ugXK0OKfpNfDjPPy4xavIwMOjhaUwkl8H/acYMR 222Ex0dNdFqcRRpCzu5YjPXXzrinS/bal8zucLms9TigFYEVpFA1v9/H6+NX1Z7eMrO0+/bIT8+ cj0E34JYOeZ22/bmUN0E68V2eKN6zIW+idVmU/JKxhhp/NLT6zwyxZfJRCbeB6sbWnPPNLSr1bH 0QOQt08BrjxUoqxl7PpRcmSo4oiFK71iHopAXTtgxh7pPN1Xc5ASzJUFDEp0ceG3a2/WhKJvzLb nnN5399Sh3EDkPIwjfH9jzLlvF+4oIjwV+tnwwZFfE/Cm9ukqagfmnTP4yhmq8xDD/fTJddauxZ u1JDrhCpLURqwBz1LKsSBtPfBd009hcWBxTIVzgDtw22bHhgQUJshQ2AQuU9AAHPbISNgyU/sDV s8wSUe/nqflgCIfWMKxXPzgFqJ7vC0jEttGW6B3DtCkGLYTWa0pg== X-Received: by 2002:a05:600c:4e11:b0:495:6bc9:62b0 with SMTP id 5b1f17b1804b1-4999fb5be5amr42157765e9.17.1786993211382; Mon, 17 Aug 2026 12:00:11 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi Subject: [PATCH v6 23/25] iotests: cover a broken Format Extension and a combined repair Date: Mon, 17 Aug 2026 20:59:40 +0200 Message-ID: <20260817185942.1065143-24-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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=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: 1786993373750158500 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 4c8fc17fa9..084eded89d 100755 --- a/tests/qemu-iotests/tests/parallels-checks +++ b/tests/qemu-iotests/tests/parallels-checks @@ -444,6 +444,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 7aaa4636d7..5dc2963a98 100644 --- a/tests/qemu-iotests/tests/parallels-checks.out +++ b/tests/qemu-iotests/tests/parallels-checks.out @@ -294,6 +294,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 23:53:30 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=1786993394; cv=none; d=zohomail.com; s=zohoarc; b=fsCiQEFQ2QYRI3sfULvLKu8aAmttqhiT31osJteI+oaBD7g9Frx4Lf2av8L6Lyvh7fJU/GhpKrhGWO6xRL370m89oIGuzXZqK5afO5i+Htk5P4cBHFY6M6cDN5c0+HCVskiCgLcaIK9WKfag4stIsC9qYe/yasiU6KV6n/ID8iU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993394; 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=pRVn12OZURVOkefSN5IC+KPyhyzqGTNv//YQOD1+l6Q=; b=KZ6vLV/01OujiHbV7ros0WrhKSsZHr0E+kfDT4wFor+H84ym5rUdS1nsi38n3ubDVuVlIaTrkjJqxILsBXA7m+jfBLZewC7WpfU34x1Dgcbs9Ke35u1EK4vHpsE2DwJrw9185Ou2omiKYgf4CZvLGEuOMWDrFnk0phE7EdRFi9A= 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 1786993394866622.5046902770869; Mon, 17 Aug 2026 12:03:14 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2aj-0008Ni-JQ; Mon, 17 Aug 2026 15:01:49 -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 1ww2ZG-0006OS-Ba for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:27 -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 1ww2ZC-0006V9-3U for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:17 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-495590dde14so47154795e9.0 for ; Mon, 17 Aug 2026 12:00:13 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993212; x=1787598012; 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=pRVn12OZURVOkefSN5IC+KPyhyzqGTNv//YQOD1+l6Q=; b=FLFVoerdoNx6OKEtdK9LwbsYCnTNqYPmCQksjBE+tPUW+Choe4ux/ds4A6rOw8Vlov OG4zpcbhu24xyvjaMBXozfw/sr0gSqBfOwIOWIQMMUA0U2zG9LMVh86IRe3kLh5RAzeM sS2giGHKf1u/T1Ssb3Ay0emRKrBJ8nzKYC+x3LVrgef6C24bpS88yU6Xq/VtJpQDSHdO b1kfRc452iEjOc0aeVl0/n8LAaNC/Qrd5Hf8JJBPw+sQt2pg8b8b3SYyD/+29ZM79nHQ i06MXmKeG3fA9dudjaDGZqGfDd2U++guameGVQItOjEW0qVuFq3pp/kywXDcvFQOcPu3 OuVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993212; x=1787598012; 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=pRVn12OZURVOkefSN5IC+KPyhyzqGTNv//YQOD1+l6Q=; b=bVutwUsoBd+Vi5o19SfXWsQML6zUH8PDrdz5N9tTO7qpZ0rFfj1vy3wMLvLXItYIYe RJa4lJOq3POtlbNainz6Rq9ge9/DEX0oyB739laSPWMCkKPztKDzSYaFgD9topjQP5hO OOCG5bu5VzpjNUaQ+j5VrES3nNlLq2qzbrd+0HU/EM2SjVK15MrQDI8ft1bq/2LQMjZW byY8Xnf4ENlsXRN8cKsFgDSJZeIk1nwX6taUaEe22rFwvUreIMYJirfr5YB0+OKB3pQv z/oZNB2qH1U9jRYVBBLpECfKg9PXxf5My9GIT59aWtTkfDFHfUKZEXivSiD8oTbejiaS 5h5g== X-Gm-Message-State: AOJu0Ywwta+rVOf6OeBYu3J9z4qMFscmG0xOwwDBQAdN0c4lz3YWYa98 0W1Tl8Szn+DNhxxw4iq9ds2Gwl6B9EU74K0CBtywbuV5y6wE6pxFBw1wPexFI+9QVBzS1pVcVVQ rhphO X-Gm-Gg: AR+sD13vzVF1Onwdshct+9kNGngyIIYPYkI8i4+BttSUVcEVcr+vlJihO+DdN6/JlQ0 ojeUABbby8UCb/kN6O//KNwfL7GszLbidRbE6jn3+KZ5kZH42zmvvhTqbteu2L4AkgN/1wf5O4d n5kg9gt6r7j3Tcra6mhi076jZBBWPFcLGBvPETr5+YPsqT93v91hTI8CtJNpd4nP5aiywk3K0fS iZ/nnyhuAgrZg1lTB1kcUeSbIhazQXwQ/qyTdLQI5PTQD8gvlbTnMrD/cquZ7D9OZqk0vv7oWh5 XqPc72f60/BoH1JuTEkbWRb8uYQ1a5UQRzWQ8IdVOXvRyGvEhhp303B3zIygP7g8sRM7l0Y3oti jIh8Dbq332aZmR2xPQoGh7+/eH4e+IfKdgLIdpyZNEziEQXGWMLdJ9sVHyYEBE2AwAXMAY2478E r95YgMpHCLXdgHpeffqCNXQt7YYsk0E0yJ0lay1EX9DOXpIN9AOQ== X-Received: by 2002:a05:600c:46cf:b0:499:8807:345f with SMTP id 5b1f17b1804b1-4999fb8a0f0mr33016805e9.13.1786993212517; Mon, 17 Aug 2026 12:00:12 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Alexander Ivanov Subject: [PATCH v6 24/25] tests: Turned on 256, 299, 304 and block-status-cache for parallels format Date: Mon, 17 Aug 2026 20:59:41 +0200 Message-ID: <20260817185942.1065143-25-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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::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=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: 1786993395780158500 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 198f282087..1ebf999930 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']) =20 test_img =3D file_path('test.qcow2') 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 23:53:30 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=1786993360; cv=none; d=zohomail.com; s=zohoarc; b=ZeBYH8fCRvN5G0mAm0cCig0TE1B4JsogprAX1Kx2ERi/EkikK2Mo61PrVR5K+UTrjLnvTeZZfcXUJbLwKD3Mn8W3PiAnToSRSwfVNWEegNTnw75v+rFtqE92AisPKCwpDvjh8gHI4TtqUxcB7Lg5noV1fJbSupqCdR7D7sraaCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1786993360; 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=Ja0e38s/qENhcuVZ7qPwvVptslecPabtUXFO8ATqnYI=; b=JiIqwe4J4lbsyRgTi88KmmUAK8O+EXHxewcIj8w/EJOga34QqeLJlNYtDw2RWR+ssQs/bswZD1zAtjJo5huhkR+xDykYCRXvh3Cg0gn5m68WULUnF2rggZXqkNABY/3InhaDcmH3bLi/GwrcsMiOgkG17jnGJCA2lMv1FFjHXfo= 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 1786993360522579.9306037870685; Mon, 17 Aug 2026 12:02:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ww2ao-0000j1-7o; Mon, 17 Aug 2026 15:01: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 1ww2ZG-0006Of-Lz for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:31 -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 1ww2ZD-0006Vv-Q2 for qemu-devel@nongnu.org; Mon, 17 Aug 2026 15:00:18 -0400 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-4994c49f588so2365185e9.0 for ; Mon, 17 Aug 2026 12:00:14 -0700 (PDT) Received: from athena ([2a06:5b06:b600:300:f6f8:884c:b162:eaeb]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49996188217sm381011085e9.13.2026.08.17.12.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 12:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1786993214; x=1787598014; 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=Ja0e38s/qENhcuVZ7qPwvVptslecPabtUXFO8ATqnYI=; b=Nll/cPDkKfPDGvMj5IAcK/ae2H0PXJxcJjF5krjcjwxIPJXu1j4q2KGVVYl1eEZ7km RWzwIywb4Ddautoa+Hc9STiNRtXIx3ENUtZLhuVeoX6STUo6IB7KD5DxjNdDJhK7FolV eC7FXs3gqk3Qp6NGrBar6Dk0O3FcnfJwQm4JYa5skgPOcd7K5y3lYhmCf8UFk0Euoi7e TBLgcZAmACT0jqcewMG+9fhjX4L939DT77THhkYMrfv8Tyv9UKgM/+ZleuVZ5J0vVGqq pFjt11wNwevXQTt20nNY/m21Y4psuAx+0K5G+/tNtpyLjLaTwW4RXYeygSbblCqkcpkk cY+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786993214; x=1787598014; 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=Ja0e38s/qENhcuVZ7qPwvVptslecPabtUXFO8ATqnYI=; b=K5WSVfhc9VlYR7Iu5EqREyvMl47IqaF6PIBQu4awc8QnXtPs2zFBNHVcPDeKpU1ctp lN99MXZ40UDJKiHPVRGp+zhTMXBz50KTJSFC41pyuO+F2fGl0+Ll3b+bPWVde1zgW+Gj xzg7SXM//zJNDZQ61QhB8e61sg4eZgClVcb6MKIUrxXkkoHcuAFi+6mfHYjnBNvPy1I2 eNaLRe6O/zrLYBNpQmygcy3aUg3kOM06ZpLfL6L505IiyY4AWgtyiZAd6T6lwR0lE4RX dC/TeiXdm9CkNiFrgMix2ruQ1Ax+k0gZbT3ZIIO5/sI4DXJTlZOIZARfffzcfciNo1G0 VQLw== X-Gm-Message-State: AOJu0Ywm0Kuxj1bZb1Di6k2gjCnFU72ZWZUGGwAAJSA90fEyurMqk0BN S7iUAXxvccVZOCaCh2JNbEU3E1xWGqnJUTMKqqoHLv+YdjMDrHKVyc8gR3JS2C69fimxMJflOjU IkWeq X-Gm-Gg: AR+sD13zTVrS6UD3SY/zkntfF0rS5UOHZZdpxGFp/hAVibdwBeh68LE+12WrZ2pMAaO oVhMtTpeVimzGK6o05YMyuIUT1lMs7B/NxsRiLh6yS2NxkjNYn2TVDANXaS9Us46o5YUVvI7Kxk J/KMwkR5RQLLK4B87U0ZBFDNBQ6pgMjFEO9ZfIMnzY6ienv12ayKwzS6ZtohLN6CfVrBE18xg2E 4RU9yV57uuVJQOSOK5R8Fz7qVEpxE7KZbcbas/tsiex978Q1DMu1nA6AZyPyH5k0DUVtnIT9cii zCEi6CoRGur8J9pgzhBNueB2kAiOP+v9DmmE20dvx3zaHn9JuZmSXw0nOa/2pJowZDUXLaxxwnW vFNFjcpKfqYYex2ojyB9i/Ub1p69yaYsZD5tEmvOKHsvpt3bhwX1JpH3c+/k+jAeix6zDJAbpxu vxsh0A71d/GPTgqre+a/dXMV0Gx/T9w8IOd3XROIXASBPlkS8YeE4= X-Received: by 2002:a05:600c:4fcc:b0:493:f783:c46a with SMTP id 5b1f17b1804b1-499a1f56bbfmr426865e9.6.1786993213725; Mon, 17 Aug 2026 12:00:13 -0700 (PDT) From: "Denis V. Lunev" To: qemu-devel@nongnu.org Cc: qemu-block@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Vladimir Sementsov-Ogievskiy Subject: [PATCH v6 25/25] tests: Add parallels format support to image-fleecing Date: Mon, 17 Aug 2026 20:59:42 +0200 Message-ID: <20260817185942.1065143-26-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260817185942.1065143-1-den@openvz.org> References: <20260817185942.1065143-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: 1786993361773158500 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 --- 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 5e3b2c7e46..7e7dafcf19 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'] @@ -61,12 +61,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 @@ -75,7 +81,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, @@ -130,7 +136,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