mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-22 03:12:22 +00:00
tools: Introduce virshNodedevCapabilityNameCompleter
This is a very simple completer for completing --cap argument of nodedev-list command. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
parent
9ef216ce2d
commit
3f9d0d97a7
@ -34,6 +34,7 @@
|
||||
#include "virmacaddr.h"
|
||||
#include "virstring.h"
|
||||
#include "virxml.h"
|
||||
#include "conf/node_device_conf.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -975,6 +976,32 @@ virshNodedevEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
|
||||
}
|
||||
|
||||
|
||||
char **
|
||||
virshNodedevCapabilityNameCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags)
|
||||
{
|
||||
VIR_AUTOSTRINGLIST tmp = NULL;
|
||||
const char *cap_str = NULL;
|
||||
size_t i = 0;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (vshCommandOptStringQuiet(ctl, cmd, "cap", &cap_str) < 0)
|
||||
return NULL;
|
||||
|
||||
if (VIR_ALLOC_N(tmp, VIR_NODE_DEV_CAP_LAST + 1) < 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < VIR_NODE_DEV_CAP_LAST; i++) {
|
||||
if (VIR_STRDUP(tmp[i], virNodeDevCapTypeToString(i)) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return virshCommaStringListComplete(cap_str, (const char **)tmp);
|
||||
}
|
||||
|
||||
|
||||
char **
|
||||
virshCellnoCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd ATTRIBUTE_UNUSED,
|
||||
|
@ -106,6 +106,10 @@ char ** virshNodedevEventNameCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
||||
char ** virshNodedevCapabilityNameCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
||||
char ** virshDomainDeviceAliasCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
@ -375,6 +375,7 @@ static const vshCmdOptDef opts_node_list_devices[] = {
|
||||
},
|
||||
{.name = "cap",
|
||||
.type = VSH_OT_STRING,
|
||||
.completer = virshNodedevCapabilityNameCompleter,
|
||||
.help = N_("capability names, separated by comma")
|
||||
},
|
||||
{.name = NULL}
|
||||
|
Loading…
x
Reference in New Issue
Block a user