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(a)redhat.com>
---
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 cb350ee..2ddab80 100644
--- a/tools/virsh-volume.c
+++ b/tools/virsh-volume.c
@@ -55,6 +55,13 @@
.help = N_("pool name or uuid") \
} \
+#define VIRSH_VOLUME_VOL_OPT_COMMON \
+ {.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_VOLUME_VOL_OPT_COMMON,
{.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_VOLUME_VOL_OPT_COMMON,
{.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_VOLUME_VOL_OPT_COMMON,
{.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_VOLUME_VOL_OPT_COMMON,
{.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_VOLUME_POOL_STRING_OPT_COMMON,
VIRSH_VOLUME_POOL_STRING_OPT_COMMON,
{.name = NULL}
};
@@ -914,11 +901,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_VOLUME_POOL_STRING_OPT_COMMON,
VIRSH_VOLUME_POOL_STRING_OPT_COMMON,
{.name = "algorithm",
.type = VSH_OT_STRING,
@@ -1004,11 +987,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_VOLUME_POOL_STRING_OPT_COMMON,
VIRSH_VOLUME_POOL_STRING_OPT_COMMON,
{.name = NULL}
};
@@ -1059,11 +1038,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_VOLUME_VOL_OPT_COMMON,
{.name = "capacity",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@@ -1160,11 +1135,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_VOLUME_POOL_STRING_OPT_COMMON,
VIRSH_VOLUME_POOL_STRING_OPT_COMMON,
{.name = NULL}
};
--
2.5.0