virsh: Add signal name completion to send-process-signal command

Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Lin Ma 2020-11-10 17:51:02 +08:00 committed by Michal Privoznik
parent 7a975279b1
commit 96d01ce969
3 changed files with 26 additions and 0 deletions

View File

@ -715,3 +715,24 @@ virshDomainConsoleCompleter(vshControl *ctl,
return g_steal_pointer(&tmp);
}
char **
virshDomainSignalCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
VIR_AUTOSTRINGLIST tmp = NULL;
size_t i = 0;
virCheckFlags(0, NULL);
tmp = g_new0(char *, VIR_DOMAIN_PROCESS_SIGNAL_LAST + 1);
for (i = 0; i < VIR_DOMAIN_PROCESS_SIGNAL_LAST; i++) {
const char *name = virDomainProcessSignalTypeToString(i);
tmp[i] = g_strdup(name);
}
return g_steal_pointer(&tmp);
}

View File

@ -98,3 +98,7 @@ char ** virshDomainVcpulistViaAgentCompleter(vshControl *ctl,
char ** virshDomainConsoleCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char ** virshDomainSignalCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);

View File

@ -8905,6 +8905,7 @@ static const vshCmdOptDef opts_send_process_signal[] = {
{.name = "signame",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.completer = virshDomainSignalCompleter,
.help = N_("the signal number or name")
},
{.name = NULL}