Re: [PATCH v3 1/4] storage: Introduce storagePoolLookupByTargetPath

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

 



On 12/02/14 17:13, 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@xxxxxxxxxx>
> ---
>  src/storage/storage_driver.c | 42 ++++++++++++++++++++++++++++++++++++++++++
>  src/storage/storage_driver.h |  4 ++++
>  2 files changed, 46 insertions(+)
> 
> diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c
> index 88dea34..5ff63cd 100644
> --- a/src/storage/storage_driver.c
> +++ b/src/storage/storage_driver.c
> @@ -1466,6 +1466,48 @@ storageVolLookupByPath(virConnectPtr conn,
>      return ret;
>  }
>  
> +virStoragePoolPtr
> +storagePoolLookupByTargetPath(virConnectPtr conn,
> +                              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);
> +    }
> +    storageDriverUnlock();
> +
> +    if (!ret) {
> +        virReportError(VIR_ERR_NO_STORAGE_VOL,
> +                       _("no storage pool with matching target path '%s'"),
> +                       path);
> +    }
> +
> +    VIR_FREE(cleanpath);
> +    return ret;
> +}
> +
>  
>  static int
>  storageVolDeleteInternal(virStorageVolPtr obj,
> diff --git a/src/storage/storage_driver.h b/src/storage/storage_driver.h
> index b805ddd..74da9bb 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
> +storagePoolLookupByTargetPath(virConnectPtr conn,
> +                              const char *path);

ATTRIBUTE_NONNULL is still missing

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

ACK if and only if you add the attribute ;)

Peter

Attachment: signature.asc
Description: OpenPGP digital signature

--
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]