From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2578DC88E41 for ; Fri, 11 Sep 2026 00:58:57 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1x4pb8-0005ew-Oy; Thu, 10 Sep 2026 20:58:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1x4oPd-0001hj-FR for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:54 -0400 Received: from mail-wm2-x10.google.com ([2a00:1450:4864:31::10]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1x4oPa-0007AR-1b for qemu-devel@nongnu.org; Thu, 10 Sep 2026 19:42:37 -0400 Received: by mail-wm2-x10.google.com with SMTP id 5b1f17b1804b1-49b912e2406so1543325e9.1 for ; Thu, 10 Sep 2026 16:42:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=openvz.org; s=google; t=1789083752; x=1789688552; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=sS82x9gVdySNfwG4lS1OAUl+9Ll5vTkrbexOf8WD9EQ=; b=c59TwasX7Vy6TwPrNRcRm3oPW+zN1xC/t6ZHQaATtXqQ7a5heGNyS3k6pcG9zVPlPU BlLSTKr0h8YlYi0zxQsEzzKVSPTqZnZziGUvuLFSJdTrr8O8vQwsKb1uzjCyYJQ7fQVq 6FpFKxJnbjPlUsH8PeRpywksW2YW9sMFoWCuTt+z5duskRsWuxjotaVLKcTVSr3IZo/U kAszx38Yl2LXzPCgrWHlQUb6OLkdLSZpVldsCL6MEoPCf58lSXWSEQCvpBloyLKFv+V4 odt53KbQb6/wXpaZHZXHI3CH0oajJ+4ZeITscT57kmr+JVHIEeYIj0gy1iLLAKrZp/+t pzMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1789083752; x=1789688552; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=sS82x9gVdySNfwG4lS1OAUl+9Ll5vTkrbexOf8WD9EQ=; b=ZBzgYH2IbjATjHUXlPYWhLncQALye0O4bnba5MIFxrBBoMO59lK8OAD3ZMl1nzIzZ0 XAP7isyQgJMHYglHZvjJm7Jq9tB3Cvgzw+B8HmGz1IWe3veGrh14zYFUP/G2O+VxI9IH nKXRQK+kRWE/hoXVz43QfIrdee37hFHxWDYiRSzn2LW8dPRke0EUGRKOlcLg/DmB5t2x dagosPvYp5EiSgMKUxOwC5cVsZ6bI8ARatmfnSX+W86kz1aJ1iGmhcho3UlsJluOQhoT tMeyPJJCXL4tK3Wrwg6AJuh2zrY+e53xUJeBL4Kt2iQE6Vn9V/vfgo0hrfjMHvSPcEWl 9kWA== X-Gm-Message-State: AFuF++k6ZP6Uxly8DTXBvCo1Sp4sfFBk3eHG6tRxlOGvUPEzeOPOwgDt t8fIj9cScsq0EADh99RC6lN9Ri6c7am3dd1QTeeeYAZNB2Eq5QPCafxRPmHOUpLsACpWceT+A2z QdrJY X-Gm-Gg: AYBFou3idM7RzZPYZnO8WdceuXyV007FFuhgrY3HZ12Hzrh+dcYdX0/JjnrgTJa0AsI AORZ4h7glOryOGLplKub1oNCetU+z4K9HZSJ9ehHcgsarFZWqC1cq3pISR3gPBSCY5xANkL4OK1 PUGuDFS3PeD/VdhH7Z9TPcLBG5E4qTKEiNFgolrkITe3F9DVFE02M7vBkSDeqLpDO0/GCuIxqLY hXX3zz0zXGEXLXWllQAWQuphO6BaXPjueq53gxzcKlSV7ul1VClMENW/G6R9xFRJ066cRlob63f 7PTR5uCIEtFdWl2NEoAbXQvBiCuT5lwPJcz9S6XxOBKHUGIhdi/soKGJJZmCjyI8htZUYfoYnJM sg6/rasUjBIOL4e2D8vWG9HLf+pec6GDtyc83W7G+tTdB0If3KKe2EMTIVzDxMy1A0o6L5RQwH9 WU05bL0quejeyDtWw4hBr9WQ3sljhJk+/hc7fg9wlEmQ0p2fV92g5zo/wxEJaRlHSzAvTg X-Received: by 2002:a05:600c:4f53:b0:49e:620b:918c with SMTP id 5b1f17b1804b1-49e620b9490mr8643315e9.5.1789083752401; Thu, 10 Sep 2026 16:42:32 -0700 (PDT) Received: from athena.sw.ru ([2a06:5b06:b600:300:54f3:cc87:964b:3604]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-49e62231360sm7726775e9.4.2026.09.10.16.42.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Sep 2026 16:42:32 -0700 (PDT) From: "Denis V. Lunev" To: qemu-block@nongnu.org Cc: qemu-devel@nongnu.org, "Denis V. Lunev" , Stefan Hajnoczi , Thomas Huth Subject: [PULL 07/29] iotests: cover the Parallels format extension parser Date: Fri, 11 Sep 2026 01:42:00 +0200 Message-ID: <20260910234222.3039975-8-den@openvz.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260910234222.3039975-1-den@openvz.org> References: <20260910234222.3039975-1-den@openvz.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:31::10; envelope-from=den@openvz.org; helo=mail-wm2-x10.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org From: Denis V. Lunev Extend the existing test with hand crafted extension clusters, built in the test rather than shipped as samples. Each corruption case is one qemu-img info run which either opens the image or reports why it was rejected: extension magic and checksum, feature magic and flags, payloads running past the cluster, bitmap granularity, an L1 entry which overflows when converted to an offset, and a cluster_size larger than the image file. Two more cases load a bitmap spanning two L1 entries. Termination by a signal is not covered by check=False, so it is caught and logged to keep the remaining cases running. Cc: Stefan Hajnoczi Cc: Thomas Huth Signed-off-by: Denis V. Lunev --- .../qemu-iotests/tests/parallels-read-bitmap | 180 +++++++++++++++++- .../tests/parallels-read-bitmap.out | 33 ++++ 2 files changed, 212 insertions(+), 1 deletion(-) diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap b/tests/qemu-iotests/tests/parallels-read-bitmap index 38ab5fa5b2..5cbef25018 100755 --- a/tests/qemu-iotests/tests/parallels-read-bitmap +++ b/tests/qemu-iotests/tests/parallels-read-bitmap @@ -18,14 +18,22 @@ # along with this program. If not, see . # +import hashlib +import struct +import uuid + +from qemu.utils import VerboseProcessError + import iotests -from iotests import qemu_nbd_popen, qemu_img_map, log, file_path +from iotests import qemu_nbd_popen, qemu_img, qemu_img_map, log, file_path iotests.script_initialize(supported_fmts=['parallels']) nbd_sock = file_path('nbd-sock', base_dir=iotests.sock_dir) +nbd_sock2 = file_path('nbd-sock2', base_dir=iotests.sock_dir) disk = iotests.file_path('disk') bitmap = 'e4f2eed0-37fe-4539-b50b-85d2e7fd235f' +MULTI_L1_UUID = '5f2e1c00-0000-4000-8000-0123456789ab' nbd_opts = f'driver=nbd,server.type=unix,server.path={nbd_sock}' \ f',x-dirty-bitmap=qemu:dirty-bitmap:{bitmap}' @@ -51,3 +59,173 @@ with qemu_nbd_popen('--read-only', f'--socket={nbd_sock}', log(f'{a}-{b-1}') else: log(a) + + +# Hand crafted Format Extension clusters. + +EXT_MAGIC = 0xAB234CEF23DCEA87 +BITMAP_MAGIC = 0x20385FAE252CB34A + +CLUSTER = 512 # one sector per track +SECTORS = 8 # 4 KiB disk +EXT_SECTOR = 1 # the extension cluster follows the header +EH_SIZE = 24 # ParallelsFormatExtensionHeader +FH_SIZE = 24 # ParallelsFeatureHeader +BF_SIZE = 32 # ParallelsDirtyBitmapFeature + +crafted = file_path('crafted') + + +def feature(magic, data_size, flags=0): + return struct.pack('> 30 + last = (chunk['start'] + chunk['length']) >> 30 + log(f'dirty {first}-{last} GiB') + + +check_multi_l1() diff --git a/tests/qemu-iotests/tests/parallels-read-bitmap.out b/tests/qemu-iotests/tests/parallels-read-bitmap.out index e8f6bc9e96..3b3f90c8de 100644 --- a/tests/qemu-iotests/tests/parallels-read-bitmap.out +++ b/tests/qemu-iotests/tests/parallels-read-bitmap.out @@ -4,3 +4,36 @@ dirty clusters (cluster size is 64K): 10-12 30 Kill NBD server + +--- well-formed extension +image opened +--- wrong extension magic +qemu-img: Could not open 'TEST_DIR/PID-crafted': Wrong parallels Format Extension magic: 0xab234cef23dcea86, expected: 0xab234cef23dcea87 +--- wrong extension checksum +qemu-img: Could not open 'TEST_DIR/PID-crafted': Wrong checksum in Format Extension header. Format extension is corrupted. +--- unknown feature +qemu-img: Could not open 'TEST_DIR/PID-crafted': Unknown feature: 0x20385fae252cb34b +--- feature flags set +qemu-img: Could not open 'TEST_DIR/PID-crafted': Flags for extension feature are unsupported +--- feature data_size beyond the cluster +qemu-img: Could not open 'TEST_DIR/PID-crafted': Feature data_size exceedes Format Extension cluster +--- feature payload consumes the cluster +qemu-img: Could not open 'TEST_DIR/PID-crafted': Can not read feature header, as remaining bytes (0) in Format Extension is less than Feature header size (24) +--- second feature payload beyond the cluster +qemu-img: Could not open 'TEST_DIR/PID-crafted': Feature data_size exceedes Format Extension cluster +--- bitmap granularity 0 +qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid bitmap granularity 0, expected a power of two of at least 512 bytes +--- bitmap granularity 3 +qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid bitmap granularity 1536, expected a power of two of at least 512 bytes +--- bitmap granularity 8388608 +qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid bitmap granularity 4294967296, expected a power of two of at least 512 bytes +--- bitmap L1 entry overflows +qemu-img: Could not open 'TEST_DIR/PID-crafted': Failed to read bitmap data cluster: Input/output error +--- cluster_size beyond the file size +qemu-img: Could not open 'TEST_DIR/PID-crafted': Invalid image: Format Extension is outside the image file +--- bitmap serialization coverage overflow +image opened +--- bitmap spanning two L1 entries +Start NBD server +dirty 32-64 GiB +Kill NBD server -- 2.53.0