[PATCH] virsh: Add virshCodesetNameCompleter

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

 



Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>

virsh: Add virshCodesetNameCompleter

Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx>
---
 tools/virsh-completer-domain.c | 22 ++++++++++++++++++++++
 tools/virsh-completer-domain.h |  4 ++++
 tools/virsh-domain.c           |  1 +
 3 files changed, 27 insertions(+)

diff --git a/tools/virsh-completer-domain.c b/tools/virsh-completer-domain.c
index e773af6552..fc4d7b2e52 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -31,6 +31,7 @@
 #include "virxml.h"
 #include "virperf.h"
 #include "virbitmap.h"
+#include "virkeycode.h"
 
 char **
 virshDomainNameCompleter(vshControl *ctl,
@@ -778,3 +779,24 @@ virshDomainLifecycleActionCompleter(vshControl *ctl G_GNUC_UNUSED,
 
     return g_steal_pointer(&tmp);
 }
+
+
+char **
+virshCodesetNameCompleter(vshControl *ctl G_GNUC_UNUSED,
+                          const vshCmd *cmd G_GNUC_UNUSED,
+                          unsigned int flags)
+{
+    g_auto(GStrv) tmp = NULL;
+    size_t i = 0;
+
+    virCheckFlags(0, NULL);
+
+    tmp = g_new0(char *, VIR_KEYCODE_SET_LAST + 1);
+
+    for (i = 0; i < VIR_KEYCODE_SET_LAST; i++) {
+        const char *name = virKeycodeSetTypeToString(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 92c57bce75..4c01b0ca1f 100644
--- a/tools/virsh-completer-domain.h
+++ b/tools/virsh-completer-domain.h
@@ -110,3 +110,7 @@ char ** virshDomainLifecycleCompleter(vshControl *ctl,
 char ** virshDomainLifecycleActionCompleter(vshControl *ctl,
                                             const vshCmd *cmd,
                                             unsigned int flags);
+
+char ** virshCodesetNameCompleter(vshControl *ctl,
+                              const vshCmd *cmd,
+                              unsigned int flags);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 1c58c26d93..d40995f44d 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8791,6 +8791,7 @@ static const vshCmdOptDef opts_send_key[] = {
     {.name = "codeset",
      .type = VSH_OT_STRING,
      .flags = VSH_OFLAG_REQ_OPT,
+     .completer = virshCodesetNameCompleter,
      .help = N_("the codeset of keycodes, default:linux")
     },
     {.name = "holdtime",
-- 
2.29.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