[PATCH] LXC: Allow setting max mem lower than current mem

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

 



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 | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 9c006e9..b47ac5e 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -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;
-- 
1.8.5.5

--
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]