[lxc-devel] Patch: really complain when trying to start already started container

Serge Hallyn serge.hallyn at canonical.com
Fri Apr 27 15:03:41 UTC 2012


Quoting Frederic Crozat (fcrozat at suse.com):
> Hi,
> 
> it looks like the current detection of already started container doesn't
> work properly (cgroups is trying to be moved before socket command is
> created), making Serge fix (97d3756cbe10) useless.

I see what was happening.  You're right, more is needed.  It is
"working" for me, but if I do

	lxc-start -n p1 -d
	lxc-start -n p1

Then the second lxc-start does fail, but in the meantime
/sys/fs/cgroup/cpuset/p1 gets renamed to /sys/fs/cgroup/cpuset/deadxxxx,
and /sys/fs/cgroup/cpuset/p1 is an empty cgroup.

> Attached patch adds similar warning when moving / deleting cgroups
> fails.
> -- 
> Frederic Crozat <fcrozat at suse.com>
> SUSE

> >From abce2e8ee2cc07c1273dff7786902393a28108de Mon Sep 17 00:00:00 2001
> From: Frederic Crozat <fcrozat at suse.com>
> Date: Fri, 27 Apr 2012 15:57:02 +0200
> Subject: [PATCH] give a hint if old cgroup can't be moved
> 
> When cgroup can't be moved, it might be a hint container is already
> running.
> ---
>  src/lxc/cgroup.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/src/lxc/cgroup.c b/src/lxc/cgroup.c
> index 9af199d..e5d9dde 100644
> --- a/src/lxc/cgroup.c
> +++ b/src/lxc/cgroup.c
> @@ -369,6 +369,9 @@ static int lxc_one_cgroup_create(const char *name,
>  	if (!access(cgname, F_OK) && rmdir(cgname)) {
>  		if (try_to_move_cgname(cgparent, cgname)) {

We should check whether the tasks file in that directory (and maybe its
subdirs) is empty.  If not, say tasks in the container are still
running.   If so, then move the directory out of the way, or if that
fails (as you do here) give an error.  Meant to do that originally, but
the multiple-cgroup-mounts-versus-ns-cgroup-mount caused so many issues
I got distracted.

Do you mind adding that check here?

>  			SYSERROR("failed to remove previous cgroup '%s'", cgname);
> +			ERROR("##");
> +			ERROR("# The container might be already running!");
> +			ERROR("##");
>  			return -1;
>  		}
>  	}
> -- 
> 1.7.7
> 

> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and 
> threat landscape has changed and how IT managers can respond. Discussions 
> will include endpoint security, mobile security and the latest in malware 
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/

> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel





More information about the lxc-devel mailing list