[libvirt] [PATCH 13/19] virsh-domain: Introduce 2 macros for domain options 'interface' and 'mac'

Michal Privoznik mprivozn at redhat.com
Mon Nov 2 19:40:48 UTC 2020


On 11/2/20 9:26 AM, Lin Ma wrote:
> The macro VIRSH_DOMAIN_OPT_INTERFACE for domain option '--interface',
> The macro VIRSH_DOMAIN_OPT_MAC for domain option '--mac'.
> 
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>   tools/virsh-domain.h | 18 ++++++++++++++++++
>   1 file changed, 18 insertions(+)
> 
> diff --git a/tools/virsh-domain.h b/tools/virsh-domain.h
> index 0d59c579d4..ac05f983f9 100644
> --- a/tools/virsh-domain.h
> +++ b/tools/virsh-domain.h
> @@ -39,3 +39,21 @@ typedef enum {
>   VIR_ENUM_DECL(virshDomainHostnameSource);
>   
>   extern const vshCmdDef domManagementCmds[];
> +
> +#define VIRSH_DOMAIN_OPT_INTERFACE(_helpstr, oflags, cflags) \
> +    {.name = "interface", \
> +     .type = VSH_OT_STRING, \
> +     .flags = oflags, \
> +     .help = _helpstr, \
> +     .completer = virshDomainInterfaceCompleter, \
> +     .completer_flags = cflags, \
> +    }
> +
> +#define VIRSH_DOMAIN_OPT_MAC(_helpstr, oflags) \
> +    {.name = "mac", \
> +     .type = VSH_OT_STRING, \
> +     .flags = oflags, \
> +     .help = _helpstr, \
> +     .completer = virshDomainInterfaceCompleter, \
> +     .completer_flags = VIRSH_DOMAIN_INTERFACE_COMPLETER_MAC, \
> +    }
> 

So, if we had two distinct completers, as I suggested, then this would 
look a bit different and both macros could accept cflags. We could then 
print MAC addresses only of running/inactive/all interfaces, which could 
be helpful.

I'm stopping my review here. I think you get the gist of my review. 
Looking forward to v2.

Michal




More information about the libvir-list mailing list