virsh: Add event name completion to 'network-event' command

Signed-off-by: Lin Ma <lma@suse.com>
This commit is contained in:
Lin Ma
2019-03-05 11:17:39 +08:00
committed by Michal Privoznik
parent 96837ab140
commit 397369853d
3 changed files with 32 additions and 0 deletions

View File

@@ -27,6 +27,7 @@
#include "virsh-nodedev.h"
#include "virsh-util.h"
#include "virsh-secret.h"
#include "virsh-network.h"
#include "internal.h"
#include "virutil.h"
#include "viralloc.h"
@@ -415,6 +416,32 @@ virshNetworkNameCompleter(vshControl *ctl,
}
char **
virshNetworkEventNameCompleter(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_NETWORK_EVENT_ID_LAST + 1) < 0)
goto error;
for (i = 0; i < VIR_NETWORK_EVENT_ID_LAST; i++) {
if (VIR_STRDUP(ret[i], virshNetworkEventCallbacks[i].name) < 0)
goto error;
}
return ret;
error:
virStringListFree(ret);
return NULL;
}
char **
virshNodeDeviceNameCompleter(vshControl *ctl,
const vshCmd *cmd ATTRIBUTE_UNUSED,