virsh: Add event name completion to 'pool-event' command

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Lin Ma 2018-05-24 15:16:26 +02:00 committed by Michal Privoznik
parent 237fe904e9
commit cac6d413f9
3 changed files with 31 additions and 0 deletions

View File

@ -703,3 +703,29 @@ virshDomainEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
virStringListFree(ret);
return NULL;
}
char **
virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
const vshCmd *cmd ATTRIBUTE_UNUSED,
unsigned int flags)
{
size_t i = 0;
char **ret = NULL;
virCheckFlags(0, NULL);
if (VIR_ALLOC_N(ret, VIR_STORAGE_POOL_EVENT_ID_LAST) < 0)
goto error;
for (i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) {
if (VIR_STRDUP(ret[i], virshPoolEventCallbacks[i].name) < 0)
goto error;
}
return ret;
error:
virStringListFree(ret);
return NULL;
}

View File

@ -86,4 +86,8 @@ char ** virshDomainEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char ** virshPoolEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
#endif

View File

@ -2098,6 +2098,7 @@ static const vshCmdOptDef opts_pool_event[] = {
},
{.name = "event",
.type = VSH_OT_STRING,
.completer = virshPoolEventNameCompleter,
.help = N_("which event type to wait for")
},
{.name = "loop",