libvirt-lxc now configures the hardlimit, softlimit and swaplimit, if
specified in the domain xml file or picks up the defaults.
Signed-off-by: Nikunj A. Dadhania <nikunj(a)linux.vnet.ibm.com>
---
src/lxc/lxc_controller.c | 22 ++++++++++++++++++++++
1 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 82ecce0..dee99b7 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -109,6 +109,28 @@ static int lxcSetContainerResources(virDomainDefPtr def)
def->name);
goto cleanup;
}
+
+ 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;
+ }
+ 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;
+ }
+ 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) {