virsh-volume: Add macros VIRSH_COMMON_OPT_VOL_*

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Lin Ma 2021-06-16 16:02:52 +08:00 committed by Michal Privoznik
parent 254504adc3
commit 64818c9ec1

View File

@ -54,14 +54,28 @@
.completer_flags = VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE, \
}
#define VIRSH_COMMON_OPT_VOLUME_VOL \
#define VIRSH_COMMON_OPT_VOL_NAME(_helpstr) \
{.name = "vol", \
.type = VSH_OT_DATA, \
.flags = VSH_OFLAG_REQ, \
.help = N_("vol name, key or path"), \
.help = _helpstr, \
.completer = virshStorageVolNameCompleter, \
}
#define VIRSH_COMMON_OPT_VOL_KEY(_helpstr) \
{.name = "vol", \
.type = VSH_OT_DATA, \
.flags = VSH_OFLAG_REQ, \
.help = _helpstr, \
.completer = virshStorageVolKeyCompleter, \
}
#define VIRSH_COMMON_OPT_VOL_FULL \
VIRSH_COMMON_OPT_VOL_NAME(N_("vol name, key or path"))
#define VIRSH_COMMON_OPT_VOL_BY_KEY \
VIRSH_COMMON_OPT_VOL_KEY(N_("volume key or path"))
virStorageVolPtr
virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
const char *optname,
@ -440,7 +454,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")),
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
{.name = "inputpool",
.type = VSH_OT_STRING,
.help = N_("pool name or uuid of the input volume's pool")
@ -550,7 +564,7 @@ static const vshCmdInfo info_vol_clone[] = {
};
static const vshCmdOptDef opts_vol_clone[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
{.name = "newname",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@ -646,7 +660,7 @@ static const vshCmdInfo info_vol_upload[] = {
};
static const vshCmdOptDef opts_vol_upload[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
VIRSH_COMMON_OPT_FILE(N_("file")),
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = "offset",
@ -768,7 +782,7 @@ static const vshCmdInfo info_vol_download[] = {
};
static const vshCmdOptDef opts_vol_download[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
VIRSH_COMMON_OPT_FILE(N_("file")),
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = "offset",
@ -889,7 +903,7 @@ static const vshCmdInfo info_vol_delete[] = {
};
static const vshCmdOptDef opts_vol_delete[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = "delete-snapshots",
.type = VSH_OT_BOOL,
@ -939,7 +953,7 @@ static const vshCmdInfo info_vol_wipe[] = {
};
static const vshCmdOptDef opts_vol_wipe[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = "algorithm",
.type = VSH_OT_STRING,
@ -1027,7 +1041,7 @@ static const vshCmdInfo info_vol_info[] = {
};
static const vshCmdOptDef opts_vol_info[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = "bytes",
.type = VSH_OT_BOOL,
@ -1117,7 +1131,7 @@ static const vshCmdInfo info_vol_resize[] = {
};
static const vshCmdOptDef opts_vol_resize[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
{.name = "capacity",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
@ -1214,7 +1228,7 @@ static const vshCmdInfo info_vol_dumpxml[] = {
};
static const vshCmdOptDef opts_vol_dumpxml[] = {
VIRSH_COMMON_OPT_VOLUME_VOL,
VIRSH_COMMON_OPT_VOL_FULL,
VIRSH_COMMON_OPT_POOL_OPTIONAL,
{.name = NULL}
};