From: John Ferlan Date: Mon, 2 Nov 2015 22:15:41 +0000 (-0500) Subject: storage: Introduce virStoragePoolObjFindPoolByUUID X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=c3afa6a9a3a0313172cdb586f54ebac5ab129d19;p=people%2Fliuw%2Flibxenctrl-split%2Flibvirt.git 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. --- diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index aeb67a715..bbf21f684 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 4f28dc155..912c232c3 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)