]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Adding memtunables to libvirt-lxc command
authorNikunj A. Dadhania <nikunj@linux.vnet.ibm.com>
Tue, 12 Oct 2010 16:14:44 +0000 (18:14 +0200)
committerDaniel Veillard <veillard@redhat.com>
Tue, 12 Oct 2010 17:26:09 +0000 (19:26 +0200)
libvirt-lxc now configures the hardlimit, softlimit and swaplimit, if
specified in the domain xml file or picks up the defaults.

src/lxc/lxc_controller.c

index 82ecce0de8e7a13d6ba282f4a3f79edf3b455709..20616b8673917c2eb415c6e9fd7928d554fdf8f3 100644 (file)
@@ -110,6 +110,36 @@ static int lxcSetContainerResources(virDomainDefPtr def)
         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) {
         virReportSystemError(-rc,