1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2025-01-03 05:17:54 +03:00

virsh: Add target completion to nodesuspend command

Signed-off-by: Lin Ma <lma@suse.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Lin Ma 2021-06-15 08:38:23 +08:00 committed by Michal Privoznik
parent 7d1028c3f6
commit 0691d642ba
3 changed files with 25 additions and 0 deletions

View File

@ -26,6 +26,7 @@
#include "virstring.h"
#include "virxml.h"
#include "virutil.h"
#include "virsh-host.h"
static char *
virshPagesizeNodeToString(xmlNodePtr node)
@ -167,3 +168,22 @@ virshNodeCpuCompleter(vshControl *ctl,
return g_steal_pointer(&tmp);
}
char **
virshNodeSuspendTargetCompleter(vshControl *ctl G_GNUC_UNUSED,
const vshCmd *cmd G_GNUC_UNUSED,
unsigned int flags)
{
char **ret = NULL;
size_t i;
virCheckFlags(0, NULL);
ret = g_new0(char *, VIR_NODE_SUSPEND_TARGET_LAST + 1);
for (i = 0; i < VIR_NODE_SUSPEND_TARGET_LAST; i++)
ret[i] = g_strdup(virNodeSuspendTargetTypeToString(i));
return ret;
}

View File

@ -33,3 +33,7 @@ char ** virshCellnoCompleter(vshControl *ctl,
char ** virshNodeCpuCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);
char ** virshNodeSuspendTargetCompleter(vshControl *ctl,
const vshCmd *cmd,
unsigned int flags);

View File

@ -972,6 +972,7 @@ static const vshCmdOptDef opts_node_suspend[] = {
{.name = "target",
.type = VSH_OT_DATA,
.flags = VSH_OFLAG_REQ,
.completer = virshNodeSuspendTargetCompleter,
.help = N_("mem(Suspend-to-RAM), disk(Suspend-to-Disk), "
"hybrid(Hybrid-Suspend)")
},