On 3/10/22 16:22, Haonan Wang wrote: > Related issue: https://gitlab.com/libvirt/libvirt/-/issues/9 > > Signed-off-by: Haonan Wang <hnwanga1@xxxxxxxxx> > --- > tools/virsh-completer-volume.c | 19 +++++++++++++++++++ > tools/virsh-completer-volume.h | 6 ++++++ > tools/virsh-volume.c | 3 +-- > tools/virsh-volume.h | 3 +++ > 4 files changed, 29 insertions(+), 2 deletions(-) > > 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..b6fa9555ad 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", > @@ -950,7 +950,6 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd) > } > > > -VIR_ENUM_DECL(virshStorageVol); I don't think this particular change is necessary. Nor virshStorageVolTypeFromString() or virshStorageVolTypeToString() is used anywhere in this patch. It's only virshStorageVolWipeAlgorithm enum declaration that needs moving. > VIR_ENUM_IMPL(virshStorageVol, > VIR_STORAGE_VOL_LAST, > N_("file"), > diff --git a/tools/virsh-volume.h b/tools/virsh-volume.h > index 15cab0fd8c..32e5394f5c 100644 > --- a/tools/virsh-volume.h > +++ b/tools/virsh-volume.h > @@ -33,3 +33,6 @@ virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd, > VIRSH_BYUUID | VIRSH_BYNAME) > > extern const vshCmdDef storageVolCmds[]; > + > +VIR_ENUM_DECL(virshStorageVolWipeAlgorithm); > +VIR_ENUM_DECL(virshStorageVol); Reviewed-by: Michal Privoznik <mprivozn@xxxxxxxxxx> and pushed. Congratulations on your first libvirt contribution! Michal