[Devel] [PATCH rh7] ve: cgroups -- Allow to attach non-self into ve cgroups, v2
Vladimir Davydov
vdavydov at parallels.com
Mon May 18 09:34:45 PDT 2015
On Mon, May 18, 2015 at 03:52:35PM +0300, Cyrill Gorcunov wrote:
> --- linux-pcs7.git.orig/kernel/ve/ve.c
> +++ linux-pcs7.git/kernel/ve/ve.c
> @@ -750,24 +750,31 @@ static void ve_destroy(struct cgroup *cg
> static int ve_can_attach(struct cgroup *cg, struct cgroup_taskset *tset)
> {
> struct ve_struct *ve = cgroup_ve(cg);
> - struct task_struct *task = current;
> -
> - if (cgroup_taskset_size(tset) != 1 ||
> - cgroup_taskset_first(tset) != task ||
> - !thread_group_leader(task) ||
> - !thread_group_empty(task))
> - return -EINVAL;
> + struct task_struct *task;
>
> if (ve->is_locked)
> return -EBUSY;
>
> /*
> + * We either moving the whole group of threads,
> + * either a single thread process.
> + */
> + if (cgroup_taskset_size(tset) == 1) {
!= ?
> + task = cgroup_taskset_first(tset);
> + if (!thread_group_leader(task) && !thread_group_empty(task))
> + return -EINVAL;
> + }
> +
> + /*
> * Forbid userspace tasks to enter during starting or stopping.
> - * Permit attaching kernel threads and init task for this containers.
> + * Permit attaching kernel threads for this containers.
> */
> - if (!ve->is_running && (ve->ve_ns || nr_threads_ve(ve)) &&
> - !(task->flags & PF_KTHREAD))
> - return -EPIPE;
> + if (!ve->is_running && (ve->ve_ns || nr_threads_ve(ve))) {
> + cgroup_taskset_for_each(task, cg, tset) {
> + if (!(task->flags & PF_KTHREAD))
> + return -EPIPE;
> + }
> + }
>
> return 0;
> }
More information about the Devel
mailing list