From nobody Mon Feb 9 03:14:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611590744; cv=none; d=zohomail.com; s=zohoarc; b=gtIqdYFvItyk6sjYVMu1b/3YuaoYVifFk9QUanj3fTTcX04l6wcNb1gB62CP9IxRz10xU1Uk0MRYT1wN3Awu6KPZ68DY6fcFW1JN5txmgwERfxk+2/dFVw5YfXe1KAzwL3KRymCfSgoPfFUnL/2/5hk7WshL2mQAPtTC1usSIXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611590744; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=urc9h6Uvst5XpzoqiBD9j2i11rJUTyFKUr7E6+afcsk=; b=g+A3HW0GW0jo8AZTGF4jz9hcOdFwj3GwlOFoVBXy759d+isnhzqOy/CSRuBFXbE+VqjG2au8JSmNYNKGAzCSyNWVQbRc4hXi2ZOorx4fOOjfTi6dGVbwAgAm3nrgwP7iAVRCuhn5ohb74QwJs/pcK3aOqjMd+zKK5Xs0fw09IhE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1611590744485168.7862008074436; Mon, 25 Jan 2021 08:05:44 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-9ciNhKuJNISaaVE-y8PFBw-1; Mon, 25 Jan 2021 11:05:40 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 47C5580362A; Mon, 25 Jan 2021 16:05:34 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF8D65C1C5; Mon, 25 Jan 2021 16:05:33 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C2CC418095FF; Mon, 25 Jan 2021 16:05:32 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10PG5Ull018181 for ; Mon, 25 Jan 2021 11:05:30 -0500 Received: by smtp.corp.redhat.com (Postfix) id 740C05D9DB; Mon, 25 Jan 2021 16:05:30 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id BAC6B5D9DC for ; Mon, 25 Jan 2021 16:05:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611590742; h=from:from:sender:sender: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=urc9h6Uvst5XpzoqiBD9j2i11rJUTyFKUr7E6+afcsk=; b=N9uUqmgNnNXBnJThir3arr71NPQhyBhaJfkS0f0NgwI9dpWkQKCG/TjCog48qLRCxJo4e7 HkPg4c3TjOz0CKKdc2hI1L9InBlvYf4CrXns5Tw+A/BXY4pgfI9pxqs/qHfdigZTBNj5sA q866YHGgutF3JTRJllsy+Lh5feBEFbE= X-MC-Unique: 9ciNhKuJNISaaVE-y8PFBw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/12] virStorageSourceGetBackingStoreStr: Move the function earlier Date: Mon, 25 Jan 2021 17:05:13 +0100 Message-Id: <14c92845cfbdb6485560def31279b410a830feb7.1611590679.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move it together with virStorageSourceGetRelativeBackingPath which is the main reason why it exists. Upcoming patch will modify the comment and arguments refering to virStorageSourceGetRelativeBackingPath so it's better if they are together. Signed-off-by: Peter Krempa --- src/storage_file/storage_source.c | 100 +++++++++++++++--------------- 1 file changed, 50 insertions(+), 50 deletions(-) diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index 85734d9275..430e3214c4 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -1880,6 +1880,56 @@ virStorageSourceGetRelativeBackingPath(virStorageSou= rcePtr top, } +/** + * virStorageSourceGetBackingStoreStr: + * @src: storage object + * + * Extracts the backing store string as stored in the storage volume descr= ibed + * by @src and returns it to the user. Caller is responsible for freeing i= t. + * In case when the string can't be retrieved or does not exist NULL is + * returned. + */ +int +virStorageSourceGetBackingStoreStr(virStorageSourcePtr src, + char **backing) +{ + ssize_t headerLen; + int rv; + g_autofree char *buf =3D NULL; + g_autoptr(virStorageSource) tmp =3D NULL; + + *backing =3D NULL; + + /* exit if we can't load information about the current image */ + if (!virStorageSourceSupportsBackingChainTraversal(src)) + return 0; + + rv =3D virStorageSourceAccess(src, F_OK); + if (rv =3D=3D -2) + return 0; + if (rv < 0) { + virStorageSourceReportBrokenChain(errno, src, src); + return -1; + } + + if ((headerLen =3D virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, + &buf)) < 0) { + if (headerLen =3D=3D -2) + return 0; + return -1; + } + + if (!(tmp =3D virStorageSourceCopy(src, false))) + return -1; + + if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0) + return -1; + + *backing =3D g_steal_pointer(&tmp->backingStoreRaw); + return 0; +} + + static bool virStorageSourceIsInitialized(const virStorageSource *src) { @@ -2562,53 +2612,3 @@ virStorageSourceGetMetadata(virStorageSourcePtr src, virHashFree(cycle); return ret; } - - -/** - * virStorageSourceGetBackingStoreStr: - * @src: storage object - * - * Extracts the backing store string as stored in the storage volume descr= ibed - * by @src and returns it to the user. Caller is responsible for freeing i= t. - * In case when the string can't be retrieved or does not exist NULL is - * returned. - */ -int -virStorageSourceGetBackingStoreStr(virStorageSourcePtr src, - char **backing) -{ - ssize_t headerLen; - int rv; - g_autofree char *buf =3D NULL; - g_autoptr(virStorageSource) tmp =3D NULL; - - *backing =3D NULL; - - /* exit if we can't load information about the current image */ - if (!virStorageSourceSupportsBackingChainTraversal(src)) - return 0; - - rv =3D virStorageSourceAccess(src, F_OK); - if (rv =3D=3D -2) - return 0; - if (rv < 0) { - virStorageSourceReportBrokenChain(errno, src, src); - return -1; - } - - if ((headerLen =3D virStorageSourceRead(src, 0, VIR_STORAGE_MAX_HEADER, - &buf)) < 0) { - if (headerLen =3D=3D -2) - return 0; - return -1; - } - - if (!(tmp =3D virStorageSourceCopy(src, false))) - return -1; - - if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0) - return -1; - - *backing =3D g_steal_pointer(&tmp->backingStoreRaw); - return 0; -} --=20 2.29.2