[PATCH v2 2/2] LXC: add support for --config in setmaxmem command

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

 



In lxc, we could not use setmaxmem command
with --config options.
This patch will add support for this.

Signed-off-by: Chen Hanxiao <chenhanxiao@xxxxxxxxxxxxxx>
---
 src/lxc/lxc_driver.c | 36 +++++-------------------------------
 1 file changed, 5 insertions(+), 31 deletions(-)

diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index d99ab3b..4741632 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -680,37 +680,6 @@ lxcDomainGetMaxMemory(virDomainPtr dom)
     return ret;
 }
 
-static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
-{
-    virDomainObjPtr vm;
-    int ret = -1;
-
-    if (!(vm = lxcDomObjFromDomain(dom)))
-        goto cleanup;
-
-    if (virDomainSetMaxMemoryEnsureACL(dom->conn, vm->def) < 0)
-        goto cleanup;
-
-    if (newmax < vm->def->mem.cur_balloon) {
-        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;
-    ret = 0;
-
- cleanup:
-    if (vm)
-        virObjectUnlock(vm);
-    return ret;
-}
-
 static int lxcDomainSetMemoryFlags(virDomainPtr dom, unsigned long newmem,
                                    unsigned int flags)
 {
@@ -804,6 +773,11 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
     return lxcDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_AFFECT_LIVE);
 }
 
+static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
+{
+    return lxcDomainSetMemoryFlags(dom, newmax, VIR_DOMAIN_MEM_MAXIMUM);
+}
+
 static int
 lxcDomainSetMemoryParameters(virDomainPtr dom,
                              virTypedParameterPtr params,
-- 
1.9.0

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