]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Provide completer for vol-wipe algorithms
authorHaonan Wang <hnwanga1@gmail.com>
Thu, 10 Mar 2022 15:22:24 +0000 (23:22 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Fri, 11 Mar 2022 08:10:24 +0000 (09:10 +0100)
Related issue: https://gitlab.com/libvirt/libvirt/-/issues/9

Signed-off-by: Haonan Wang <hnwanga1@gmail.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer-volume.c
tools/virsh-completer-volume.h
tools/virsh-volume.c
tools/virsh-volume.h

index ac3c4721775c5acd84e8a23f04daf8db2bfa12ca..bed45fa1caec2430b89373b5279c10f52f1bb7fe 100644 (file)
@@ -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;
+}
index dc6eeb4b3c31132f1453dd8649d8a5ffebce0eb8..17e50f450dd1649e00a56e35405b2e46c3cf419e 100644 (file)
@@ -33,3 +33,9 @@ char **
 virshStorageVolKeyCompleter(vshControl *ctl,
                             const vshCmd *cmd,
                             unsigned int flags);
+
+
+char **
+virshStorageVolWipeAlgorithmCompleter(vshControl *ctl,
+                                      const vshCmd *cmd,
+                                      unsigned int flags);
index d005602fe8fae489c73a3f6b483561b5775767e5..503acda8743de00e7a29dd5cb5885d6db1829e8b 100644 (file)
@@ -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",
index 15cab0fd8c611bbea1e8f9ec80cac833fbd77ff5..f8b076d5caf4f62953a0acd7b626518721948895 100644 (file)
@@ -33,3 +33,5 @@ virStorageVolPtr virshCommandOptVolBy(vshControl *ctl, const vshCmd *cmd,
                          VIRSH_BYUUID | VIRSH_BYNAME)
 
 extern const vshCmdDef storageVolCmds[];
+
+VIR_ENUM_DECL(virshStorageVolWipeAlgorithm);