From nobody Wed Feb 11 10:17:40 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) client-ip=209.132.183.39; envelope-from=libvir-list-bounces@redhat.com; helo=mx6-phx2.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.39 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) by mx.zohomail.com with SMTPS id 1489596001695837.4220360256344; Wed, 15 Mar 2017 09:40:01 -0700 (PDT) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2FGaqJp023605; Wed, 15 Mar 2017 12:36:52 -0400 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v2FGalWw024900 for ; Wed, 15 Mar 2017 12:36:47 -0400 Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2FGafII000870; Wed, 15 Mar 2017 12:36:47 -0400 From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 15 Mar 2017 17:37:16 +0100 Message-Id: <1838446d333e75580e18d5479abe805ba47f5940.1489595335.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 04/23] util: storage: Add variables for node names into virStorageSource 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 'nodeformat' should be used for strings which describe the storage format object, and 'nodebacking' for the actual storage object itself. --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/util/virstoragefile.h | 10 ++++++++++ 3 files changed, 51 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 31d6085cb..bf2039a75 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2490,6 +2490,7 @@ virStorageNetProtocolTypeToString; virStorageSourceBackingStoreClear; virStorageSourceClear; virStorageSourceCopy; +virStorageSourceFindByNodeName; virStorageSourceFree; virStorageSourceGetActualType; virStorageSourceGetSecurityLabelDef; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index c8eb26aa7..3bcb69bf6 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2012,6 +2012,8 @@ virStorageSourceCopy(const virStorageSource *src, VIR_STRDUP(ret->backingStoreRaw, src->backingStoreRaw) < 0 || VIR_STRDUP(ret->snapshot, src->snapshot) < 0 || VIR_STRDUP(ret->configFile, src->configFile) < 0 || + VIR_STRDUP(ret->nodeformat, src->nodeformat) < 0 || + VIR_STRDUP(ret->nodebacking, src->nodebacking) < 0 || VIR_STRDUP(ret->compat, src->compat) < 0) goto error; @@ -2232,6 +2234,9 @@ virStorageSourceClear(virStorageSourcePtr def) virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageAuthDefFree(def->auth); + VIR_FREE(def->nodebacking); + VIR_FREE(def->nodeformat); + virStorageSourceBackingStoreClear(def); } @@ -3781,3 +3786,38 @@ virStorageSourceIsRelative(virStorageSourcePtr src) return false; } + + +/** + * virStorageSourceFindByNodeName: + * @top: backing chain top + * @nodeName: node name to find in backing chain + * @index: if provided the index in the backing chain + * + * Looks up the given storage source in the backing chain and returns the + * pointer to it. If @index is passed then it's filled by the index in the + * backing chain. On failure NULL is returned and no error is reported. + */ +virStorageSourcePtr +virStorageSourceFindByNodeName(virStorageSourcePtr top, + const char *nodeName, + unsigned int *index) +{ + virStorageSourcePtr tmp; + + if (index) + *index =3D 0; + + for (tmp =3D top; tmp; tmp =3D tmp->backingStore) { + if (STREQ_NULLABLE(tmp->nodeformat, nodeName) || + STREQ_NULLABLE(tmp->nodebacking, nodeName)) + return tmp; + + if (index) + (*index)++; + } + + if (index) + *index =3D 0; + return NULL; +} diff --git a/src/util/virstoragefile.h b/src/util/virstoragefile.h index 5f6e41911..9ebfc1108 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -276,6 +276,10 @@ struct _virStorageSource { /* Name of the child backing store recorded in metadata of the * current file. */ char *backingStoreRaw; + + /* metadata that allows identifying given storage source */ + char *nodeformat; /* name of the format handler object */ + char *nodebacking; /* name of the backing storage object */ }; @@ -395,4 +399,10 @@ virStorageSourcePtr virStorageSourceNewFromBackingAbso= lute(const char *path); bool virStorageSourceIsRelative(virStorageSourcePtr src); +virStorageSourcePtr +virStorageSourceFindByNodeName(virStorageSourcePtr top, + const char *nodeName, + unsigned int *index) + ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2); + #endif /* __VIR_STORAGE_FILE_H__ */ --=20 2.12.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list