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

virsh: Add iothread IDs completion to iothread* commands

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:
Lin Ma 2020-09-11 15:13:10 +08:00 committed by Michal Privoznik
parent 889bdba38d
commit ab4ef5de67
3 changed files with 45 additions and 0 deletions

View File

@ -439,3 +439,40 @@ virshDomainPerfDisableCompleter(vshControl *ctl,
return virshCommaStringListComplete(event, (const char **)events);
}
char **
virshDomainIOThreadIdCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags)
{
virDomainPtr dom = NULL;
size_t niothreads = 0;
g_autofree virDomainIOThreadInfoPtr *info = NULL;
size_t i;
int rc;
char **ret = NULL;
VIR_AUTOSTRINGLIST tmp = NULL;
virCheckFlags(0, NULL);
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
return NULL;
if ((rc = virDomainGetIOThreadInfo(dom, &info, flags)) < 0)
goto cleanup;
niothreads = rc;
if (VIR_ALLOC_N(tmp, niothreads + 1) < 0)
goto cleanup;
for (i = 0; i < niothreads; i++)
tmp[i] = g_strdup_printf("%u", info[i]->iothread_id);
ret = g_steal_pointer(&tmp);
cleanup:
virshDomainFree(dom);
return ret;
}

View File

@ -74,3 +74,7 @@ char ** virshDomainPerfDisableCompleter(vshControl *ctl,
char ** virshDomainUUIDCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char ** virshDomainIOThreadIdCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);

View File

@ -243,6 +243,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
},
{.name = "iothread",
.type = VSH_OT_STRING,
.completer = virshDomainIOThreadIdCompleter,
.help = N_("IOThread to be used by supported device")
},
{.name = "cache",
@ -7748,6 +7749,7 @@ static const vshCmdOptDef opts_iothreadpin[] = {
{.name = "iothread",
.type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ,
.completer = virshDomainIOThreadIdCompleter,
.help = N_("IOThread ID number")
},
{.name = "cpulist",
@ -7896,6 +7898,7 @@ static const vshCmdOptDef opts_iothreadset[] = {
{.name = "id",
.type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ,
.completer = virshDomainIOThreadIdCompleter,
.help = N_("iothread id of existing IOThread")
},
{.name = "poll-max-ns",
@ -7999,6 +8002,7 @@ static const vshCmdOptDef opts_iothreaddel[] = {
{.name = "id",
.type = VSH_OT_INT,
.flags = VSH_OFLAG_REQ,
.completer = virshDomainIOThreadIdCompleter,
.help = N_("iothread_id for the IOThread to delete")
},
VIRSH_COMMON_OPT_DOMAIN_CONFIG,