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

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

The patch code originally authored by Michal Privoznik, Please refer to
https://www.redhat.com/archives/libvir-list/2018-May/msg01022.htmlSigned-off-by: NLin Ma <lma@suse.com>
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
上级 bee2331f
......@@ -26,6 +26,7 @@
#include "virsh.h"
#include "virsh-pool.h"
#include "virsh-util.h"
#include "virsh-secret.h"
#include "internal.h"
#include "virutil.h"
#include "viralloc.h"
......@@ -649,3 +650,29 @@ virshAllocpagesPagesizeCompleter(vshControl *ctl,
VIR_FREE(ret);
goto cleanup;
}
char **
virshSecretEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
const vshCmd *cmd ATTRIBUTE_UNUSED,
unsigned int flags)
{
size_t i;
char **ret = NULL;
virCheckFlags(0, NULL);
if (VIR_ALLOC_N(ret, VIR_SECRET_EVENT_ID_LAST) < 0)
goto error;
for (i = 0; i < VIR_SECRET_EVENT_ID_LAST; i++) {
if (VIR_STRDUP(ret[i], virshSecretEventCallbacks[i].name) < 0)
goto error;
}
return ret;
error:
virStringListFree(ret);
return NULL;
}
......@@ -78,4 +78,8 @@ char ** virshAllocpagesPagesizeCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char ** virshSecretEventNameCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
#endif
......@@ -671,6 +671,7 @@ static const vshCmdOptDef opts_secret_event[] = {
},
{.name = "event",
.type = VSH_OT_STRING,
.completer = virshSecretEventNameCompleter,
.help = N_("which event type to wait for")
},
{.name = "loop",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册