From 11253a09f2b47eff623f6fa2b0ea2a87ccdcf231 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 20 Aug 2013 11:04:18 +0200 Subject: [PATCH] qemuSetupMemoryCgroup: Handle hard_limit properly 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 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 759ea9119e..a863ce6a26 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -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);