提交 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 @@
#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,29 @@ virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
virStringListFree(ret);
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,
const vshCmd *cmd,
unsigned int flags);
char ** virshDomainEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
#endif
......@@ -13339,6 +13339,7 @@ static const vshCmdOptDef opts_event[] = {
0),
{.name = "event",
.type = VSH_OT_STRING,
.completer = virshDomainEventNameCompleter,
.help = N_("which event type to wait for")
},
{.name = "all",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册