On 04/27/2012 04:48 PM, Frederic Crozat wrote:
> 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.
>
> Attached patch adds similar warning when moving / deleting cgroups
> fails.

Hi Frederic,

I don't think it is a good indication for the userspace.

If the userspace is trying to start two times the same containers at the 
same time, it is up to the caller to understand what is going wrong and 
not lxc to interpret the reason of the failure.

But I admit the error reporting could be better. The 
'try_to_move_cgname' can fail in two cases, 'tempnam' fails with ENOMEM 
or 'rename' fails with the proper errno set.

So I suggest to add the check in this function:

Index: lxc/src/lxc/cgroup.c
===================================================================
--- lxc.orig/src/lxc/cgroup.c   2012-05-27 03:43:19.121713805 +0200
+++ lxc/src/lxc/cgroup.c        2012-05-27 04:03:33.233730379 +0200
@@ -338,12 +338,18 @@ int try_to_move_cgname(char *cgparent, c
          * duplicates if we race, and we'll just fail at that (unlikely)
          * point
          */
-
         newdir = tempnam(cgparent, "dead");
-       if (!newdir)
+       if (!newdir) {
+               ERROR("not enough memory to allocate a temporary name");
                 return -1;
-       if (rename(cgname, newdir))
+       }
+
+       if (rename(cgname, newdir)) {
+               SYSERROR("failed to rename the old cgroup '%s' to '%s'",
+                       cgname, newdir);
                 return -1;
+       }
+
         WARN("non-empty cgroup %s renamed to %s, please manually 
inspect it\n",
                 cgname, newdir);

@@ -425,7 +431,7 @@ static int lxc_one_cgroup_create(const c
          */
         if (!access(cgname, F_OK) && rmdir(cgname)) {
                 if (try_to_move_cgname(cgparent, cgname)) {
-                       SYSERROR("failed to remove previous cgroup 
'%s'", cgname);
+                       ERROR("failed to remove previous cgroup '%s'", 
cgname);
                         return -1;
                 }
         }


------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to