Re: [PATCH 4/5] storage: Create helper for virStorageBackendLogicalFindPoolSources

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

 



On 07.12.2015 21:47, John Ferlan wrote:
> Rework virStorageBackendLogicalFindPoolSources a bit to create a
> helper virStorageBackendLogicalGetPoolSources that will make the
> pvs call in order to generate a list of associated pv_name and vg_name's.
> 
> A future patch will make use of this for start/check processing to
> ensure the storage pool source definition matches expectations.
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  src/storage/storage_backend_logical.c | 52 ++++++++++++++++++++++++-----------
>  1 file changed, 36 insertions(+), 16 deletions(-)
> 
> diff --git a/src/storage/storage_backend_logical.c b/src/storage/storage_backend_logical.c
> index 536e617..53ba983 100644
> --- a/src/storage/storage_backend_logical.c
> +++ b/src/storage/storage_backend_logical.c
> @@ -414,10 +414,16 @@ virStorageBackendLogicalFindPoolSourcesFunc(char **const groups,
>      return -1;
>  }
>  
> -static char *
> -virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
> -                                        const char *srcSpec ATTRIBUTE_UNUSED,
> -                                        unsigned int flags)
> +/*
> + * @sourceList: Pointer to a storage pool source list
> + *
> + * Use the pvs command to fill the list of pv_name and vg_name associated
> + * into the passed sourceList.
> + *
> + * Returns 0 if successful, -1 and sets error on failure
> + */
> +static int
> +virStorageBackendLogicalGetPoolSources(virStoragePoolSourceListPtr sourceList)
>  {
>      /*
>       * # pvs --noheadings -o pv_name,vg_name
> @@ -431,11 +437,7 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
>          2
>      };
>      virCommandPtr cmd;
> -    char *retval = NULL;
> -    virStoragePoolSourceList sourceList;
> -    size_t i;
> -
> -    virCheckFlags(0, NULL);
> +    int ret = -1;
>  
>      /*
>       * NOTE: ignoring errors here; this is just to "touch" any logical volumes
> @@ -447,20 +449,38 @@ virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
>          VIR_WARN("Failure when running vgscan to refresh physical volumes");
>      virCommandFree(cmd);
>  
> -    memset(&sourceList, 0, sizeof(sourceList));
> -    sourceList.type = VIR_STORAGE_POOL_LOGICAL;
> -
>      cmd = virCommandNewArgList(PVS,
>                                 "--noheadings",
>                                 "-o", "pv_name,vg_name",
>                                 NULL);
>      if (virCommandRunRegex(cmd, 1, regexes, vars,
>                             virStorageBackendLogicalFindPoolSourcesFunc,
> -                           &sourceList, "pvs") < 0) {
> -        virCommandFree(cmd);
> -        return NULL;
> -    }
> +                           sourceList, "pvs") < 0)
> +        goto cleanup;
> +    ret = 0;
> +
> + cleanup:
>      virCommandFree(cmd);
> +    return ret;
> +}
> +
> +
> +static char *
> +virStorageBackendLogicalFindPoolSources(virConnectPtr conn ATTRIBUTE_UNUSED,
> +                                        const char *srcSpec ATTRIBUTE_UNUSED,
> +                                        unsigned int flags)
> +{
> +    virStoragePoolSourceList sourceList;
> +    size_t i;
> +    char *retval = NULL;
> +
> +    virCheckFlags(0, NULL);
> +
> +    memset(&sourceList, 0, sizeof(sourceList));
> +    sourceList.type = VIR_STORAGE_POOL_LOGICAL;
> +
> +    if (virStorageBackendLogicalGetPoolSources(&sourceList) < 0)
> +        goto cleanup;
>  
>      retval = virStoragePoolSourceListFormat(&sourceList);
>      if (retval == NULL) {
> 

ACK

Michal

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