Re: [ [PATCH v3 4/8] virsh: Add event name completion to 'event' command

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

 



On 05/23/2018 08:32 AM, Lin Ma wrote:
> Signed-off-by: Lin Ma <lma@xxxxxxxx>
> ---
>  tools/virsh-completer.c | 31 +++++++++++++++++++++++++++++++
>  tools/virsh-completer.h |  3 +++
>  tools/virsh-domain.c    |  1 +
>  3 files changed, 35 insertions(+)
> 
> diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
> index b402fd22c3..c0c3c5571a 100644
> --- a/tools/virsh-completer.c
> +++ b/tools/virsh-completer.c
> @@ -23,6 +23,7 @@
>  #include <config.h>
>  
>  #include "virsh-completer.h"
> +#include "virsh-domain.h"
>  #include "virsh.h"
>  #include "virsh-pool.h"
>  #include "virsh-util.h"
> @@ -676,3 +677,33 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
>      virStringListFree(ret);
>      return NULL;
>  }
> +
> +
> +char **
> +virshEventNameCompleter(vshControl *ctl,
> +                        const vshCmd *cmd ATTRIBUTE_UNUSED,
> +                        unsigned int flags)
> +{
> +    virshControlPtr priv = ctl->privData;
> +    size_t i = 0;
> +    char **ret = NULL;
> +
> +    virCheckFlags(0, NULL);
> +
> +    if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
> +        return NULL;

There is no need for connection.

> +
> +    if (VIR_ALLOC_N(ret, VIR_DOMAIN_EVENT_ID_LAST + 1) < 0)
> +        goto error;
> +
> +    for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) {
> +        if (VIR_STRDUP(ret[i], vshEventCallbacks[i].name) < 0)
> +            goto error;
> +    }
> +
> +    return ret;
> +
> + error:
> +    virStringListFree(ret);
> +    return NULL;
> +}

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]

  Powered by Linux