Rather than continually cut-n-paste the strings into each command, create common macros to be used generically. Replace the more commonly used "vol" option with a macro. This also adjusts 2 commands that didn't have the correct helpstr - 'vol-create-from' and 'vol-clone'. Both are described in the man page as taking vol, path, or key and the code uses the virshCommandOptVol instead of virshCommandOptVolBy. Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx> --- tools/virsh-volume.c | 61 ++++++++++++++-------------------------------------- 1 file changed, 16 insertions(+), 45 deletions(-) diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 5d9cade..58bfe03 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -55,6 +55,13 @@ .help = N_("pool name or uuid") \ } \ +#define VIRSH_COMMON_OPT_VOLUME_VOL \ + {.name = "vol", \ + .type = VSH_OT_DATA, \ + .flags = VSH_OFLAG_REQ, \ + .help = N_("vol name, key or path") \ + } \ + virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, const char *optname, @@ -434,11 +441,7 @@ static const vshCmdOptDef opts_vol_create_from[] = { .flags = VSH_OFLAG_REQ, .help = N_("file containing an XML vol description") }, - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("input vol name or key") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, {.name = "inputpool", .type = VSH_OT_STRING, .help = N_("pool name or uuid of the input volume's pool") @@ -549,11 +552,7 @@ static const vshCmdInfo info_vol_clone[] = { }; static const vshCmdOptDef opts_vol_clone[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("orig vol name or key") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, {.name = "newname", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -649,11 +648,7 @@ static const vshCmdInfo info_vol_upload[] = { }; static const vshCmdOptDef opts_vol_upload[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -760,11 +755,7 @@ static const vshCmdInfo info_vol_download[] = { }; static const vshCmdOptDef opts_vol_download[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, {.name = "file", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -870,11 +861,7 @@ static const vshCmdInfo info_vol_delete[] = { }; static const vshCmdOptDef opts_vol_delete[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, VIRSH_COMMON_OPT_VOLUME_POOL_STRING, {.name = "delete-snapshots", .type = VSH_OT_BOOL, @@ -924,11 +911,7 @@ static const vshCmdInfo info_vol_wipe[] = { }; static const vshCmdOptDef opts_vol_wipe[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, VIRSH_COMMON_OPT_VOLUME_POOL_STRING, {.name = "algorithm", .type = VSH_OT_STRING, @@ -1014,11 +997,7 @@ static const vshCmdInfo info_vol_info[] = { }; static const vshCmdOptDef opts_vol_info[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, VIRSH_COMMON_OPT_VOLUME_POOL_STRING, {.name = NULL} }; @@ -1069,11 +1048,7 @@ static const vshCmdInfo info_vol_resize[] = { }; static const vshCmdOptDef opts_vol_resize[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, {.name = "capacity", .type = VSH_OT_DATA, .flags = VSH_OFLAG_REQ, @@ -1170,11 +1145,7 @@ static const vshCmdInfo info_vol_dumpxml[] = { }; static const vshCmdOptDef opts_vol_dumpxml[] = { - {.name = "vol", - .type = VSH_OT_DATA, - .flags = VSH_OFLAG_REQ, - .help = N_("vol name, key or path") - }, + VIRSH_COMMON_OPT_VOLUME_VOL, VIRSH_COMMON_OPT_VOLUME_POOL_STRING, {.name = NULL} }; -- 2.5.0 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list