[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH 2 of 2] Use cgroup functions to set resource limits on LXC domains



On Wed, Oct 01, 2008 at 01:19:04PM -0700, Dan Smith wrote:
> This patch adds code to the controller to set up a cgroup named after the
> domain name, set the memory limit, and restrict devices.  It also
> adds bits to lxc_driver to properly clean up the cgroup on domain death.
> 
> If virCgroupHaveSupport() says that no support is available, then we just
> allow the domain creation to proceed as it did before without resource
> controls in place.

  Okay in addition to Dan feedback on the error handling,

> +/**
> + * lxcSetContainerResources
> + * @def: pointer to virtual machine structure
> + *
> + * Creates a cgroup for the container, moves the task inside,
> + * and sets resource limits
> + *
> + * Returns 0 on success or -1 in case of error
> + */
> +static int lxcSetContainerResources(virDomainDefPtr def)
> +{
> +    virCgroupPtr cgroup;
> +    int rc = -1;
> +    int i;
> +    struct cgroup_device_policy devices[] = {
> +        {'c', 1, 3},
> +        {'c', 1, 5},
> +        {'c', 1, 7},
> +        {'c', 1, 8},
> +        {'c', 1, 9},
> +        {'c', 5, 1},
> +        {0,   0, 0}};

  creating a domain is always the trickiest part of domain lifecycle
and setting up the framework is often something a bit obfuscated, nearly
by definition. But if we could associate meaningful constants to the
device policies here, this would help people having to improve or
debug that code in the future ;-)

  otherwise looks fine to me,

    +1

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel veillard com  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]