[PATCH 17/19] virsh: Add signal name completion to send-process-signal 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 305711151f..c1151764ff 100644
--- a/tools/virsh-completer-domain.c
+++ b/tools/virsh-completer-domain.c
@@ -672,3 +672,23 @@ virshDomainConsoleCompleter(vshControl *ctl,
 
     return g_steal_pointer(&tmp);
 }
+
+char **
+virshDomainSignalCompleter(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_PROCESS_SIGNAL_LAST + 1);
+
+    for (i = 0; i < VIR_DOMAIN_PROCESS_SIGNAL_LAST; i++) {
+        const char *name = virDomainProcessSignalTypeToString(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 02fea2fe94..cdec66f23e 100644
--- a/tools/virsh-completer-domain.h
+++ b/tools/virsh-completer-domain.h
@@ -98,3 +98,7 @@ char ** virshDomainVcpulistViaAgentCompleter(vshControl *ctl,
 char ** virshDomainConsoleCompleter(vshControl *ctl,
                                     const vshCmd *cmd,
                                     unsigned int flags);
+
+char ** virshDomainSignalCompleter(vshControl *ctl,
+                                   const vshCmd *cmd,
+                                   unsigned int flags);
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 65bbb6c646..f69fbe41a5 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -8895,6 +8895,7 @@ static const vshCmdOptDef opts_send_process_signal[] = {
     {.name = "signame",
      .type = VSH_OT_DATA,
      .flags = VSH_OFLAG_REQ,
+     .completer = virshDomainSignalCompleter,
      .help = N_("the signal number or name")
     },
     {.name = NULL}
-- 
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