From c3afa6a9a3a0313172cdb586f54ebac5ab129d19 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Mon, 2 Nov 2015 17:15:41 -0500 Subject: [PATCH] storage: Introduce virStoragePoolObjFindPoolByUUID 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. --- 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 aeb67a715b..bbf21f684f 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 4f28dc155d..912c232c38 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) -- GitLab