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

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

 



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@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]