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.
This commit is contained in:
John Ferlan 2015-11-02 17:15:41 -05:00
parent 27432ba70c
commit c3afa6a9a3
2 changed files with 24 additions and 0 deletions

View File

@ -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;
}

View File

@ -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)