]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add format completion to blockcopy command
authorLin Ma <lma@suse.com>
Tue, 15 Jun 2021 00:38:26 +0000 (08:38 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Jun 2021 08:28:02 +0000 (10:28 +0200)
Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer-domain.c
tools/virsh-completer-domain.h
tools/virsh-domain.c

index 256ac0b59320261c702375808f36cf29de16a40f..14e4d95ec30ad057a394d47ba3791477daa44e8d 100644 (file)
@@ -35,6 +35,7 @@
 #include "virkeynametable_linux.h"
 #include "virkeynametable_osx.h"
 #include "virkeynametable_win32.h"
+#include "conf/storage_conf.h"
 
 char **
 virshDomainNameCompleter(vshControl *ctl,
@@ -976,3 +977,22 @@ virshDomainMigrateCompMethodsCompleter(vshControl *ctl,
 
     return virshCommaStringListComplete(method, methods);
 }
+
+
+char **
+virshDomainStorageFileFormatCompleter(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_FILE_LAST + 1);
+
+    for (i = 0; i < VIR_STORAGE_FILE_LAST; i++)
+        ret[i] = g_strdup(virStorageFileFormatTypeToString(i));
+
+    return ret;
+}
index 5d5609050444fe895cc406906a0b0f2c3f452bc3..45380906f97e84eac2e3aea1942693dae6377356 100644 (file)
@@ -132,3 +132,9 @@ char **
 virshDomainMigrateCompMethodsCompleter(vshControl *ctl,
                                        const vshCmd *cmd,
                                        unsigned int flags);
+
+
+char **
+virshDomainStorageFileFormatCompleter(vshControl *ctl,
+                                      const vshCmd *cmd,
+                                      unsigned int flags);
index 34a30c43c9c6239e9ec8b309d09b2bd908fbe16a..f2a5fb03a4370a346d65b7518dbc6db67d49b6ed 100644 (file)
@@ -2236,6 +2236,8 @@ static const vshCmdOptDef opts_blockcopy[] = {
     },
     {.name = "format",
      .type = VSH_OT_STRING,
+     .flags = VSH_OFLAG_NONE,
+     .completer = virshDomainStorageFileFormatCompleter,
      .help = N_("format of the destination file")
     },
     {.name = "granularity",