]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
lxc: Check domain is active/inactive as required by operation
authorJiri Denemark <jdenemar@redhat.com>
Mon, 3 May 2010 12:04:44 +0000 (14:04 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 4 May 2010 11:36:56 +0000 (13:36 +0200)
Report VIR_ERR_OPERATION_INVALID when operation which requires running
domain is called on inactive domain and vice versa.

src/lxc/lxc_driver.c

index 6884fea8cca44a0b88c895f59c8e077c1803ac1b..fc0df37e7921dc4fdc2684be1fa920c4b65217b7 100644 (file)
@@ -1378,6 +1378,12 @@ static int lxcDomainStart(virDomainPtr dom)
         goto cleanup;
     }
 
+    if (virDomainObjIsActive(vm)) {
+        lxcError(VIR_ERR_OPERATION_INVALID,
+                 "%s", _("Domain is already running"));
+        goto cleanup;
+    }
+
     ret = lxcVmStart(dom->conn, driver, vm);
 
     if (ret == 0)
@@ -1483,6 +1489,12 @@ static int lxcDomainShutdown(virDomainPtr dom)
         goto cleanup;
     }
 
+    if (!virDomainObjIsActive(vm)) {
+        lxcError(VIR_ERR_OPERATION_INVALID,
+                 "%s", _("Domain is not running"));
+        goto cleanup;
+    }
+
     ret = lxcVmTerminate(driver, vm, 0);
     event = virDomainEventNewFromObj(vm,
                                      VIR_DOMAIN_EVENT_STOPPED,
@@ -1662,6 +1674,12 @@ static int lxcDomainDestroy(virDomainPtr dom)
         goto cleanup;
     }
 
+    if (!virDomainObjIsActive(vm)) {
+        lxcError(VIR_ERR_OPERATION_INVALID,
+                 "%s", _("Domain is not running"));
+        goto cleanup;
+    }
+
     ret = lxcVmTerminate(driver, vm, SIGKILL);
     event = virDomainEventNewFromObj(vm,
                                      VIR_DOMAIN_EVENT_STOPPED,