From nobody Sat Feb 7 09:53: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=1748508541; cv=none; d=zohomail.com; s=zohoarc; b=IhuAnzlfYdvj3hPhGpqUJC2TfZpSJqrsibZZnUXTSd4VmJnTRMB/cONizRxGF0B9w8S9ISID+vsuPmd/S4g8kAk5HQuF8vVTYkrJeqYAVq8FCRxgHXnqVvWWoOW5+/qPzcCq71T+lSmLvBPEbfzgEr6zZG0Jg2EYn+QBge+DCns= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1748508541; 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=CwZlUqV4m1EDcoHT9v3QGwHqnIj9KNUWTEw22h9Oer4=; b=Jvs8KvdPq35R0/Z6BHqzMhWDKxyO6PcHCJqO5wlzfIf2oneaWj7N6opOzUQERm7NnnaDqqbj55IQYyiU9HtOudFFSm+uN6yrNi0AsALkTvpR5/gT3iDASQpFqjxox/7h+HvzEGYjK8vjuXh7GBFbi/6i4i18RRsKrIA3UFE7ris= 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 1748508541317468.63400813858186; Thu, 29 May 2025 01:49:01 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6F4151350; Thu, 29 May 2025 04:49:00 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id F1EF813C9; Thu, 29 May 2025 04:43:51 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 9F53512E1; Thu, 29 May 2025 04:43:47 -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 DAD4F153F for ; Thu, 29 May 2025 04:43:23 -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-558-S7y5ZYHHPAmt7MA2SjekBA-1; Thu, 29 May 2025 04:43:21 -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 254BD18001EA for ; Thu, 29 May 2025 08:43:21 +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 4270219560AF for ; Thu, 29 May 2025 08:43:19 +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=1748508203; 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=k+RAjtmIVfOyP/MI88q3ZQyyILCGjmzBk5r8IaN+Z+s=; b=M7MdqQ+azeEoCwr4sAF8d7FquKCDxVk00AOK2o9g6SDjOky+MdoVlc37nsADdyB8YaRwf0 cM+ZeL+hR/WAvNoDxT7Lp/CAxtAiaTSPlqhj/7KqGfWI1Sx1k+XXr+5rmXz0fUyKqRGhhB q5OomH3EuvET0uEufWDmXQJqLTnS+Gg= X-MC-Unique: S7y5ZYHHPAmt7MA2SjekBA-1 X-Mimecast-MFC-AGG-ID: S7y5ZYHHPAmt7MA2SjekBA_1748508201 To: devel@lists.libvirt.org Subject: [PATCH 07/15] storage_file_probe: Refactor qedGetBackingStore into qedGetImageSpecific Date: Thu, 29 May 2025 10:43:01 +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: oWCJI3F0U9wbggyvp1DPxD93DRspPCIdzcMlD54lrY4_1748508201 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: Y7XL3VQ4BRSJQICR3TZLZNKSJVIOUXH3 X-Message-ID-Hash: Y7XL3VQ4BRSJQICR3TZLZNKSJVIOUXH3 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: 1748508542580116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Change to the new function prototype and adjust the code to fill the fields in virStorageSource directly. The code also converts the copying of the backing file string from 'g_new0' + 'memcpy' to 'g_strndup' as we treat it as a string later on. Signed-off-by: Peter Krempa --- src/storage_file/storage_file_probe.c | 28 ++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/src/storage_file/storage_file_probe.c b/src/storage_file/stora= ge_file_probe.c index 08fd3f2265..1544dded5c 100644 --- a/src/storage_file/storage_file_probe.c +++ b/src/storage_file/storage_file_probe.c @@ -117,7 +117,9 @@ static int qcow2GetFeatures(virBitmap **features, int f= ormat, static int vmdk4GetBackingStore(char **, int *, const char *, size_t); static int -qedGetBackingStore(char **, int *, const char *, size_t); +qedGetImageSpecific(virStorageSource *meta, + const char *buf, + size_t buf_size); #define QCOWX_HDR_VERSION (4) #define QCOWX_HDR_BACKING_FILE_OFFSET (QCOWX_HDR_VERSION+4) @@ -329,7 +331,7 @@ static struct FileTypeInfo const fileTypeInfo[] =3D { /* https://wiki.qemu.org/Features/QED */ 0, "QED", LV_LITTLE_ENDIAN, -2, 0, {0}, - QED_HDR_IMAGE_SIZE, 8, 1, NULL, NULL, qedGetBackingStore, NULL, NU= LL, NULL + QED_HDR_IMAGE_SIZE, 8, 1, NULL, NULL, NULL, NULL, NULL, qedGetImag= eSpecific }, [VIR_STORAGE_FILE_VMDK] =3D { 0, "KDMV", @@ -656,21 +658,22 @@ vmdk4GetBackingStore(char **res, } static int -qedGetBackingStore(char **res, - int *format, - const char *buf, - size_t buf_size) +qedGetImageSpecific(virStorageSource *meta, + const char *buf, + size_t buf_size) { unsigned long long flags; unsigned long offset, size; - *res =3D NULL; + g_clear_pointer(&meta->backingStoreRaw, g_free); + /* Check if this image has a backing file */ if (buf_size < QED_HDR_FEATURES_OFFSET+8) return 0; + flags =3D virReadBufInt64LE(buf + QED_HDR_FEATURES_OFFSET); if (!(flags & QED_F_BACKING_FILE)) { - *format =3D VIR_STORAGE_FILE_NONE; + meta->backingStoreRawFormat =3D VIR_STORAGE_FILE_NONE; return 0; } @@ -685,14 +688,13 @@ qedGetBackingStore(char **res, return 0; if (offset + size > buf_size || offset + size < offset) return 0; - *res =3D g_new0(char, size + 1); - memcpy(*res, buf + offset, size); - (*res)[size] =3D '\0'; + + meta->backingStoreRaw =3D g_strndup(buf + offset, size); if (flags & QED_F_BACKING_FORMAT_NO_PROBE) - *format =3D VIR_STORAGE_FILE_RAW; + meta->backingStoreRawFormat =3D VIR_STORAGE_FILE_RAW; else - *format =3D VIR_STORAGE_FILE_AUTO_SAFE; + meta->backingStoreRawFormat =3D VIR_STORAGE_FILE_AUTO_SAFE; return 0; } --=20 2.49.0