]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Add target completion to nodesuspend command
authorLin Ma <lma@suse.com>
Tue, 15 Jun 2021 00:38:23 +0000 (08:38 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Jun 2021 08:27:55 +0000 (10:27 +0200)
Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer-host.c
tools/virsh-completer-host.h
tools/virsh-host.c

index 213f029552d475c849229c1f947bde65d0598e83..d17bc5f5cefd744fee0710117de7e96d3d1f1b46 100644 (file)
@@ -26,6 +26,7 @@
 #include "virstring.h"
 #include "virxml.h"
 #include "virutil.h"
+#include "virsh-host.h"
 
 static char *
 virshPagesizeNodeToString(xmlNodePtr node)
@@ -167,3 +168,22 @@ virshNodeCpuCompleter(vshControl *ctl,
 
     return g_steal_pointer(&tmp);
 }
+
+
+char **
+virshNodeSuspendTargetCompleter(vshControl *ctl G_GNUC_UNUSED,
+                                const vshCmd *cmd G_GNUC_UNUSED,
+                                unsigned int flags)
+{
+    char **ret = NULL;
+    size_t i;
+
+    virCheckFlags(0, NULL);
+
+    ret = g_new0(char *, VIR_NODE_SUSPEND_TARGET_LAST + 1);
+
+    for (i = 0; i < VIR_NODE_SUSPEND_TARGET_LAST; i++)
+        ret[i] = g_strdup(virNodeSuspendTargetTypeToString(i));
+
+    return ret;
+}
index a5022165846a4711258ef6e8668a62c8582dffd3..88106ec3dbe9e14f1afab8c2fa0d82470b73d438 100644 (file)
@@ -33,3 +33,7 @@ char ** virshCellnoCompleter(vshControl *ctl,
 char ** virshNodeCpuCompleter(vshControl *ctl,
                               const vshCmd *cmd,
                               unsigned int flags);
+
+char ** virshNodeSuspendTargetCompleter(vshControl *ctl,
+                                        const vshCmd *cmd,
+                                        unsigned int flags);
index 9d6d2b3645907bec95ab755e3c2a8a43caca63b6..f42e995122de45f76c459b00517127a43607d316 100644 (file)
@@ -972,6 +972,7 @@ static const vshCmdOptDef opts_node_suspend[] = {
     {.name = "target",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshNodeSuspendTargetCompleter,
      .help = N_("mem(Suspend-to-RAM), disk(Suspend-to-Disk), "
                 "hybrid(Hybrid-Suspend)")
     },