mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-03 05:17:54 +03:00
virsh: Add logical CPU IDs completion for nodecpustats command
Signed-off-by: Lin Ma <lma@suse.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a9327362cd
commit
4583a49ccf
@ -136,3 +136,34 @@ virshCellnoCompleter(vshControl *ctl,
|
|||||||
|
|
||||||
return g_steal_pointer(&tmp);
|
return g_steal_pointer(&tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char **
|
||||||
|
virshNodeCpuCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd G_GNUC_UNUSED,
|
||||||
|
unsigned int flags)
|
||||||
|
{
|
||||||
|
virshControlPtr priv = ctl->privData;
|
||||||
|
VIR_AUTOSTRINGLIST tmp = NULL;
|
||||||
|
size_t i;
|
||||||
|
int cpunum;
|
||||||
|
size_t offset = 0;
|
||||||
|
unsigned int online;
|
||||||
|
g_autofree unsigned char *cpumap = NULL;
|
||||||
|
|
||||||
|
virCheckFlags(0, NULL);
|
||||||
|
|
||||||
|
if ((cpunum = virNodeGetCPUMap(priv->conn, &cpumap, &online, 0)) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
tmp = g_new0(char *, online + 1);
|
||||||
|
|
||||||
|
for (i = 0; i < cpunum; i++) {
|
||||||
|
if (VIR_CPU_USED(cpumap, i) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
tmp[offset++] = g_strdup_printf("%zu", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return g_steal_pointer(&tmp);
|
||||||
|
}
|
||||||
|
@ -29,3 +29,7 @@ char ** virshAllocpagesPagesizeCompleter(vshControl *ctl,
|
|||||||
char ** virshCellnoCompleter(vshControl *ctl,
|
char ** virshCellnoCompleter(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
char ** virshNodeCpuCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd,
|
||||||
|
unsigned int flags);
|
||||||
|
@ -751,6 +751,7 @@ static const vshCmdInfo info_nodecpustats[] = {
|
|||||||
static const vshCmdOptDef opts_node_cpustats[] = {
|
static const vshCmdOptDef opts_node_cpustats[] = {
|
||||||
{.name = "cpu",
|
{.name = "cpu",
|
||||||
.type = VSH_OT_INT,
|
.type = VSH_OT_INT,
|
||||||
|
.completer = virshNodeCpuCompleter,
|
||||||
.help = N_("prints specified cpu statistics only.")
|
.help = N_("prints specified cpu statistics only.")
|
||||||
},
|
},
|
||||||
{.name = "percent",
|
{.name = "percent",
|
||||||
|
Loading…
Reference in New Issue
Block a user