]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Add event name completion to 'pool-event' command
authorLin Ma <lma@suse.com>
Thu, 24 May 2018 13:16:26 +0000 (15:16 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 24 May 2018 13:26:10 +0000 (15:26 +0200)
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-completer.c
tools/virsh-completer.h
tools/virsh-pool.c

index 6fb56ebfdcf3f180d1f36b63acc1cb991bf5ab1c..050278203343826d409b639e5dac79699b80ed5f 100644 (file)
@@ -703,3 +703,29 @@ virshDomainEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
     virStringListFree(ret);
     return NULL;
 }
+
+
+char **
+virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
+                            const vshCmd *cmd ATTRIBUTE_UNUSED,
+                            unsigned int flags)
+{
+    size_t i = 0;
+    char **ret = NULL;
+
+    virCheckFlags(0, 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], virshPoolEventCallbacks[i].name) < 0)
+            goto error;
+    }
+
+    return ret;
+
+ error:
+    virStringListFree(ret);
+    return NULL;
+}
index 8763c4e2edb301f2bb9656e9754d657a0f346b6d..b02b49ce4ab0b4239794efd6fd384b7896703701 100644 (file)
@@ -86,4 +86,8 @@ char ** virshDomainEventNameCompleter(vshControl *ctl,
                                       const vshCmd *cmd,
                                       unsigned int flags);
 
+char ** virshPoolEventNameCompleter(vshControl *ctl,
+                                    const vshCmd *cmd,
+                                    unsigned int flags);
+
 #endif
index 0145b4430b5e869d512b4b4e18489a14785e47fe..cc49a5b96d0a10421e3b249a20b56985d3cd8a2a 100644 (file)
@@ -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",