mirror of https://gitee.com/openkylin/libvirt.git
virsh: Add event name completion to 'event' command
Signed-off-by: Lin Ma <lma@suse.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
05642e8bd1
commit
66d6608148
|
@ -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",
|
||||
|
|
Loading…
Reference in New Issue