]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
Don't fail lxc domain start when memory controller support is missing
authorGuido Günther <agx@sigxcpu.org>
Fri, 15 Oct 2010 08:01:38 +0000 (10:01 +0200)
committerGuido Günther <agx@sigxcpu.org>
Tue, 19 Oct 2010 19:29:12 +0000 (21:29 +0200)
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

src/lxc/lxc_controller.c
src/lxc/lxc_driver.c

index 20616b8673917c2eb415c6e9fd7928d554fdf8f3..2a4f113315ba3173d3383832d666d3599b4da089 100644 (file)
@@ -107,7 +107,9 @@ static int lxcSetContainerResources(virDomainDefPtr def)
         virReportSystemError(-rc,
                              _("Unable to set memory limit for domain %s"),
                              def->name);
-        goto cleanup;
+        /* Don't fail if we can't set memory due to lack of kernel support */
+        if (rc != -ENOENT)
+            goto cleanup;
     }
 
     if(def->mem.hard_limit) {
index 7563a8ce469d4363254d3ffef679ecb8da46ef16..0145d5e0b43bb3ec9681d1fd9e184f79f7f497f7 100644 (file)
@@ -485,7 +485,7 @@ static int lxcDomainGetInfo(virDomainPtr dom,
     lxc_driver_t *driver = dom->conn->privateData;
     virDomainObjPtr vm;
     virCgroupPtr cgroup = NULL;
-    int ret = -1;
+    int ret = -1, rc;
 
     lxcDriverLock(driver);
     vm = virDomainFindByUUID(&driver->domains, dom->uuid);
@@ -515,10 +515,15 @@ static int lxcDomainGetInfo(virDomainPtr dom,
                      "%s", _("Cannot read cputime for domain"));
             goto cleanup;
         }
-        if (virCgroupGetMemoryUsage(cgroup, &(info->memory)) < 0) {
+        if ((rc = virCgroupGetMemoryUsage(cgroup, &(info->memory))) < 0) {
             lxcError(VIR_ERR_OPERATION_FAILED,
                      "%s", _("Cannot read memory usage for domain"));
-            goto cleanup;
+            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;
         }
     }