]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virsh: Use VIR_ENUM_* for --target argument in cmdDomPMSuspend
authorLin Ma <lma@suse.com>
Tue, 15 Jun 2021 00:38:24 +0000 (08:38 +0800)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 15 Jun 2021 08:27:57 +0000 (10:27 +0200)
Signed-off-by: Lin Ma <lma@suse.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
tools/virsh-domain.c

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