]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add lifecycle type completion to set-lifecycle-action command
authorLin Ma <lma@suse.com>
Tue, 10 Nov 2020 09:51:03 +0000 (17:51 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 10 Nov 2020 17:34:31 +0000 (18:34 +0100)
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer-domain.c
tools/virsh-completer-domain.h
tools/virsh-domain.c

index 1d3499d5abe118e1ab04ea6ee36fad8ed70f5bfd..6a76c54f7c5ff3ef7e152b2722149debd8f7d45a 100644 (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);
+}
index cdec66f23e03d1ade94f5dee2b55358025412678..70f6e3094728afacc15de729b879edd9cd7875b1 100644 (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);
index 1406bb45830bd183eb10bc8b46ee79b3ba14e5bc..be91bd48fc2121d4f3b4899c9e926e4987b7c716 100644 (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",