virsh: Use VIR_ENUM_* for --target argument in cmdDomPMSuspend

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 2021-06-15 08:38:24 +08:00 committed by Michal Privoznik
parent 0691d642ba
commit b41811b93d

View File

@ -43,6 +43,7 @@
#include "virstring.h" #include "virstring.h"
#include "virsh-console.h" #include "virsh-console.h"
#include "virsh-domain-monitor.h" #include "virsh-domain-monitor.h"
#include "virsh-host.h"
#include "virerror.h" #include "virerror.h"
#include "virtime.h" #include "virtime.h"
#include "virtypedparam.h" #include "virtypedparam.h"
@ -3472,7 +3473,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
const char *name; const char *name;
bool ret = false; bool ret = false;
const char *target = NULL; const char *target = NULL;
unsigned int suspendTarget; int suspendTarget;
unsigned long long duration = 0; unsigned long long duration = 0;
if (!(dom = virshCommandOptDomain(ctl, cmd, &name))) if (!(dom = virshCommandOptDomain(ctl, cmd, &name)))
@ -3484,13 +3485,7 @@ cmdDomPMSuspend(vshControl *ctl, const vshCmd *cmd)
if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0) if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
goto cleanup; goto cleanup;
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"));
goto cleanup; goto cleanup;
} }