mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virsh: Use VIR_ENUM_* for --target argument in cmdNodeSuspend
Signed-off-by: Lin Ma <lma@suse.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
a61a6978d3
commit
7d1028c3f6
@ -950,6 +950,13 @@ cmdNodeMemStats(vshControl *ctl, const vshCmd *cmd)
|
|||||||
/*
|
/*
|
||||||
* "nodesuspend" command
|
* "nodesuspend" command
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
VIR_ENUM_IMPL(virNodeSuspendTarget,
|
||||||
|
VIR_NODE_SUSPEND_TARGET_LAST,
|
||||||
|
"mem",
|
||||||
|
"disk",
|
||||||
|
"hybrid");
|
||||||
|
|
||||||
static const vshCmdInfo info_nodesuspend[] = {
|
static const vshCmdInfo info_nodesuspend[] = {
|
||||||
{.name = "help",
|
{.name = "help",
|
||||||
.data = N_("suspend the host node for a given time duration")
|
.data = N_("suspend the host node for a given time duration")
|
||||||
@ -980,7 +987,7 @@ static bool
|
|||||||
cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd)
|
cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd)
|
||||||
{
|
{
|
||||||
const char *target = NULL;
|
const char *target = NULL;
|
||||||
unsigned int suspendTarget;
|
int suspendTarget;
|
||||||
long long duration;
|
long long duration;
|
||||||
virshControl *priv = ctl->privData;
|
virshControl *priv = ctl->privData;
|
||||||
|
|
||||||
@ -990,13 +997,7 @@ cmdNodeSuspend(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (vshCommandOptLongLong(ctl, cmd, "duration", &duration) < 0)
|
if (vshCommandOptLongLong(ctl, cmd, "duration", &duration) < 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (STREQ(target, "mem")) {
|
if ((suspendTarget = virNodeSuspendTargetTypeFromString(target)) < 0) {
|
||||||
suspendTarget = VIR_NODE_SUSPEND_TARGET_MEM;
|
|
||||||
} else if (STREQ(target, "disk")) {
|
|
||||||
suspendTarget = VIR_NODE_SUSPEND_TARGET_DISK;
|
|
||||||
} else if (STREQ(target, "hybrid")) {
|
|
||||||
suspendTarget = VIR_NODE_SUSPEND_TARGET_HYBRID;
|
|
||||||
} else {
|
|
||||||
vshError(ctl, "%s", _("Invalid target"));
|
vshError(ctl, "%s", _("Invalid target"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -21,5 +21,8 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "vsh.h"
|
#include "vsh.h"
|
||||||
|
#include "virenum.h"
|
||||||
|
|
||||||
extern const vshCmdDef hostAndHypervisorCmds[];
|
extern const vshCmdDef hostAndHypervisorCmds[];
|
||||||
|
|
||||||
|
VIR_ENUM_DECL(virNodeSuspendTarget);
|
||||||
|
Loading…
Reference in New Issue
Block a user