mirror of https://gitee.com/openkylin/libvirt.git
virsh: Add event name completion to 'nodedev-event' command
Signed-off-by: Lin Ma <lma@suse.com> Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a9f6b8fc8c
commit
83f1e64dd3
|
@ -26,6 +26,7 @@
|
||||||
#include "virsh-domain.h"
|
#include "virsh-domain.h"
|
||||||
#include "virsh.h"
|
#include "virsh.h"
|
||||||
#include "virsh-pool.h"
|
#include "virsh-pool.h"
|
||||||
|
#include "virsh-nodedev.h"
|
||||||
#include "virsh-util.h"
|
#include "virsh-util.h"
|
||||||
#include "virsh-secret.h"
|
#include "virsh-secret.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
@ -729,3 +730,29 @@ virshPoolEventNameCompleter(vshControl *ctl ATTRIBUTE_UNUSED,
|
||||||
virStringListFree(ret);
|
virStringListFree(ret);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
char **
|
||||||
|
virshNodedevEventNameCompleter(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_NODE_DEVICE_EVENT_ID_LAST) < 0)
|
||||||
|
goto error;
|
||||||
|
|
||||||
|
for (i = 0; i < VIR_NODE_DEVICE_EVENT_ID_LAST; i++) {
|
||||||
|
if (VIR_STRDUP(ret[i], virshNodedevEventCallbacks[i].name) < 0)
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
error:
|
||||||
|
virStringListFree(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
|
@ -90,4 +90,8 @@ char ** virshPoolEventNameCompleter(vshControl *ctl,
|
||||||
const vshCmd *cmd,
|
const vshCmd *cmd,
|
||||||
unsigned int flags);
|
unsigned int flags);
|
||||||
|
|
||||||
|
char ** virshNodedevEventNameCompleter(vshControl *ctl,
|
||||||
|
const vshCmd *cmd,
|
||||||
|
unsigned int flags);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -870,6 +870,7 @@ static const vshCmdOptDef opts_node_device_event[] = {
|
||||||
},
|
},
|
||||||
{.name = "event",
|
{.name = "event",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
|
.completer = virshNodedevEventNameCompleter,
|
||||||
.help = N_("which event type to wait for")
|
.help = N_("which event type to wait for")
|
||||||
},
|
},
|
||||||
{.name = "loop",
|
{.name = "loop",
|
||||||
|
|
Loading…
Reference in New Issue