mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-02 23:23:51 +00:00
virsh: Add logical CPU list completion for --cpulist argument
Currently this patch works for the commands emulatorpin, iothreadpin and vcpupin. Signed-off-by: Lin Ma <lma@suse.de> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
b3198b95d6
commit
a9aac97fdb
@ -564,3 +564,34 @@ virshDomainVcpulistCompleter(vshControl *ctl,
|
||||
virshDomainFree(dom);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
char **
|
||||
virshDomainCpulistCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags)
|
||||
{
|
||||
virshControlPtr priv = ctl->privData;
|
||||
size_t i;
|
||||
int cpunum;
|
||||
g_autofree unsigned char *cpumap = NULL;
|
||||
unsigned int online;
|
||||
VIR_AUTOSTRINGLIST cpulist = NULL;
|
||||
const char *cpuid = NULL;
|
||||
|
||||
virCheckFlags(0, NULL);
|
||||
|
||||
if (vshCommandOptStringQuiet(ctl, cmd, "cpulist", &cpuid) < 0)
|
||||
return NULL;
|
||||
|
||||
if ((cpunum = virNodeGetCPUMap(priv->conn, &cpumap, &online, 0)) < 0)
|
||||
return NULL;
|
||||
|
||||
if (VIR_ALLOC_N(cpulist, cpunum + 1) < 0)
|
||||
return NULL;
|
||||
|
||||
for (i = 0; i < cpunum; i++)
|
||||
cpulist[i] = g_strdup_printf("%zu", i);
|
||||
|
||||
return virshCommaStringListComplete(cpuid, (const char **)cpulist);
|
||||
}
|
||||
|
@ -86,3 +86,7 @@ char ** virshDomainVcpuCompleter(vshControl *ctl,
|
||||
char ** virshDomainVcpulistCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
||||
char ** virshDomainCpulistCompleter(vshControl *ctl,
|
||||
const vshCmd *cmd,
|
||||
unsigned int flags);
|
||||
|
@ -7008,6 +7008,7 @@ static const vshCmdOptDef opts_vcpupin[] = {
|
||||
{.name = "cpulist",
|
||||
.type = VSH_OT_STRING,
|
||||
.flags = VSH_OFLAG_EMPTY_OK,
|
||||
.completer = virshDomainCpulistCompleter,
|
||||
.help = N_("host cpu number(s) to set, or omit option to query")
|
||||
},
|
||||
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
|
||||
@ -7235,6 +7236,7 @@ static const vshCmdOptDef opts_emulatorpin[] = {
|
||||
{.name = "cpulist",
|
||||
.type = VSH_OT_STRING,
|
||||
.flags = VSH_OFLAG_EMPTY_OK,
|
||||
.completer = virshDomainCpulistCompleter,
|
||||
.help = N_("host cpu number(s) to set, or omit option to query")
|
||||
},
|
||||
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
|
||||
@ -7757,6 +7759,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
|
||||
{.name = "cpulist",
|
||||
.type = VSH_OT_DATA,
|
||||
.flags = VSH_OFLAG_REQ,
|
||||
.completer = virshDomainCpulistCompleter,
|
||||
.help = N_("host cpu number(s) to set")
|
||||
},
|
||||
VIRSH_COMMON_OPT_DOMAIN_CONFIG,
|
||||
|
Loading…
x
Reference in New Issue
Block a user