From 5b436359a825713975b1b39e597a02910cf57f90 Mon Sep 17 00:00:00 2001 From: John Ferlan Date: Sat, 9 Jan 2016 08:36:31 -0500 Subject: [PATCH] virsh: Create macros for common "vol" options 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 --- 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 a1bf19a984..661c876042 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -54,6 +54,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, @@ -425,11 +432,7 @@ static const vshCmdInfo info_vol_create_from[] = { static const vshCmdOptDef opts_vol_create_from[] = { VIRSH_COMMON_OPT_POOL_FULL, VIRSH_COMMON_OPT_FILE(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") @@ -540,11 +543,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, @@ -640,11 +639,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, VIRSH_COMMON_OPT_FILE(N_("file")), VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name = "offset", @@ -747,11 +742,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, VIRSH_COMMON_OPT_FILE(N_("file")), VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name = "offset", @@ -853,11 +844,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_POOL_OPTIONAL, {.name = "delete-snapshots", .type = VSH_OT_BOOL, @@ -907,11 +894,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_POOL_OPTIONAL, {.name = "algorithm", .type = VSH_OT_STRING, @@ -997,11 +980,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_POOL_OPTIONAL, {.name = NULL} }; @@ -1052,11 +1031,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, @@ -1153,11 +1128,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_POOL_OPTIONAL, {.name = NULL} }; -- GitLab