Re: [PATCH v3 08/14] virsh: Create macro for common "file" option

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

 



On Sat, 2016-01-09 at 08:36 -0500, John Ferlan wrote:
> Rather than continually cut-n-paste the strings into each command,
> create a common macro to be used generically.  Note that not all
> '{.name = "file",' entries are replaced, just those that use
> VSH_OT_DATA and VSH_OFLAG_REQ.
> 
> Replacement of this option is a bit trickier, since the .helpstr
> changes from command to command. Also because if the N_() I18N
> for each, it's also not possible to just copy the string. So,
> replace the enter right side of the .helpstr = with the _helpstr
              -----                   -------- -
              ^ entire                ^ .help  ^ assignment (?)
> macro argument.
> 
> Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
> ---
>  tools/virsh-domain.c | 85 +++++++++++++---------------------------------------
>  1 file changed, 20 insertions(+), 65 deletions(-)
> 
> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
> index e3ed216..ce698c3 100644
> --- a/tools/virsh-domain.c
> +++ b/tools/virsh-domain.c
> @@ -87,6 +87,13 @@
>       .help = N_("affect current domain")               \
>      }                                                  \
>  
> +#define VIRSH_COMMON_OPT_DOMAIN_FILE(_helpstr)         \
> +    {.name = "file",                                   \
> +     .type = VSH_OT_DATA,                              \
> +     .flags = VSH_OFLAG_REQ,                           \
> +     .help = _helpstr                                  \
> +    }                                                  \
> +

I don't think this should be specific to domain commands. I'd
rather rename it to VIRSH_COMMON_OPT_FILE(), move it to virsh.h
and use it for

  iface-define
  net-create
  net-define
  nodedev-create
  nwfilter-define
  secret-define
  vol-create
  vol-create-from
  vol-upload
  vol-download

too. Even better, you could change

  #define VIRSH_COMMON_OPT_POOL_FILE \
      VIRSH_COMMON_OPT_FILE(N_("file containing an XML pool description"))

and add

  #define VIRSH_COMMON_OPT_VOLUME_FILE \
      VIRSH_COMMON_OPT_FILE(N_("file containing an XML vol description"))

to use in the vol-* commands listed above.

Cheers.

-- 
Andrea Bolognani
Software Engineer - Virtualization Team

--
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]