Signed-off-by: Lin Ma <l...@suse.com>
---
 tools/virsh-completer-domain.c | 20 ++++++++++++++++++++
 tools/virsh-completer-domain.h |  4 ++++
 tools/virsh-domain.c           |  1 +
 3 files changed, 25 insertions(+)

diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index b1b670ffc5..a44ee65642 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -751,3 +751,23 @@ virshDomainLifecycleCompleter(vshControl *ctl 
G_GNUC_UNUSED,
 
     return g_steal_pointer(&tmp);
 }
+
+char **
+virshDomainLifecycleActionCompleter(vshControl *ctl G_GNUC_UNUSED,
+                                    const vshCmd *cmd G_GNUC_UNUSED,
+                                    unsigned int flags)
+{
+    size_t i = 0;
+    VIR_AUTOSTRINGLIST tmp = NULL;
+
+    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);
+}
diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h
index 70f6e30947..92c57bce75 100644
--- a/tools/virsh-completer-domain.h
+++ b/tools/virsh-completer-domain.h
@@ -106,3 +106,7 @@ char ** virshDomainSignalCompleter(vshControl *ctl,
 char ** virshDomainLifecycleCompleter(vshControl *ctl,
                                       const vshCmd *cmd,
                                       unsigned int flags);
+
+char ** virshDomainLifecycleActionCompleter(vshControl *ctl,
+                                            const vshCmd *cmd,
+                                            unsigned int flags);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index be91bd48fc..12b35c037d 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5723,6 +5723,7 @@ static const vshCmdOptDef opts_setLifecycleAction[] = {
     {.name = "action",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshDomainLifecycleActionCompleter,
      .help = N_("lifecycle action to set")
     },
     VIRSH_COMMON_OPT_DOMAIN_CONFIG,
-- 
2.26.0


Reply via email to