[PATCH 1/2] virsh: Add check for domain state before attempting resume

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 tools/virsh-domain.c | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 4d0cc8f..f41a74b 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -4530,19 +4530,29 @@ static bool
 cmdResume(vshControl *ctl, const vshCmd *cmd)
 {
     virDomainPtr dom;
-    bool ret = true;
+    bool ret = false;
     const char *name;
+    int state;
 
     if (!(dom = vshCommandOptDomain(ctl, cmd, &name)))
-        return false;
+        goto cleanup;
 
+    if ((state = vshDomainState(ctl, dom, NULL)) < 0) {
+        vshPrint(ctl, _("Unable to get domain status"));
+        goto cleanup;
+    }
+    if (state != VIR_DOMAIN_PAUSED) {
+        vshPrint(ctl, _("Domain %s is not paused"), name);
+        goto cleanup;
+    }
     if (virDomainResume(dom) == 0) {
         vshPrint(ctl, _("Domain %s resumed\n"), name);
+        ret = true;
     } else {
         vshError(ctl, _("Failed to resume domain %s"), name);
-        ret = false;
     }
 
+cleanup:
     virDomainFree(dom);
     return ret;
 }
-- 
1.8.1.4

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]