]> xenbits.xensource.com Git - libvirt.git/commitdiff
qemu, lxc: Raise error message when resuming running domain
authorSławek Kapłoński <slawek@kaplonski.pl>
Sat, 22 Oct 2016 10:30:01 +0000 (12:30 +0200)
committerMartin Kletzander <mkletzan@redhat.com>
Wed, 26 Oct 2016 17:46:44 +0000 (19:46 +0200)
When user tries to resume already running domain (Qemu or LXC)
VIR_ERR_OPERATION_INVALID error should be raised with message that
domain is already running.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1009008

src/lxc/lxc_driver.c
src/qemu/qemu_driver.c

index 466e67f11c496039c7052fbf0b4383afae2d9b54..4a0165a6160d480cad5ff79bb2c4d0956382d4be 100644 (file)
@@ -3156,6 +3156,7 @@ static int lxcDomainResume(virDomainPtr dom)
     virDomainObjPtr vm;
     virObjectEventPtr event = NULL;
     int ret = -1;
+    int state;
     virLXCDomainObjPrivatePtr priv;
     virLXCDriverConfigPtr cfg = virLXCDriverGetConfig(driver);
 
@@ -3176,7 +3177,12 @@ static int lxcDomainResume(virDomainPtr dom)
         goto endjob;
     }
 
-    if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) {
+    state = virDomainObjGetState(vm, NULL);
+    if (state == VIR_DOMAIN_RUNNING) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       "%s", _("domain is already running"));
+        goto endjob;
+    } else if (state == VIR_DOMAIN_PAUSED) {
         if (virCgroupSetFreezerState(priv->cgroup, "THAWED") < 0) {
             virReportError(VIR_ERR_OPERATION_FAILED,
                            "%s", _("Resume operation failed"));
index 3a518262a4e0b8e37ac2c06bbf2cc898722d63ad..3f57a9fee0b9d38cb653fec55013844831882f12 100644 (file)
@@ -1927,6 +1927,10 @@ static int qemuDomainResume(virDomainPtr dom)
         virReportError(VIR_ERR_OPERATION_INVALID,
                        "%s", _("domain is pmsuspended"));
         goto endjob;
+    } else if (state == VIR_DOMAIN_RUNNING) {
+        virReportError(VIR_ERR_OPERATION_INVALID,
+                       "%s", _("domain is already running"));
+        goto endjob;
     } else if ((state == VIR_DOMAIN_CRASHED &&
                 reason == VIR_DOMAIN_CRASHED_PANICKED) ||
                state == VIR_DOMAIN_PAUSED) {