[libvirt] [PATCH v3 05/14] virsh: Create macro for common "config" option

John Ferlan jferlan at redhat.com
Mon Jan 11 15:55:33 UTC 2016



On 01/11/2016 07:21 AM, Andrea Bolognani wrote:
> 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 = "config",' entries are replaced, just those that have the
>> common .help string of "affect next boot".
>>
>> Non replaced instances are unique to the command.
>>
>> Signed-off-by: John Ferlan <jferlan at redhat.com>
>> ---
>>  tools/virsh-domain.c | 116 +++++++++++++--------------------------------------
>>  1 file changed, 28 insertions(+), 88 deletions(-)
>>
>> diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
>> index 476ba58..ba6ba7f 100644
>> --- a/tools/virsh-domain.c
>> +++ b/tools/virsh-domain.c
>> @@ -69,6 +69,12 @@
>>       .help = N_("make live change persistent")         \
>>      }                                                  \
>>  
>> +#define VIRSH_COMMON_OPT_DOMAIN_CONFIG                 \
>> +    {.name = "config",                                 \
>> +    .type = VSH_OT_BOOL,                               \
>> +    .help = N_("affect next boot")                     \
>> +    }                                                  \
>> +
> 
> .type and .help are not aligned properly.
> 

Good catch.

> You also seem to have missed the 'dommemstat' command; however,
> since that command is defined in virsh-domain-monitor.c you'll
> have to move the definition of VIRSH_COMMON_OPT_DOMAIN_CONFIG
> to virsh.h to make it available there.
> 
OK - my search was done more on the count of repetitive options rather
than looking for repetitive options in other files, but I can make this
one more generic too.

> The config option for the 'schedinfo' and 'change-media'
> commands, while it has a slightly different help text, also
> serves AFAICT the same purpose and as such should IMHO use the
> macro you just defined as well.
> 

BTW: I could do something similar as done for the _FILE w/r/t _helpstr
for any ".type = VSH_OT_BOOL," options...  To avoid the multiple places
where I'd pass "N_("affect next boot"), I could change the macro to be:


#define VIRSH_COMMON_OPT_CONFIG(_helpstr)                 \
    {.name = "config",                                    \
     .type = VSH_OT_BOOL,                                 \
     .help = _helpstr ? _helpstr : N_("affect next boot") \
    }                                                     \

and callers be either (NULL) or whatever helpstring - thoughts??


John




More information about the libvir-list mailing list