From nobody Tue Sep 9 09:52:21 2025 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=1748508682; cv=none; d=zohomail.com; s=zohoarc; b=j9CjPZHfIQxx0K0EJrdRCHE3MY3SZGEYfNiVxJdCdwun9/B9mu3d9mYO/K9rh69YX472lETmaXWNrVmMlkZjLNZwPJ0WvlYheDcYZ2pVydlLJevVu53lDD4Gf3kPj6WQswAIj/UGV52xPfKS+uI/KmqD8+BAjn17HnK/7Fxwf2w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748508682; 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=eJMNCQtWWVwonU/SlehEOIYrf7HKizIMyqeeELygNXE=; b=XmsNQRIDTAIL+mCo8DM1ve6RtApdQTAH0R394Rn2Qv5WP0zUDKtuJZKWTxxxYjxmfe+rz3f0awctZ63PEyVDRjt9kDoJ9tvdQHa9yLMViMvDTSXhK+M08FwtquBIsT1gSmoV72scyyXoydcP0HIuvkrHArD7yy7Sf/NBCTCalJo= 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 174850868207086.59537714729493; Thu, 29 May 2025 01:51:22 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 171F817CE; Thu, 29 May 2025 04:51:21 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2A6381772; Thu, 29 May 2025 04:44:06 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C2CB315E9; Thu, 29 May 2025 04:43:51 -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 36FA912B1 for ; Thu, 29 May 2025 04:43:30 -0400 (EDT) Received: from mx-prod-mc-08.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-648-LPnSYUAoNqq4n_BoF55aOw-1; Thu, 29 May 2025 04:43:28 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 68AD71800DA1 for ; Thu, 29 May 2025 08:43:27 +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 A15A019560AF for ; Thu, 29 May 2025 08:43:26 +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=1748508209; 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=B8+qeR633nGAZmbCqIWdJe60Z9eYSYA5p+2qKmYQgg8=; b=EbTuna7knjkf1MUV3ZDwwC4v3izu09sB8icRvWwxPynk0WpJxGcUbUqGOmks29u7iQNjpS 0ARLAacS+q9Z+sV/3HciecOK4LY/uzMiXf9242xCMMxn+qssrtKLTydPaZ7d+vA94YYwnV CVvP9FKoUvJzzNT9qe5dUdAsJvgjKas= X-MC-Unique: LPnSYUAoNqq4n_BoF55aOw-1 X-Mimecast-MFC-AGG-ID: LPnSYUAoNqq4n_BoF55aOw_1748508207 To: devel@lists.libvirt.org Subject: [PATCH 12/15] storage_file_probe: Call qcow2GetFeatures from qcow2GetImageSpecific Date: Thu, 29 May 2025 10:43:06 +0200 Message-ID: <7911f8acb712cf4393365b02125a6a47c9bf06eb.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: ixK_An11RWYrj2Ousq9cP2eHJ3twwxWvN02ncYFn2H0_1748508207 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5RO37AFEQ624JMEHXOBACMJD2MZCZXLW X-Message-ID-Hash: 5RO37AFEQ624JMEHXOBACMJD2MZCZXLW 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: 1748508684663116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Parse qcow2 feature flags from qcow2GetImageSpecific. To achieve that qcow2GetFeatures is refactored to take virStorageSource directly and fill the data. To avoid the need to pass 'format' the parsing of the qcow2 version is changed to access the offset directly (same as in qcow2GetExtensions) Signed-off-by: Peter Krempa --- src/storage_file/storage_file_probe.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index b357fdeb66..10e159c27b 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -115,8 +115,6 @@ qcow2GetImageSpecific(virStorageSource *meta, 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); static int vmdk4GetImageSpecific(virStorageSource *meta, const char *buf, @@ -329,7 +327,7 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { NULL, NULL, qcow2GetDataFile, - qcow2GetFeatures, + NULL, qcow2GetImageSpecific }, [VIR_STORAGE_FILE_QED] =3D { @@ -590,14 +588,13 @@ qcow2GetFeaturesProcessGroup(uint64_t bits, static int -qcow2GetFeatures(virBitmap **features, - int format, - char *buf, +qcow2GetFeatures(virStorageSource *meta, + const char *buf, ssize_t len) { - int version =3D -1; + int version =3D virReadBufInt32BE(buf + QCOWX_HDR_VERSION); - version =3D virReadBufInt32BE(buf + fileTypeInfo[format].versionOffset= ); + g_clear_pointer(&meta->features, virBitmapFree); if (version =3D=3D 2) return 0; @@ -605,17 +602,17 @@ qcow2GetFeatures(virBitmap **features, if (len < QCOW2v3_HDR_SIZE) return -1; - *features =3D virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST); + meta->features =3D virBitmapNew(VIR_STORAGE_FILE_FEATURE_LAST); qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATU= RES_COMPATIBLE), qcow2CompatibleFeatureArray, G_N_ELEMENTS(qcow2CompatibleFeatureArray), - *features); + meta->features); qcow2GetFeaturesProcessGroup(virReadBufInt64BE(buf + QCOW2v3_HDR_FEATU= RES_INCOMPATIBLE), qcow2IncompatibleFeatureArray, G_N_ELEMENTS(qcow2IncompatibleFeatureArra= y), - *features); + meta->features); return 0; } @@ -639,6 +636,9 @@ qcow2GetImageSpecific(virStorageSource *meta, if (qcowXGetBackingStore(meta, buf, buf_size) < 0) return -1; + if (qcow2GetFeatures(meta, buf, buf_size) < 0) + return -1; + format =3D meta->backingStoreRawFormat; if (qcow2GetExtensions(buf, buf_size, &format, NULL) < 0) --=20 2.49.0