[libvirt] [PATCH v2 1/4] storage: Introduce storagePoolLookupByPath

Peter Krempa pkrempa at redhat.com
Tue Dec 2 10:56:24 UTC 2014


On 12/01/14 15:57, Michal Privoznik wrote:
> While this could be exposed as a public API, it's not done yet as
> there's no demand for that yet. Anyway, this is just preparing
> the environment for easier volume creation on the destination.
> 
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
>  src/storage/storage_driver.c | 36 ++++++++++++++++++++++++++++++++++++
>  src/storage/storage_driver.h |  4 ++++
>  2 files changed, 40 insertions(+)
> 
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index 23b63f5..a4f1030 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -1466,6 +1466,42 @@ storageVolLookupByPath(virConnectPtr conn,
>      return ret;
>  }
>  

A comment describing how this works (mention that only active pools are
found), or ...

> +virStoragePoolPtr
> +storagePoolLookupByPath(virConnectPtr conn,

.. rename to LookupByTargetPath perhaps?

> +                        const char *path)
> +{
> +    size_t i;
> +    virStoragePoolPtr ret = NULL;
> +    char *cleanpath;
> +
> +    cleanpath = virFileSanitizePath(path);
> +    if (!cleanpath)
> +        return NULL;
> +
> +    storageDriverLock();
> +    for (i = 0; i < driver->pools.count && !ret; i++) {
> +        virStoragePoolObjPtr pool = driver->pools.objs[i];
> +
> +        virStoragePoolObjLock(pool);
> +
> +        if (!virStoragePoolObjIsActive(pool)) {
> +           virStoragePoolObjUnlock(pool);
> +           continue;
> +        }
> +
> +        if (STREQ(path, pool->def->target.path)) {
> +            ret = virGetStoragePool(conn, pool->def->name, pool->def->uuid,
> +                                    NULL, NULL);
> +        }
> +
> +        virStoragePoolObjUnlock(pool);
> +    }
> +
> +    VIR_FREE(cleanpath);
> +    storageDriverUnlock();
> +    return ret;
> +}
> +
>  
>  static int
>  storageVolDeleteInternal(virStorageVolPtr obj,
> diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
> index b805ddd..b51760a 100644
> --- a/src/storage/storage_driver.h
> +++ b/src/storage/storage_driver.h
> @@ -57,6 +57,10 @@ int virStorageFileGetMetadata(virStorageSourcePtr src,
>  int virStorageTranslateDiskSourcePool(virConnectPtr conn,
>                                        virDomainDiskDefPtr def);
>  
> +virStoragePoolPtr
> +storagePoolLookupByPath(virConnectPtr conn,
> +                        const char *path);

Add ATTRIBUTE_NONNULL(2)

> +
>  int storageRegister(void);
>  
>  #endif /* __VIR_STORAGE_DRIVER_H__ */
> 

ACK with the attribute and a comment about the usage of this func added.

Peter


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20141202/47a9d508/attachment-0001.sig>


More information about the libvir-list mailing list