提交 b94b72b4 编写于 作者: J Jiri Denemark

lxc: Make SetMemory work for active domains only

上级 e1fa3fb0
...@@ -642,27 +642,30 @@ static int lxcDomainSetMemory(virDomainPtr dom, unsigned long newmem) { ...@@ -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) { if (driver->cgroup == NULL) {
lxcError(VIR_ERR_INTERNAL_ERROR, lxcError(VIR_ERR_NO_SUPPORT,
_("Unable to get cgroup for %s"), vm->def->name); "%s", _("cgroups must be configured on the host"));
goto cleanup; goto cleanup;
} }
if (virCgroupSetMemory(cgroup, newmem) < 0) { if (virCgroupForDomain(driver->cgroup, vm->def->name, &cgroup, 0) != 0) {
lxcError(VIR_ERR_OPERATION_FAILED, lxcError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Failed to set memory for domain")); _("Unable to get cgroup for %s"), vm->def->name);
goto cleanup; goto cleanup;
} }
} else {
vm->def->memory = newmem; 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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册