From nobody Mon Feb 9 00:56:06 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.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 63.128.21.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=1611590763; cv=none; d=zohomail.com; s=zohoarc; b=XBR3omIKaf0VF3W8SlKaaLihf6Xn6zdBehDd4I6tvsQUo8XXADBpUiMBTxTV4Reaabow824Q7L7wILjuB8NFAYEVXKop2cZjDWVWUGBk7ZZ+a5HaehZDiszR5SeB/xmYJwXxbKKd89ChJWptR/PVUYqub35UpDiwfCQ58xgrL/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611590763; 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=q+/Z8EfuhjUhqv/htJArCB4yTml2n5i9JWqlnnj0Q7I=; b=UBlgft7hf+EaYdZQbmpKc6UOKkH1k9WblP7Z8KrJdP6SLUWOAKqm6yJrTnP3h+5ToiqC6GQp9ZjqC5+KdgGTgoPfkEoV/e7IxT/ZpiBcFqkv7ltS74Gf9Fu+3xEuQBqrqfP96/ZzKYGGJXvFgsSjH4ZkclM2bcBnfSERVuNw04E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.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 [63.128.21.124]) by mx.zohomail.com with SMTPS id 1611590763875201.71398238209997; Mon, 25 Jan 2021 08:06:03 -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-142-NEvERpYINm25exeboozJ5A-1; Mon, 25 Jan 2021 11:05:52 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2247019611A4; Mon, 25 Jan 2021 16:05:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F149D5D9E4; Mon, 25 Jan 2021 16:05:44 +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 BB6024E590; Mon, 25 Jan 2021 16:05:44 +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 10PG5Vxh018200 for ; Mon, 25 Jan 2021 11:05:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id 976AB5D9DC; Mon, 25 Jan 2021 16:05:31 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id EF9D35D9DB for ; Mon, 25 Jan 2021 16:05:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611590762; 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=q+/Z8EfuhjUhqv/htJArCB4yTml2n5i9JWqlnnj0Q7I=; b=RiPNH0LOq9NcBWUmNuomrqy8vn91qe+LPKBb/zObj7QU2F2ujKxjo+3rcRw/lkxcpsJizK SZwc4sJfobQi4cP7PRJp/yUmGbFm3J2y1DjwJvLlOKQk/+1Z9R00+QdjWyNC85JuQCbTeP YhwzSOdUMoivCDg0PlURwQv5xpedKTU= X-MC-Unique: NEvERpYINm25exeboozJ5A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/12] virStorageSourceGetBackingStoreStr: Return relative paths only Date: Mon, 25 Jan 2021 17:05:14 +0100 Message-Id: <391f76a0e87db8e5fb839fa2cca27995a9bb73d2.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.14 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" Rename the function to virStorageSourceFetchRelativeBackingPath and return relative paths only. The function is only used to restore the relative relationship between images so there's no need for it to be universal. Signed-off-by: Peter Krempa --- src/libvirt_private.syms | 2 +- src/qemu/qemu_block.c | 6 +----- src/qemu/qemu_snapshot.c | 13 +++---------- src/storage_file/storage_source.c | 22 +++++++++++++--------- src/storage_file/storage_source.h | 4 ++-- 5 files changed, 20 insertions(+), 27 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index fbaf16704b..c03b769c37 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -1691,7 +1691,7 @@ virStorageSourceChainLookup; virStorageSourceChown; virStorageSourceCreate; virStorageSourceDeinit; -virStorageSourceGetBackingStoreStr; +virStorageSourceFetchRelativeBackingPath; virStorageSourceGetMetadata; virStorageSourceGetMetadataFromBuf; virStorageSourceGetMetadataFromFD; diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index d845a3312d..6456100170 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -3420,7 +3420,6 @@ qemuBlockUpdateRelativeBacking(virDomainObjPtr vm, virStorageSourcePtr n; for (n =3D src; virStorageSourceHasBacking(n); n =3D n->backingStore) { - g_autofree char *backingStoreStr =3D NULL; int rc; if (n->backingStore->relPath) @@ -3432,15 +3431,12 @@ qemuBlockUpdateRelativeBacking(virDomainObjPtr vm, if (qemuDomainStorageFileInit(driver, vm, n, topsrc) < 0) return -1; - rc =3D virStorageSourceGetBackingStoreStr(n, &backingStoreStr); + rc =3D virStorageSourceFetchRelativeBackingPath(n, &n->backingStor= e->relPath); virStorageSourceDeinit(n); if (rc < 0) return rc; - - if (backingStoreStr && virStorageIsRelative(backingStoreStr)) - n->backingStore->relPath =3D g_steal_pointer(&backingStoreStr); } return 0; diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index bfc5a1a46b..39445738a2 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -1088,16 +1088,9 @@ qemuSnapshotDiskPrepareOne(virDomainObjPtr vm, dd->initialized =3D true; if (reuse) { - if (updateRelativeBacking) { - g_autofree char *backingStoreStr =3D NULL; - - if (virStorageSourceGetBackingStoreStr(dd->src, &backingSt= oreStr) < 0) - return -1; - if (backingStoreStr !=3D NULL) { - if (virStorageIsRelative(backingStoreStr)) - dd->relPath =3D g_steal_pointer(&backingStoreStr); - } - } + if (updateRelativeBacking && + virStorageSourceFetchRelativeBackingPath(dd->src, &dd->rel= Path) < 0) + return -1; } else { /* pre-create the image file so that we can label it before ha= nding it to qemu */ if (supportsCreate && dd->src->type !=3D VIR_STORAGE_TYPE_BLOC= K) { diff --git a/src/storage_file/storage_source.c b/src/storage_file/storage_s= ource.c index 430e3214c4..23d36507ea 100644 --- a/src/storage_file/storage_source.c +++ b/src/storage_file/storage_source.c @@ -1881,24 +1881,26 @@ virStorageSourceGetRelativeBackingPath(virStorageSo= urcePtr top, /** - * virStorageSourceGetBackingStoreStr: + * virStorageSourceFetchRelativeBackingPath: * @src: storage object + * @relPath: filled with the relative path to the backing image of @src if + * the metadata of @src refer to it as relative. * - * 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. + * Fetches the backing store definition of @src by updating the metadata f= rom + * disk and fills 'relPath' if the backing store string is relative. The d= ata + * is used by virStorageSourceGetRelativeBackingPath to establish the rela= tive + * path between two images. */ int -virStorageSourceGetBackingStoreStr(virStorageSourcePtr src, - char **backing) +virStorageSourceFetchRelativeBackingPath(virStorageSourcePtr src, + char **relPath) { ssize_t headerLen; int rv; g_autofree char *buf =3D NULL; g_autoptr(virStorageSource) tmp =3D NULL; - *backing =3D NULL; + g_clear_pointer(relPath, g_free); /* exit if we can't load information about the current image */ if (!virStorageSourceSupportsBackingChainTraversal(src)) @@ -1925,7 +1927,9 @@ virStorageSourceGetBackingStoreStr(virStorageSourcePt= r src, if (virStorageFileProbeGetMetadata(tmp, buf, headerLen) < 0) return -1; - *backing =3D g_steal_pointer(&tmp->backingStoreRaw); + if (virStorageIsRelative(tmp->backingStoreRaw)) + *relPath =3D g_steal_pointer(&tmp->backingStoreRaw); + return 0; } diff --git a/src/storage_file/storage_source.h b/src/storage_file/storage_s= ource.h index 480333d37a..58f88a3c01 100644 --- a/src/storage_file/storage_source.h +++ b/src/storage_file/storage_source.h @@ -138,8 +138,8 @@ virStorageSourceGetMetadata(virStorageSourcePtr src, ATTRIBUTE_NONNULL(1); int -virStorageSourceGetBackingStoreStr(virStorageSourcePtr src, - char **backing) +virStorageSourceFetchRelativeBackingPath(virStorageSourcePtr src, + char **relPath) ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); void --=20 2.29.2