virsh: Provide completer for CPU architectures

Related: https://gitlab.com/libvirt/libvirt/-/issues/9
Signed-off-by: Amneesh Singh <natto@weirdnatto.in>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Amneesh Singh 2022-04-02 16:01:46 +05:30 committed by Michal Privoznik
parent 11ad758910
commit 4f0480a11c
3 changed files with 22 additions and 0 deletions

View File

@ -28,6 +28,7 @@
#include "virutil.h"
#include "virsh-host.h"
#include "conf/domain_conf.h"
#include "virarch.h"
static char *
virshPagesizeNodeToString(xmlNodePtr node)
@ -193,3 +194,15 @@ virshDomainVirtTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
return virshEnumComplete(VIR_DOMAIN_VIRT_LAST,
virDomainVirtTypeToString);
}
char **
virshArchCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
virCheckFlags(0, NULL);
return virshEnumComplete(VIR_ARCH_LAST,
(const char *(*)(int))virArchToString);
}

View File

@ -46,3 +46,8 @@ char **
virshDomainVirtTypeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char **
virshArchCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);

View File

@ -86,6 +86,7 @@ static const vshCmdOptDef opts_domcapabilities[] = {
},
{.name = "arch",
.type = VSH_OT_STRING,
.completer = virshArchCompleter,
.help = N_("domain architecture (/domain/os/type/@arch)"),
},
{.name = "machine",
@ -1312,6 +1313,7 @@ static const vshCmdInfo info_cpu_models[] = {
static const vshCmdOptDef opts_cpu_models[] = {
{.name = "arch",
.type = VSH_OT_DATA,
.completer = virshArchCompleter,
.flags = VSH_OFLAG_REQ,
.help = N_("architecture")
},
@ -1588,6 +1590,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_compare[] = {
},
{.name = "arch",
.type = VSH_OT_STRING,
.completer = virshArchCompleter,
.help = N_("CPU architecture (/domain/os/type/@arch)"),
},
{.name = "machine",
@ -1698,6 +1701,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_baseline[] = {
},
{.name = "arch",
.type = VSH_OT_STRING,
.completer = virshArchCompleter,
.help = N_("CPU architecture (/domain/os/type/@arch)"),
},
{.name = "machine",