[ [PATCH v3 6/8] virsh: Add event name completion to 'pool-event' command

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

 



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

diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index c0c3c5571a..1fab758e12 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -707,3 +707,33 @@ virshEventNameCompleter(vshControl *ctl,
     virStringListFree(ret);
     return NULL;
 }
+
+
+char **
+virshPoolEventNameCompleter(vshControl *ctl,
+                            const vshCmd *cmd ATTRIBUTE_UNUSED,
+                            unsigned int flags)
+{
+    virshControlPtr priv = ctl->privData;
+    size_t i = 0;
+    char **ret = NULL;
+
+    virCheckFlags(0, NULL);
+
+    if (!priv->conn || virConnectIsAlive(priv->conn) <= 0)
+        return NULL;
+
+    if (VIR_ALLOC_N(ret, VIR_STORAGE_POOL_EVENT_ID_LAST) < 0)
+        goto error;
+
+    for (i = 0; i < VIR_STORAGE_POOL_EVENT_ID_LAST; i++) {
+        if (VIR_STRDUP(ret[i], vshPoolEventCallbacks[i].name) < 0)
+            goto error;
+    }
+
+    return ret;
+
+ error:
+    virStringListFree(ret);
+    return NULL;
+}
diff --git a/tools/virsh-completer.h b/tools/virsh-completer.h
index 9f8dc3dfa8..76fa31cb47 100644
--- a/tools/virsh-completer.h
+++ b/tools/virsh-completer.h
@@ -85,4 +85,8 @@ char ** virshSecretEventNameCompleter(vshControl *ctl,
                                       const vshCmd *cmd,
                                       unsigned int flags);
 
+char ** virshPoolEventNameCompleter(vshControl *ctl,
+                                    const vshCmd *cmd,
+                                    unsigned int flags);
+
 #endif
diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c
index f0544d2e2d..5f59e35894 100644
--- a/tools/virsh-pool.c
+++ b/tools/virsh-pool.c
@@ -2098,6 +2098,7 @@ static const vshCmdOptDef opts_pool_event[] = {
     },
     {.name = "event",
      .type = VSH_OT_STRING,
+     .completer = virshPoolEventNameCompleter,
      .help = N_("which event type to wait for")
     },
     {.name = "loop",
-- 
2.16.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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