[PATCH 3/4] storage: Introduce virStoragePoolObjFindPoolByUUID

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add a new API to search the currently defined pool list for a pool with
a matching UUID and return the locked pool object pointer.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/storage/storage_driver.c | 21 +++++++++++++++++++++
 src/storage/storage_driver.h |  3 +++
 2 files changed, 24 insertions(+)

diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
index aeb67a7..bbf21f6 100644
--- a/src/storage/storage_driver.c
+++ b/src/storage/storage_driver.c
@@ -3370,3 +3370,24 @@ virStorageTranslateDiskSourcePool(virConnectPtr conn,
     virStoragePoolDefFree(pooldef);
     return ret;
 }
+
+
+/*
+ * virStoragePoolObjFindPoolByUUID
+ * @uuid: The uuid to lookup
+ *
+ * Using the passed @uuid, search the driver pools for a matching uuid.
+ * If found, then lock the pool
+ *
+ * Returns NULL if pool is not found or a locked pool object pointer
+ */
+virStoragePoolObjPtr
+virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
+{
+    virStoragePoolObjPtr pool;
+
+    storageDriverLock();
+    pool = virStoragePoolObjFindByUUID(&driver->pools, uuid);
+    storageDriverUnlock();
+    return pool;
+}
diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
index 4f28dc1..912c232 100644
--- a/src/storage/storage_driver.h
+++ b/src/storage/storage_driver.h
@@ -57,6 +57,9 @@ int virStorageFileGetMetadata(virStorageSourcePtr src,
 int virStorageTranslateDiskSourcePool(virConnectPtr conn,
                                       virDomainDiskDefPtr def);
 
+virStoragePoolObjPtr virStoragePoolObjFindPoolByUUID(const unsigned char *uuid)
+    ATTRIBUTE_NONNULL(1);
+
 virStoragePoolPtr
 storagePoolLookupByTargetPath(virConnectPtr conn,
                               const char *path)
-- 
2.1.0

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]