[libvirt] [PATCH v2 2/5] virsh-volume: Introduce virshStorageVolKeyCompleter

Michal Prívozník mprivozn at redhat.com
Wed Jun 16 08:33:28 UTC 2021


On 6/16/21 10:02 AM, Lin Ma wrote:
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>  tools/virsh-completer-volume.c | 47 ++++++++++++++++++++++++++++++++++
>  tools/virsh-completer-volume.h |  5 ++++
>  2 files changed, 52 insertions(+)
> 
> diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c
> index 301ee982a5..a29c5eca41 100644
> --- a/tools/virsh-completer-volume.c
> +++ b/tools/virsh-completer-volume.c
> @@ -69,3 +69,50 @@ virshStorageVolNameCompleter(vshControl *ctl,
>      g_free(vols);
>      return ret;
>  }
> +
> +char **
> +virshStorageVolKeyCompleter(vshControl *ctl,
> +                            const vshCmd *cmd G_GNUC_UNUSED,
> +                            unsigned int flags)
> +{
> +    virshControl *priv = ctl->privData;
> +    struct virshStoragePoolList *list = NULL;
> +    virStorageVolPtr *vols = NULL;
> +    int rc;
> +    int nvols = 0;
> +    size_t i = 0, j = 0;
> +    char **ret = NULL;
> +    g_auto(GStrv) tmp = NULL;
> +
> +    virCheckFlags(0, NULL);
> +
> +    if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
> +        return NULL;
> +
> +    if (!(list = virshStoragePoolListCollect(ctl,
> +                    VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE)))

This is not aligned. One way to resolve this is to break this compound
statement into two:

  list = virshBLAH();
  if (!list)
    goto cleanup;

> +        goto cleanup;
> +

Michal




More information about the libvir-list mailing list