提交 679b464b 编写于 作者: G Guido Günther

Don't fail lxc domain start when memory controller support is missing

Debian stock kernel has CONFIG_CGROUP_MEM_RES_CTLR disabled due to the
overhead [1]. Allow to start containers if the corresponding files in
the cgroup filesystem are missing. This fixes Debian bug #566180 [2].

[1] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=534964
[2] http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=566180
上级 83e57114
...@@ -107,6 +107,8 @@ static int lxcSetContainerResources(virDomainDefPtr def) ...@@ -107,6 +107,8 @@ static int lxcSetContainerResources(virDomainDefPtr def)
virReportSystemError(-rc, virReportSystemError(-rc,
_("Unable to set memory limit for domain %s"), _("Unable to set memory limit for domain %s"),
def->name); def->name);
/* Don't fail if we can't set memory due to lack of kernel support */
if (rc != -ENOENT)
goto cleanup; goto cleanup;
} }
......
...@@ -485,7 +485,7 @@ static int lxcDomainGetInfo(virDomainPtr dom, ...@@ -485,7 +485,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
lxc_driver_t *driver = dom->conn->privateData; lxc_driver_t *driver = dom->conn->privateData;
virDomainObjPtr vm; virDomainObjPtr vm;
virCgroupPtr cgroup = NULL; virCgroupPtr cgroup = NULL;
int ret = -1; int ret = -1, rc;
lxcDriverLock(driver); lxcDriverLock(driver);
vm = virDomainFindByUUID(&driver->domains, dom->uuid); vm = virDomainFindByUUID(&driver->domains, dom->uuid);
...@@ -515,9 +515,14 @@ static int lxcDomainGetInfo(virDomainPtr dom, ...@@ -515,9 +515,14 @@ static int lxcDomainGetInfo(virDomainPtr dom,
"%s", _("Cannot read cputime for domain")); "%s", _("Cannot read cputime for domain"));
goto cleanup; goto cleanup;
} }
if (virCgroupGetMemoryUsage(cgroup, &(info->memory)) < 0) { if ((rc = virCgroupGetMemoryUsage(cgroup, &(info->memory))) < 0) {
lxcError(VIR_ERR_OPERATION_FAILED, lxcError(VIR_ERR_OPERATION_FAILED,
"%s", _("Cannot read memory usage for domain")); "%s", _("Cannot read memory usage for domain"));
if (rc == -ENOENT) {
/* Don't fail if we can't read memory usage due to a lack of
* kernel support */
info->memory = 0;
} else
goto cleanup; goto cleanup;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册