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

Add lifecycle action 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:04 +08:00 committed by Michal Privoznik
parent bb331d90b8
commit d44a8203e7
3 changed files with 26 additions and 0 deletions

View File

@ -757,3 +757,24 @@ virshDomainLifecycleCompleter(vshControl *ctl G_GNUC_UNUSED,
return g_steal_pointer(&tmp); return g_steal_pointer(&tmp);
} }
char **
virshDomainLifecycleActionCompleter(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_ACTION_LAST + 1);
for (i = 0; i < VIR_DOMAIN_LIFECYCLE_ACTION_LAST; i++) {
const char *action = virDomainLifecycleActionTypeToString(i);
tmp[i] = g_strdup(action);
}
return g_steal_pointer(&tmp);
}

View File

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

View File

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