提交 66d66081 编写于 作者: L Lin Ma 提交者: Michal Privoznik

virsh: Add event name completion to 'event' command

Signed-off-by: NLin Ma <lma@suse.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 05642e8b
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <config.h> #include <config.h>
#include "virsh-completer.h" #include "virsh-completer.h"
#include "virsh-domain.h"
#include "virsh.h" #include "virsh.h"
#include "virsh-pool.h" #include "virsh-pool.h"
#include "virsh-util.h" #include "virsh-util.h"
...@@ -676,3 +677,29 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED, ...@@ -676,3 +677,29 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
virStringListFree(ret); virStringListFree(ret);
return NULL; return NULL;
} }
char **
virshDomainEventNameCompleter(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_DOMAIN_EVENT_ID_LAST + 1) < 0)
goto error;
for (i = 0; i < VIR_DOMAIN_EVENT_ID_LAST; i++) {
if (VIR_STRDUP(ret[i], virshDomainEventCallbacks[i].name) < 0)
goto error;
}
return ret;
error:
virStringListFree(ret);
return NULL;
}
...@@ -82,4 +82,8 @@ char ** virshSecretEventNameCompleter(vshControl *ctl, ...@@ -82,4 +82,8 @@ char ** virshSecretEventNameCompleter(vshControl *ctl,
const vshCmd *cmd, const vshCmd *cmd,
unsigned int flags); unsigned int flags);
char ** virshDomainEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
#endif #endif
...@@ -13339,6 +13339,7 @@ static const vshCmdOptDef opts_event[] = { ...@@ -13339,6 +13339,7 @@ static const vshCmdOptDef opts_event[] = {
0), 0),
{.name = "event", {.name = "event",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.completer = virshDomainEventNameCompleter,
.help = N_("which event type to wait for") .help = N_("which event type to wait for")
}, },
{.name = "all", {.name = "all",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册