[libvirt] [PATCH 2/2] LXC: use lxcDomainSetMemoryFlags to do lxcDomainSetMaxMemory's work

Chen Hanxiao chenhanxiao at cn.fujitsu.com
Wed Jul 16 09:51:06 UTC 2014


Signed-off-by: Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
---
 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 be6ee19..9f974eb 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)
 {
@@ -809,6 +778,11 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem)
     return lxcDomainSetMemoryFlags(dom, newmem, VIR_DOMAIN_AFFECT_LIVE);
 }
 
+static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long memory)
+{
+    return lxcDomainSetMemoryFlags(dom, memory, VIR_DOMAIN_MEM_MAXIMUM);
+}
+
 static int
 lxcDomainSetMemoryParameters(virDomainPtr dom,
                              virTypedParameterPtr params,
-- 
1.9.0




More information about the libvir-list mailing list