virsh: Add format completion to blockcopy command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Lin Ma 2021-06-15 08:38:26 +08:00 committed by Michal Privoznik
parent 8de9a54b9e
commit 8cdbca6213
3 changed files with 28 additions and 0 deletions

View 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;
}

View 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);

View 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",