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

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 "virutil.h"
#include "virsh-host.h" #include "virsh-host.h"
#include "conf/domain_conf.h" #include "conf/domain_conf.h"
#include "virarch.h"
static char * static char *
virshPagesizeNodeToString(xmlNodePtr node) virshPagesizeNodeToString(xmlNodePtr node)
@ -193,3 +194,15 @@ virshDomainVirtTypeCompleter(vshControl *ctl G_GNUC_UNUSED,
return virshEnumComplete(VIR_DOMAIN_VIRT_LAST, return virshEnumComplete(VIR_DOMAIN_VIRT_LAST,
virDomainVirtTypeToString); 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, virshDomainVirtTypeCompleter(vshControl *ctl,
const vshCmd *cmd, const vshCmd *cmd,
unsigned int flags); 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", {.name = "arch",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.completer = virshArchCompleter,
.help = N_("domain architecture (/domain/os/type/@arch)"), .help = N_("domain architecture (/domain/os/type/@arch)"),
}, },
{.name = "machine", {.name = "machine",
@ -1312,6 +1313,7 @@ static const vshCmdInfo info_cpu_models[] = {
static const vshCmdOptDef opts_cpu_models[] = { static const vshCmdOptDef opts_cpu_models[] = {
{.name = "arch", {.name = "arch",
.type = VSH_OT_DATA, .type = VSH_OT_DATA,
.completer = virshArchCompleter,
.flags = VSH_OFLAG_REQ, .flags = VSH_OFLAG_REQ,
.help = N_("architecture") .help = N_("architecture")
}, },
@ -1588,6 +1590,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_compare[] = {
}, },
{.name = "arch", {.name = "arch",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.completer = virshArchCompleter,
.help = N_("CPU architecture (/domain/os/type/@arch)"), .help = N_("CPU architecture (/domain/os/type/@arch)"),
}, },
{.name = "machine", {.name = "machine",
@ -1698,6 +1701,7 @@ static const vshCmdOptDef opts_hypervisor_cpu_baseline[] = {
}, },
{.name = "arch", {.name = "arch",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.completer = virshArchCompleter,
.help = N_("CPU architecture (/domain/os/type/@arch)"), .help = N_("CPU architecture (/domain/os/type/@arch)"),
}, },
{.name = "machine", {.name = "machine",