[libvirt] [PATCH v2 05/13] virsh: Add interface mac completion to iface-name command
Michal Privoznik
mprivozn at redhat.com
Tue Nov 10 17:37:10 UTC 2020
On 11/10/20 10:50 AM, Lin Ma wrote:
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
> tools/virsh-completer-interface.c | 9 +++++++++
> tools/virsh-completer-interface.h | 4 ++++
> tools/virsh-interface.c | 1 +
> 3 files changed, 14 insertions(+)
>
> diff --git a/tools/virsh-completer-interface.c b/tools/virsh-completer-interface.c
> index 407021485f..dea8d645cd 100644
> --- a/tools/virsh-completer-interface.c
> +++ b/tools/virsh-completer-interface.c
> @@ -69,3 +69,12 @@ virshInterfaceNameCompleter(vshControl *ctl,
> {
> return virshInterfaceStringHelper(ctl, cmd, flags, virInterfaceGetName);
> }
> +
> +char **
> +virshInterfaceMacCompleter(vshControl *ctl,
> + const vshCmd *cmd,
> + unsigned int flags)
> +{
> + return virshInterfaceStringHelper(ctl, cmd, flags,
> + virInterfaceGetMACString);
> +}
> diff --git a/tools/virsh-completer-interface.h b/tools/virsh-completer-interface.h
> index 32da01e766..b48ded6a12 100644
> --- a/tools/virsh-completer-interface.h
> +++ b/tools/virsh-completer-interface.h
> @@ -28,3 +28,7 @@ typedef const char *
> char ** virshInterfaceNameCompleter(vshControl *ctl,
> const vshCmd *cmd,
> unsigned int flags);
> +
> +char ** virshInterfaceMacCompleter(vshControl *ctl,
> + const vshCmd *cmd,
> + unsigned int flags);
> diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c
> index 8cdbc6e85f..ae2b52bfc3 100644
> --- a/tools/virsh-interface.c
> +++ b/tools/virsh-interface.c
> @@ -404,6 +404,7 @@ static const vshCmdOptDef opts_interface_name[] = {
> {.name = "interface",
> .type = VSH_OT_DATA,
> .flags = VSH_OFLAG_REQ,
> + .completer = virshInterfaceMacCompleter,
> .help = N_("interface mac")
> },
> {.name = NULL}
>
Beautiful.
Michal
More information about the libvir-list
mailing list