]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Add event name completion to 'nodedev-event' command
authorLin Ma <lma@suse.com>
Wed, 23 May 2018 06:32:46 +0000 (14:32 +0800)
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-nodedev.c

index 050278203343826d409b639e5dac79699b80ed5f..07dccb11e4c83159339e04c279805e97a65adc96 100644 (file)
@@ -26,6 +26,7 @@
 #include "virsh-domain.h"
 #include "virsh.h"
 #include "virsh-pool.h"
+#include "virsh-nodedev.h"
 #include "virsh-util.h"
 #include "virsh-secret.h"
 #include "internal.h"
@@ -729,3 +730,29 @@ virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
     virStringListFree(ret);
     return NULL;
 }
+
+
+char **
+virshNodedevEventNameCompleter(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_NODE_DEVICE_EVENT_ID_LAST) < 0)
+        goto error;
+
+    for (i = 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) {
+        if (VIR_STRDUP(ret[i], virshNodedevEventCallbacks[i].name) < 0)
+            goto error;
+    }
+
+    return ret;
+
+ error:
+    virStringListFree(ret);
+    return NULL;
+}
index b02b49ce4ab0b4239794efd6fd384b7896703701..61dd7e748403206dc7229346b831e68ad750ba81 100644 (file)
@@ -90,4 +90,8 @@ char ** virshPoolEventNameCompleter(vshControl *ctl,
                                     const vshCmd *cmd,
                                     unsigned int flags);
 
+char ** virshNodedevEventNameCompleter(vshControl *ctl,
+                                       const vshCmd *cmd,
+                                       unsigned int flags);
+
 #endif
index b26cd5cec9f317c47b366885cd7ae6a7d11203ba..e6f963ea66a0fa6ba4986c67a75b09d2a5df85ae 100644 (file)
@@ -870,6 +870,7 @@ static const vshCmdOptDef opts_node_device_event[] = {
     },
     {.name = "event",
      .type = VSH_OT_STRING,
+     .completer = virshNodedevEventNameCompleter,
      .help = N_("which event type to wait for")
     },
     {.name = "loop",