]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
LXC: Allow setting max mem lower than current mem
authorJán Tomko <jtomko@redhat.com>
Thu, 26 Jun 2014 07:13:25 +0000 (09:13 +0200)
committerJán Tomko <jtomko@redhat.com>
Mon, 7 Jul 2014 12:41:26 +0000 (14:41 +0200)
For inactive domains, set both current and maximum memory
to the specified 'maximum memory' value.

This matches the behavior of QEMU driver's SetMaxMemory.

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

src/lxc/lxc_driver.c

index 9c006e9c2f1347e787e9fb2da45d46efaaa3a280..b47ac5ed6af2e4cbe4bc7b2e83db76ce03750103 100644 (file)
@@ -692,9 +692,14 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
         goto cleanup;
 
     if (newmax < vm->def->mem.cur_balloon) {
-        virReportError(VIR_ERR_INVALID_ARG,
-                       "%s", _("Cannot set max memory lower than current memory"));
-        goto cleanup;
+        if (!virDomainObjIsActive(vm)) {
+            vm->def->mem.cur_balloon = newmax;
+        } else {
+            virReportError(VIR_ERR_OPERATION_INVALID, "%s",
+                           _("Cannot set max memory lower than current"
+                             " memory for an active domain"));
+            goto cleanup;
+        }
     }
 
     vm->def->mem.max_balloon = newmax;