On 05/23/2018 08:32 AM, Lin Ma wrote:
Signed-off-by: Lin Ma <lma(a)suse.com>
---
tools/virsh-completer.c | 31 +++++++++++++++++++++++++++++++
tools/virsh-completer.h | 3 +++
tools/virsh-domain.c | 1 +
3 files changed, 35 insertions(+)
diff --git a/tools/virsh-completer.c b/tools/virsh-completer.c
index b402fd22c3..c0c3c5571a 100644
--- a/tools/virsh-completer.c
+++ b/tools/virsh-completer.c
@@ -23,6 +23,7 @@
#include <config.h>
#include "virsh-completer.h"
+#include "virsh-domain.h"
#include "virsh.h"
#include "virsh-pool.h"
#include "virsh-util.h"
@@ -676,3 +677,33 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
virStringListFree(ret);
return NULL;
}
+
+
+char **
+virshEventNameCompleter(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;
There is no need for connection.
+
+ if (VIR_ALLOC_N(ret, VIR_DOMAIN_EVENT_ID_LAST + 1) < 0)
+ goto error;
+
+ for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) {
+ if (VIR_STRDUP(ret[i], vshEventCallbacks[i].name) < 0)
+ goto error;
+ }
+
+ return ret;
+
+ error:
+ virStringListFree(ret);
+ return NULL;
+}
Michal