Re: [PATCH v2 6/9] virsh: Add vshRebootShutdownModeCompleter

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

 



On 20.08.2013 22:02, Tomas Meszaros wrote:
> vshRebootShutdownModeCompleter returns available modes
> for reboot/shutdown commands.
> ---
>  tools/virsh.c | 28 ++++++++++++++++++++++++++++
>  tools/virsh.h |  1 +
>  2 files changed, 29 insertions(+)
> 

Again, you should add .completer = vshRebootShutdownModeCompleter in
this patch.

> diff --git a/tools/virsh.c b/tools/virsh.c
> index 85d74ad..965b141 100644
> --- a/tools/virsh.c
> +++ b/tools/virsh.c
> @@ -2578,6 +2578,34 @@ error:
>      return NULL;
>  }
>  
> +char **
> +vshRebootShutdownModeCompleter(unsigned int unused_flags ATTRIBUTE_UNUSED)
> +{
> +    const char *modes[] = {"acpi", "agent", "initctl", "signal"};
> +    const unsigned int modes_size = ARRAY_CARDINALITY(modes);
> +    char **names = NULL;
> +    size_t i;
> +
> +    names = vshMalloc(NULL, sizeof(char *) * (modes_size + 1));
> +
> +    if (!names)
> +        return NULL;

Again useless if.

> +
> +    for (i = 0; i < modes_size; i++) {
> +        if (VIR_STRDUP(names[i], modes[i]) < 0)
> +            goto cleanup;
> +    }
> +
> +    names[i] = NULL;
> +    return names;
> +
> +cleanup:
> +    for (i = 0; names[i]; i++)
> +        VIR_FREE(names[i]);
> +    VIR_FREE(names);
> +    return NULL;
> +}
> +
>  /* -----------------
>   * Readline stuff
>   * -----------------
> diff --git a/tools/virsh.h b/tools/virsh.h
> index 6767e65..61510b0 100644
> --- a/tools/virsh.h
> +++ b/tools/virsh.h
> @@ -257,6 +257,7 @@ struct _vshCmdGrp {
>  
>  char **vshDomainCompleter(unsigned int flags);
>  char **vshSuspendTargetCompleter(unsigned int unused_flags);
> +char **vshRebootShutdownModeCompleter(unsigned int unused_flags);
>  
>  void vshError(vshControl *ctl, const char *format, ...)
>      ATTRIBUTE_FMT_PRINTF(2, 3);
> 

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]