]> xenbits.xensource.com Git - libvirt.git/commitdiff
lxc: Make SetMemory work for active domains only
authorJiri Denemark <jdenemar@redhat.com>
Mon, 3 May 2010 12:02:56 +0000 (14:02 +0200)
committerJiri Denemark <jdenemar@redhat.com>
Tue, 4 May 2010 11:34:54 +0000 (13:34 +0200)
src/lxc/lxc_driver.c

index f118b7d0c3dcc2d18486981f5224fe097e80eef8..6884fea8cca44a0b88c895f59c8e077c1803ac1b 100644 (file)
@@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
         goto cleanup;
     }
 
-    if (virDomainObjIsActive(vm)) {
-        if (driver->cgroup == NULL) {
-            lxcError(VIR_ERR_NO_SUPPORT,
-                     "%s", _("cgroups must be configured on the host"));
-            goto cleanup;
-        }
+    if (!virDomainObjIsActive(vm)) {
+        lxcError(VIR_ERR_OPERATION_INVALID,
+                 "%s", _("Domain is not running"));
+        goto cleanup;
+    }
 
-        if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
-            lxcError(VIR_ERR_INTERNAL_ERROR,
-                     _("Unable to get cgroup for %s"), vm->def->name);
-            goto cleanup;
-        }
+    if (driver->cgroup == NULL) {
+        lxcError(VIR_ERR_NO_SUPPORT,
+                 "%s", _("cgroups must be configured on the host"));
+        goto cleanup;
+    }
 
-        if (virCgroupSetMemory(cgroup, newmem) < 0) {
-            lxcError(VIR_ERR_OPERATION_FAILED,
-                     "%s", _("Failed to set memory for domain"));
-            goto cleanup;
-        }
-    } else {
-        vm->def->memory = newmem;
+    if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
+        lxcError(VIR_ERR_INTERNAL_ERROR,
+                 _("Unable to get cgroup for %s"), vm->def->name);
+        goto cleanup;
+    }
+
+    if (virCgroupSetMemory(cgroup, newmem) < 0) {
+        lxcError(VIR_ERR_OPERATION_FAILED,
+                 "%s", _("Failed to set memory for domain"));
+        goto cleanup;
     }
+
     ret = 0;
 
 cleanup: