]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemuSetupMemoryCgroup: Handle hard_limit properly
authorMichal Privoznik <mprivozn@redhat.com>
Tue, 20 Aug 2013 09:04:18 +0000 (11:04 +0200)
committerCole Robinson <crobinso@redhat.com>
Wed, 6 Nov 2013 17:16:25 +0000 (12:16 -0500)
Since 16bcb3 we have a regression. The hard_limit is set
unconditionally. By default the limit is zero. Hence, if user hasn't
configured any, we set the zero in cgroup subsystem making the kernel
kill the corresponding qemu process immediately. The proper fix is to
set hard_limit iff user has configured any.

(cherry picked from commit 94a24dd3a953f415596dd2800287c9010fa51c4c)

Conflicts:
src/qemu/qemu_cgroup.c

src/qemu/qemu_cgroup.c

index 759ea9119ef1b6468f896c10cdb02ba085784d4c..a863ce6a2670b3b9c8f058ee1762ecce58fd8a60 100644 (file)
@@ -618,12 +618,14 @@ int qemuSetupCgroup(virQEMUDriverPtr driver,
     }
 
     if (virCgroupHasController(priv->cgroup, VIR_CGROUP_CONTROLLER_MEMORY)) {
-        rc = virCgroupSetMemoryHardLimit(priv->cgroup, vm->def->mem.hard_limit);
-        if (rc != 0) {
-            virReportSystemError(-rc,
-                                 _("Unable to set memory hard limit for domain %s"),
-                                 vm->def->name);
-            goto cleanup;
+        if (vm->def->mem.hard_limit != 0) {
+            rc = virCgroupSetMemoryHardLimit(priv->cgroup, vm->def->mem.hard_limit);
+            if (rc != 0) {
+                virReportSystemError(-rc,
+                                     _("Unable to set memory hard limit for domain %s"),
+                                     vm->def->name);
+                goto cleanup;
+            }
         }
         if (vm->def->mem.soft_limit != 0) {
             rc = virCgroupSetMemorySoftLimit(priv->cgroup, vm->def->mem.soft_limit);