[lxc-devel] [PATCHv3 05/14] cgroup: additional fix for deprecated ns subsystem

Ward, David - 0663 - MITLL david.ward at ll.mit.edu
Wed May 2 16:43:39 UTC 2012


On 21/03/12 19:28, Ward, David - 0663 - MITLL wrote:
> When a hierarchy contains the 'ns' subsystem, do not append '/lxc'
> to the parent cgroup. Update surrounding comments for consistency.
>
> Signed-off-by: David Ward<david.ward at ll.mit.edu>

This patch is actually unnecessary.  The existing code already handled 
the 'ns' subsystem; the sequence of function calls is just a bit 
confusing.  All other patches in this set are still valid.

David

> ---
>   src/lxc/cgroup.c |   13 +++++++------
>   1 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
> index 9af199d..e5145f9 100644
> --- a/src/lxc/cgroup.c
> +++ b/src/lxc/cgroup.c
> @@ -305,9 +305,9 @@ static int lxc_one_cgroup_create(const char *name,
>   	char initcgroup[MAXPATHLEN];
>   	int flags, ret;
>
> -	/* cgparent is the parent dir, /sys/fs/cgroup/<cgroup>/<init-cgroup>/lxc */
> +	/* cgparent is the parent dir, e.g., /sys/fs/cgroup/<cgroup>/<init-cgroup>/lxc */
>   	/* (remember get_init_cgroup() returns a path starting with '/') */
> -	/* cgname is the full name,    /sys/fs/cgroup/</cgroup>/<init-cgroup>/lxc/name */
> +	/* cgname is the full name, e.g., /sys/fs/cgroup/<cgroup>/<init-cgroup>/lxc/name */
>   	ret = snprintf(cginit, MAXPATHLEN, "%s%s", mntent->mnt_dir,
>   		get_init_cgroup(NULL, mntent, initcgroup));
>   	if (ret<  0 || ret>= MAXPATHLEN) {
> @@ -315,7 +315,10 @@ static int lxc_one_cgroup_create(const char *name,
>   		return -1;
>   	}
>
> -	ret = snprintf(cgparent, MAXPATHLEN, "%s/lxc", cginit);
> +	flags = get_cgroup_flags(mntent);
> +
> +	ret = snprintf(cgparent, MAXPATHLEN, "%s%s", cginit,
> +		       (flags&  CGROUP_NS_CGROUP) ? "" : "/lxc");
>   	if (ret<  0 || ret>= MAXPATHLEN) {
>   		SYSERROR("Failed creating pathname for cgroup parent (%d)\n", ret);
>   		return -1;
> @@ -326,8 +329,6 @@ static int lxc_one_cgroup_create(const char *name,
>   		return -1;
>   	}
>
> -	flags = get_cgroup_flags(mntent);
> -
>   	/* Do we have the deprecated ns_cgroup subsystem? */
>   	if (flags&  CGROUP_NS_CGROUP) {
>   		WARN("using deprecated ns_cgroup");
> @@ -356,7 +357,7 @@ static int lxc_one_cgroup_create(const char *name,
>   		return -1;
>   	}
>
> -	/* if /sys/fs/cgroup/<cgroup>/<init-cgroup>/lxc does not exist, create it */
> +	/* if cgparent does not exist, create it */
>   	if (access(cgparent, F_OK)&&  mkdir(cgparent, 0755)) {
>   		SYSERROR("failed to create '%s' directory", cgparent);
>   		return -1;

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4558 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20120502/05715255/attachment.bin>


More information about the lxc-devel mailing list