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

[libvirt] [PATCH v4 09/13] Adding memtunables to libvirt-lxc command



From: Nikunj A. Dadhania <nikunj linux vnet ibm com>

v4:
* Fix: call cgroup apis only if tunables are non zero

v1:
libvirt-lxc now configures the hardlimit, softlimit and swaplimit, if
specified in the domain xml file or picks up the defaults.

Acked-by: "Daniel P. Berrange" <berrange redhat com>
Signed-off-by: Nikunj A. Dadhania <nikunj linux vnet ibm com>
---
 src/lxc/lxc_controller.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 82ecce0..258130d 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -109,6 +109,36 @@ static int lxcSetContainerResources(virDomainDefPtr def)
                              def->name);
         goto cleanup;
     }
+    
+    if(def->mem.hard_limit) {
+        rc = virCgroupSetMemoryHardLimit(cgroup, def->mem.hard_limit);
+        if (rc != 0) {
+            virReportSystemError(-rc,
+                                 _("Unable to set memory hard limit for domain %s"),
+                                 def->name);
+            goto cleanup;
+        }
+    }
+
+    if(def->mem.soft_limit) {
+        rc = virCgroupSetMemorySoftLimit(cgroup, def->mem.soft_limit);
+        if (rc != 0) {
+            virReportSystemError(-rc,
+                                 _("Unable to set memory soft limit for domain %s"),
+                                 def->name);
+            goto cleanup;
+        }
+    }
+
+    if(def->mem.swap_hard_limit) {
+        rc = virCgroupSetSwapHardLimit(cgroup, def->mem.swap_hard_limit);
+        if (rc != 0) {
+            virReportSystemError(-rc,
+                                 _("Unable to set swap hard limit for domain %s"),
+                                 def->name);
+            goto cleanup;
+        }
+    }
 
     rc = virCgroupDenyAllDevices(cgroup);
     if (rc != 0) {


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