1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

virsh-completer: Provide completer for numatune --mode

The completer is trivial, just iterate over
virDomainNumatuneMemMode enum and convert each integer into its
string comrade.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Michal Privoznik 2021-12-16 15:46:31 +01:00
parent d05a89b703
commit dfd1ffc544
3 changed files with 26 additions and 0 deletions

View File

@ -37,6 +37,7 @@
#include "virkeynametable_osx.h"
#include "virkeynametable_win32.h"
#include "conf/storage_conf.h"
#include "conf/numa_conf.h"
char **
virshDomainNameCompleter(vshControl *ctl,
@ -1130,3 +1131,22 @@ virshDomainStorageFileFormatCompleter(vshControl *ctl G_GNUC_UNUSED,
return ret;
}
char **
virshDomainNumatuneModeCompleter(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_DOMAIN_NUMATUNE_MEM_LAST + 1);
for (i = 0; i < VIR_DOMAIN_NUMATUNE_MEM_LAST; i++)
ret[i] = g_strdup(virDomainNumatuneMemModeTypeToString(i));
return ret;
}

View File

@ -181,3 +181,8 @@ char **
virshDomainBlockjobBaseTopCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshDomainNumatuneModeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);

View File

@ -9407,6 +9407,7 @@ static const vshCmdOptDef opts_numatune[] = {
VIRSH_COMMON_OPT_DOMAIN_FULL(0),
{.name = "mode",
.type = VSH_OT_STRING,
.completer = virshDomainNumatuneModeCompleter,
.help = N_("NUMA mode, one of strict, preferred and interleave \n"
"or a number from the virDomainNumatuneMemMode enum")
},