[libvirt] [PATCH] Don't fail lxc domain start when memory controller support is missing

Daniel P. Berrange berrange at redhat.com
Mon Oct 18 09:11:51 UTC 2010


On Fri, Oct 15, 2010 at 06:05:10PM +0200, Guido Günther wrote:
> On Fri, Oct 15, 2010 at 10:15:02AM +0200, Guido Günther wrote:
> > Hi,
> > starting of lxc domains currently fails if memory controller support is
> > disabled in the kernel. Attached patch fixes this by ignoring the error
> > in case the files don't exist in the cgroup filesystem. I didn't add the
> > same exceptions for the recent hard and soft limit code since if somebody
> > sets this values he probably wants them enforced. O.k. to apply?
> In fact I missed one hunk. Here's a better patch with some commnents.
>  -- Guido

> >From b0f6c1628a3654c8a49382cd5b29577fddfe3f1c Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Guido=20G=C3=BCnther?= <agx at sigxcpu.org>
> Date: Fri, 15 Oct 2010 10:01:38 +0200
> Subject: [PATCH] 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
> ---
>  src/lxc/lxc_controller.c |    4 +++-
>  src/lxc/lxc_driver.c     |   11 ++++++++---
>  2 files changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
> index 20616b8..2a4f113 100644
> --- a/src/lxc/lxc_controller.c
> +++ b/src/lxc/lxc_controller.c
> @@ -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) {
> diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
> index df814da..8085169 100644
> --- a/src/lxc/lxc_driver.c
> +++ b/src/lxc/lxc_driver.c
> @@ -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;
>          }
>      }

ACK

Daniel
-- 
|: Red Hat, Engineering, London    -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://deltacloud.org :|
|: http://autobuild.org        -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|




More information about the libvir-list mailing list