From nobody Tue Sep 9 02:56:52 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=1748508517; cv=none; d=zohomail.com; s=zohoarc; b=LknUIN9PobneaZwwAt7wfASbzB66wnYT5/vMvo5VN2NhxiGBRGp5NggjUqEMyTa1i7lYr8snMBVp9xea+aAgjPzTfwiU6fNC32Jv+Ke2J2OuiZh0E1//aEcnkUdEWQ5DzTLoeSn5JDBBeq71nrNPXwmczwmyyZI0ypPT5LQr26Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748508517; 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=KFLf1CumIHE2uCuk9QBux/cyoV47yJe3Em/uWLxv0fM=; b=QL7zawwf3+M+nUUxDcbh/KOSqbYkmVAkPf3bTxbe+6I8L4cXyDCawZfEf+vya0HG4RPw7XCWQaOQkuryl1EoNYRrRuJsbW3cdKW3RyuJGQk2/XUXMXX9MGw+6WtxrpF4M1Wfgovopt2LfCJjHQNcGyw08ej8BG4ZJzCXF92G/Jw= 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 1748508517261929.371617365951; Thu, 29 May 2025 01:48:37 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4EED41633; Thu, 29 May 2025 04:48:36 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 4083B1428; Thu, 29 May 2025 04:43:50 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B89E012FF; Thu, 29 May 2025 04:43:42 -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 8E4D513B3 for ; Thu, 29 May 2025 04:43:22 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-78-kpltcbxQMZ-R3SA9z8MtXA-1; Thu, 29 May 2025 04:43:20 -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-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B8E61195609E for ; Thu, 29 May 2025 08:43:19 +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 ECC2E19560AF for ; Thu, 29 May 2025 08:43:18 +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=1748508202; 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=jei5wN51nilMsGtKbPle4CLFo6AGNRR4mBcNLxicnCY=; b=WHbupnOfq6lWCQubi8k6DBZXj0hJPWir1RHlS2cV5DfIT8Y8ZnUs50lCjUVip810b8Eiat /u4IGHybnoY7CiWUsF9kNgU4Tnp8qL8d7+X0GF0cppAImfZOQFM1f16xZiCHEwNefXXExE obSRpETEUx/dAFS+JpGUPqsDQrytBv0= X-MC-Unique: kpltcbxQMZ-R3SA9z8MtXA-1 X-Mimecast-MFC-AGG-ID: kpltcbxQMZ-R3SA9z8MtXA_1748508199 To: devel@lists.libvirt.org Subject: [PATCH 06/15] storage_file_probe: Refactor cowGetBackingStore into cowGetImageSpecific Date: Thu, 29 May 2025 10:43:00 +0200 Message-ID: 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: 7s2nTydMALwtw7W8Nu-H_O39wreFfBBR7Q_hkUDM7-s_1748508199 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: XM5ZVJ6PCPARN27FJHQKVBLL5B7XSDK7 X-Message-ID-Hash: XM5ZVJ6PCPARN27FJHQKVBLL5B7XSDK7 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: 1748508518301116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Rename the function, adjust parameters and fix the code to fill the virStorageSource fields directly. Signed-off-by: Peter Krempa --- src/storage_file/storage_file_probe.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index 29837792e4..08fd3f2265 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -102,8 +102,10 @@ struct FileTypeInfo { }; -static int cowGetBackingStore(char **, int *, - const char *, size_t); +static int +cowGetImageSpecific(virStorageSource *meta, + const char *buf, + size_t buf_size); static unsigned long long qcow2GetClusterSize(const char *buf, size_t buf_size); @@ -303,7 +305,7 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { [VIR_STORAGE_FILE_COW] =3D { 0, "OOOM", LV_BIG_ENDIAN, 4, 4, {2}, - 4+4+1024+4, 8, 1, NULL, NULL, cowGetBackingStore, NULL, NULL, NULL + 4+4+1024+4, 8, 1, NULL, NULL, NULL, NULL, NULL, cowGetImageSpecific }, [VIR_STORAGE_FILE_QCOW] =3D { 0, "QFI", @@ -375,23 +377,22 @@ G_STATIC_ASSERT(G_N_ELEMENTS(qcow2IncompatibleFeature= Array) =3D=3D QCOW2_INCOMPATIBL static int -cowGetBackingStore(char **res, - int *format, - const char *buf, - size_t buf_size) +cowGetImageSpecific(virStorageSource *meta, + const char *buf, + size_t buf_size) { #define COW_FILENAME_MAXLEN 1024 - *res =3D NULL; - *format =3D VIR_STORAGE_FILE_AUTO; - if (buf_size < 4+4+ COW_FILENAME_MAXLEN) + g_clear_pointer(&meta->backingStoreRaw, g_free); + + if (buf_size < 4 + 4 + COW_FILENAME_MAXLEN) return 0; - if (buf[4+4] =3D=3D '\0') { /* cow_header_v2.backing_file[0] */ - *format =3D VIR_STORAGE_FILE_NONE; + if (buf[4 + 4] =3D=3D '\0') { /* cow_header_v2.backing_file[0] */ + meta->backingStoreRawFormat =3D VIR_STORAGE_FILE_NONE; return 0; } - *res =3D g_strndup((const char *)buf + 4 + 4, COW_FILENAME_MAXLEN); + meta->backingStoreRaw =3D g_strndup((const char *)buf + 4 + 4, COW_FIL= ENAME_MAXLEN); return 0; } --=20 2.49.0