virsh: Add lifecycle type completion to set-lifecycle-action 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:
Lin Ma 2020-11-10 17:51:03 +08:00 committed by Michal Privoznik
parent 96d01ce969
commit bb331d90b8
3 changed files with 26 additions and 0 deletions

View File

@ -736,3 +736,24 @@ virshDomainSignalCompleter(vshControl *ctl G_GNUC_UNUSED,
return g_steal_pointer(&tmp);
}
char **
virshDomainLifecycleCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
VIR_AUTOSTRINGLIST tmp = NULL;
size_t i = 0;
virCheckFlags(0, NULL);
tmp = g_new0(char *, VIR_DOMAIN_LIFECYCLE_LAST + 1);
for (i = 0; i < VIR_DOMAIN_LIFECYCLE_LAST; i++) {
const char *name = virDomainLifecycleTypeToString(i);
tmp[i] = g_strdup(name);
}
return g_steal_pointer(&tmp);
}

View File

@ -102,3 +102,7 @@ char ** virshDomainConsoleCompleter(vshControl *ctl,
char ** virshDomainSignalCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char ** virshDomainLifecycleCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);

View File

@ -5717,6 +5717,7 @@ static const vshCmdOptDef opts_setLifecycleAction[] = {
{.name = "type",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.completer = virshDomainLifecycleCompleter,
.help = N_("lifecycle type to modify")
},
{.name = "action",