From nobody Mon Feb 9 00:55:45 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 1487877886869644.6504243724092; Thu, 23 Feb 2017 11:24:46 -0800 (PST) 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 v1NJLFuF057105; Thu, 23 Feb 2017 14:21:15 -0500 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1NJLCBB001290 for ; Thu, 23 Feb 2017 14:21:12 -0500 Received: from angien.brq.redhat.com (dhcp129-47.brq.redhat.com [10.34.129.47]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1NJL8uV028635; Thu, 23 Feb 2017 14:21:11 -0500 From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 23 Feb 2017 20:21:55 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [RFC PATCH 02/12] util: storage: Add preliminary storage 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" --- src/libvirt_private.syms | 1 + src/util/virstoragefile.c | 37 +++++++++++++++++++++++++++++++++++++ src/util/virstoragefile.h | 9 +++++++++ 3 files changed, 47 insertions(+) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 69d1bc860..078cca001 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2476,6 +2476,7 @@ virStorageNetProtocolTypeToString; virStorageSourceBackingStoreClear; virStorageSourceClear; virStorageSourceCopy; +virStorageSourceFindByNodeName; virStorageSourceFree; virStorageSourceGetActualType; virStorageSourceGetSecurityLabelDef; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 3e711228b..d8f66a8a1 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -2012,6 +2012,7 @@ 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->nodeName, src->nodeName) < 0 || VIR_STRDUP(ret->compat, src->compat) < 0) goto error; @@ -2232,6 +2233,8 @@ virStorageSourceClear(virStorageSourcePtr def) virStorageNetHostDefFree(def->nhosts, def->hosts); virStorageAuthDefFree(def->auth); + VIR_FREE(def->nodeName); + virStorageSourceBackingStoreClear(def); } @@ -3781,3 +3784,37 @@ 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->nodeName, 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..ffea60075 100644 --- a/src/util/virstoragefile.h +++ b/src/util/virstoragefile.h @@ -276,6 +276,9 @@ 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 *nodeName; }; @@ -395,4 +398,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.11.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list