[PATCH 18/19] virsh: Add lifecycle type completion to set-lifecycle-action command

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Lin Ma <lma@xxxxxxxx>
---
 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 c1151764ff..d8ea3d62b3 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -692,3 +692,23 @@ 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)
+{
+    size_t i = 0;
+    VIR_AUTOSTRINGLIST tmp = NULL;
+
+    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);
+}
diff --git a/tools/virsh-completer-domain.h b/tools/virsh-completer-domain.h
index cdec66f23e..70f6e30947 100644
--- a/tools/virsh-completer-domain.h
+++ b/tools/virsh-completer-domain.h
@@ -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);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index f69fbe41a5..516e55e564 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -5707,6 +5707,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",
-- 
2.26.0





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux