diff --git a/tools/virsh-completer-volume.c b/tools/virsh-completer-volume.c index ac3c472177..bed45fa1ca 100644 --- a/tools/virsh-completer-volume.c +++ b/tools/virsh-completer-volume.c @@ -26,6 +26,7 @@ #include "virsh-pool.h" #include "virsh.h" #include "virstring.h" +#include "virsh-volume.h" char ** virshStorageVolNameCompleter(vshControl *ctl, @@ -116,3 +117,21 @@ virshStorageVolKeyCompleter(vshControl *ctl, virshStoragePoolListFree(list); return ret; } + +char ** +virshStorageVolWipeAlgorithmCompleter(vshControl *ctl G_GNUC_UNUSED, + const vshCmd *cmd G_GNUC_UNUSED, + unsigned int flags) +{ + char **ret = NULL; + size_t i; + + virCheckFlags(0, NULL); + + ret = g_new0(char *, VIR_STORAGE_VOL_WIPE_ALG_LAST + 1); + + for (i = 0; i < VIR_STORAGE_VOL_WIPE_ALG_LAST; i++) + ret[i] = g_strdup(virshStorageVolWipeAlgorithmTypeToString(i)); + + return ret; +} diff --git a/tools/virsh-completer-volume.h b/tools/virsh-completer-volume.h index dc6eeb4b3c..17e50f450d 100644 --- a/tools/virsh-completer-volume.h +++ b/tools/virsh-completer-volume.h @@ -33,3 +33,9 @@ char ** virshStorageVolKeyCompleter(vshControl *ctl, const vshCmd *cmd, unsigned int flags); + + +char ** +virshStorageVolWipeAlgorithmCompleter(vshControl *ctl, + const vshCmd *cmd, + unsigned int flags); diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index d005602fe8..503acda874 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -902,12 +902,12 @@ static const vshCmdOptDef opts_vol_wipe[] = { VIRSH_COMMON_OPT_POOL_OPTIONAL, {.name = "algorithm", .type = VSH_OT_STRING, + .completer = virshStorageVolWipeAlgorithmCompleter, .help = N_("perform selected wiping algorithm") }, {.name = NULL} }; -VIR_ENUM_DECL(virshStorageVolWipeAlgorithm); VIR_ENUM_IMPL(virshStorageVolWipeAlgorithm, VIR_STORAGE_VOL_WIPE_ALG_LAST, "zero", "nnsa", "dod", "bsi", "gutmann", "schneier", diff --git a/tools/virsh-volume.h b/tools/virsh-volume.h index 15cab0fd8c..f8b076d5ca 100644 --- a/tools/virsh-volume.h +++ b/tools/virsh-volume.h @@ -33,3 +33,5 @@ virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, VIRSH_BYUUID | VIRSH_BYNAME) extern const vshCmdDef storageVolCmds[]; + +VIR_ENUM_DECL(virshStorageVolWipeAlgorithm);