mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-25 23:25:24 +00:00
lxc: Make SetMemory work for active domains only
This commit is contained in:
parent
e1fa3fb0fc
commit
b94b72b457
@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) {
|
|||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainObjIsActive(vm)) {
|
if (!virDomainObjIsActive(vm)) {
|
||||||
if (driver->cgroup == NULL) {
|
lxcError(VIR_ERR_OPERATION_INVALID,
|
||||||
lxcError(VIR_ERR_NO_SUPPORT,
|
"%s", _("Domain is not running"));
|
||||||
"%s", _("cgroups must be configured on the host"));
|
goto cleanup;
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
|
|
||||||
lxcError(VIR_ERR_INTERNAL_ERROR,
|
|
||||||
_("Unable to get cgroup for %s"), vm->def->name);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (virCgroupSetMemory(cgroup, newmem) < 0) {
|
|
||||||
lxcError(VIR_ERR_OPERATION_FAILED,
|
|
||||||
"%s", _("Failed to set memory for domain"));
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
vm->def->memory = newmem;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (driver->cgroup == NULL) {
|
||||||
|
lxcError(VIR_ERR_NO_SUPPORT,
|
||||||
|
"%s", _("cgroups must be configured on the host"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
|
||||||
|
lxcError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
_("Unable to get cgroup for %s"), vm->def->name);
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (virCgroupSetMemory(cgroup, newmem) < 0) {
|
||||||
|
lxcError(VIR_ERR_OPERATION_FAILED,
|
||||||
|
"%s", _("Failed to set memory for domain"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
Loading…
Reference in New Issue
Block a user