From nobody Mon Feb 9 08:14:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1748508632; cv=none; d=zohomail.com; s=zohoarc; b=Z3vT3t0FHIB9U/qnlinS+YySeMHRMqDsCIIrl6NF3mMpevW3uqZnFEcqS7876zUNFPVqTC94S8XGqsYXWw95pwmtI3/L5uDIB5rlEge/mOlLi7j66z+78UH82M1cltnLYNj4usdUJ6dlpVpFfS8H5RabcDZx6imf6RhitsG4qkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748508632; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=tthUZjwXB/WICQz6FwuS6m7Pskv+cJ7ClTx8wjgVEDg=; b=csM4HALdRkG7KkK0uDhOWJH3nCXLdWN62fg9btRwQHI3ePrXsYgZfSx8ERgcC6+5DFC66KaEDtvA6WDPDXdOJIey56lTsKBY+VQn9TJappbNSVYXlESINqAKYzQN8KjbgeRPmM31ZIZ8TDsFPiMhVun74UYeOEPK41WcVeQ9rZk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1748508632154437.49649650770743; Thu, 29 May 2025 01:50:32 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3AEF5164B; Thu, 29 May 2025 04:50:31 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 61AC41711; Thu, 29 May 2025 04:44:00 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id AAACD1406; Thu, 29 May 2025 04:43:48 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id ADA8914AE for ; Thu, 29 May 2025 04:43:27 -0400 (EDT) Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-2gsXMBhiPMmlLwJ3RYi3Sw-1; Thu, 29 May 2025 04:43:25 -0400 Received: from mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.40]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E6C4F180034A for ; Thu, 29 May 2025 08:43:24 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.44.22.3]) by mx-prod-int-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 269ED19560AF for ; Thu, 29 May 2025 08:43:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1748508207; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yi7REij1Go86Wpa/dSqn8a7dnP1fG04rInbZ5IfLgHg=; b=cKKSrv72VZhZ/YkbHBY1WlkbPPujbjRhYhaEtpFrdAx862BMtmVqlHM8egiNNRXB/OZJxi EU/PlQ3QAnF24XQaHWEDRJNovzy7+nxseiWekTnl++w8VhZry2RcoZka4mk5O3x+b2wX5X FQxmPHaEHsQDtWSy6rrg4hbNF5/Rauo= X-MC-Unique: 2gsXMBhiPMmlLwJ3RYi3Sw-1 X-Mimecast-MFC-AGG-ID: 2gsXMBhiPMmlLwJ3RYi3Sw_1748508205 To: devel@lists.libvirt.org Subject: [PATCH 10/15] storage_file_probe: Move logic from qcow2GetClusterSize to qcow2GetImageSpecific Date: Thu, 29 May 2025 10:43:04 +0200 Message-ID: <1d0603c49173a05bab2d77ac1c6db732aa44cd9a.1748507931.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.40 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: z2M_40Ir3JtSsPIWmUP3O_xdvKcEF8ZL_FJMt6bKY7Y_1748508205 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: TNSQHQIR4OAGT4NRSDHQFESLUP7A2EW4 X-Message-ID-Hash: TNSQHQIR4OAGT4NRSDHQFESLUP7A2EW4 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1748508633570116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Move the cluster size parser into the image specific code for qcow2, which will later allow us to remove the callback for cluster size which is not used by any other format. Signed-off-by: Peter Krempa --- src/storage_file/storage_file_probe.c | 31 ++++++++------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index ce8ba4b884..21a1013102 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -114,9 +114,6 @@ static int qcow2GetImageSpecific(virStorageSource *meta, const char *buf, size_t buf_size); -static unsigned long long -qcow2GetClusterSize(const char *buf, - size_t buf_size); static int qcow2GetDataFile(char **, virBitmap *, char *, size_t); static int qcow2GetFeatures(virBitmap **features, int format, char *buf, ssize_t len); @@ -329,7 +326,7 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { LV_BIG_ENDIAN, 4, 4, {2, 3}, QCOWX_HDR_IMAGE_SIZE, 8, 1, qcow2EncryptionInfo, - qcow2GetClusterSize, + NULL, NULL, qcow2GetDataFile, qcow2GetFeatures, @@ -532,24 +529,6 @@ qcow2GetExtensions(const char *buf, } -static unsigned long long -qcow2GetClusterSize(const char *buf, - size_t buf_size) -{ - int clusterBits =3D 0; - - if ((QCOWX_HDR_CLUSTER_BITS_OFFSET + 4) > buf_size) - return 0; - - clusterBits =3D virReadBufInt32BE(buf + QCOWX_HDR_CLUSTER_BITS_OFFSET); - - if (clusterBits > 0) - return 1ULL << clusterBits; - - return 0; -} - - static int qcowXGetBackingStore(virStorageSource *meta, const char *buf, @@ -601,6 +580,14 @@ qcow2GetImageSpecific(virStorageSource *meta, { int format; + meta->clusterSize =3D 0; + if (buf_size > (QCOWX_HDR_CLUSTER_BITS_OFFSET + 4)) { + int clusterBits =3D virReadBufInt32BE(buf + QCOWX_HDR_CLUSTER_BITS= _OFFSET); + + if (clusterBits > 0) + meta->clusterSize =3D 1ULL << clusterBits; + } + if (qcowXGetBackingStore(meta, buf, buf_size) < 0) return -1; --=20 2.49.0