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 94a24dd3a9)

Conflicts:
	src/qemu/qemu_cgroup.c
This commit is contained in:
Michal Privoznik 2013-08-20 11:04:18 +02:00 committed by Cole Robinson
parent 9421fd0010
commit 11253a09f2

View 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);