[PATCH 03/12] virsh: Add target completion to nodesuspend command

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

 



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

diff --git a/tools/virsh-completer-host.c b/tools/virsh-completer-host.c
index 213f029552..d17bc5f5ce 100644
--- a/tools/virsh-completer-host.c
+++ b/tools/virsh-completer-host.c
@@ -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;
+}
diff --git a/tools/virsh-completer-host.h b/tools/virsh-completer-host.h
index a502216584..88106ec3db 100644
--- a/tools/virsh-completer-host.h
+++ b/tools/virsh-completer-host.h
@@ -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);
diff --git a/tools/virsh-host.c b/tools/virsh-host.c
index 9d6d2b3645..f42e995122 100644
--- a/tools/virsh-host.c
+++ b/tools/virsh-host.c
@@ -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)")
     },
-- 
2.26.2





[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