LXC: Allow setting max mem lower than current mem

For inactive domains, set both current and maximum memory
to the specified 'maximum memory' value.

This matches the behavior of QEMU driver's SetMaxMemory.

https://bugzilla.redhat.com/show_bug.cgi?id=1091132
This commit is contained in:
Ján Tomko 2014-06-26 09:13:25 +02:00
parent 87388228f4
commit ba8c83614a

View File

@ -692,9 +692,14 @@ static int lxcDomainSetMaxMemory(virDomainPtr dom, unsigned long newmax)
goto cleanup; goto cleanup;
if (newmax < vm->def->mem.cur_balloon) { if (newmax < vm->def->mem.cur_balloon) {
virReportError(VIR_ERR_INVALID_ARG, if (!virDomainObjIsActive(vm)) {
"%s", _("Cannot set max memory lower than current memory")); vm->def->mem.cur_balloon = newmax;
goto cleanup; } else {
virReportError(VIR_ERR_OPERATION_INVALID, "%s",
_("Cannot set max memory lower than current"
" memory for an active domain"));
goto cleanup;
}
} }
vm->def->mem.max_balloon = newmax; vm->def->mem.max_balloon = newmax;