It breaks with multiple cgroup mounts unless /etc/mtab is linked
to /proc/self/mounts (which it is not in Ubuntu, for instance).

Signed-off-by: Serge Hallyn <serge.hal...@canonical.com>

Index: lxc/src/lxc/lxc-ps.in
===================================================================
--- lxc.orig/src/lxc/lxc-ps.in  2011-07-28 11:29:35.003183756 -0500
+++ lxc/src/lxc/lxc-ps.in       2011-07-28 11:31:37.973180821 -0500
@@ -53,15 +53,21 @@
        my $mount_string;
 
        $mount_string=`mount -t cgroup |grep -E -e '^lxc '`;
-       unless ($mount_string) {
-               $mount_string=`mount |grep -m1 'type cgroup'`;
-       }
-       chomp($mount_string);
        if ($mount_string) {
+               # use the one 'lxc' cgroup mount if it exists
+               chomp($mount_string);
                $$ref_cgroup=`echo "$mount_string" |cut -d' ' -f3`;
                chomp($$ref_cgroup);
        }
-       die "unable to find mounted cgroup" unless $$ref_cgroup;
+       # Otherwise (i.e. cgroup-bin) use the first cgroup mount
+       $mount_string=`grep -m1 -E '^[^ \t]+[ \t]+[^ \t]+[ \t]+cgroup' 
/proc/self/mounts`;
+       unless ($mount_string) {
+               die "unable to find mounted cgroup" unless $$ref_cgroup;
+       }
+       chomp($mount_string);
+       $$ref_cgroup=`echo "$mount_string" |cut -d' ' -f2`;
+       chomp($$ref_cgroup);
+       return;
 }
 
 sub get_pids_in_containers {
@@ -115,11 +121,7 @@
     my $container = <LXC>;
     close LXC;
     chomp($container);
-    if ($container =~ m/[:,]ns[:,]/o) {
-       $container =~ s/.*:\///o;
-    } else {
-       $container ='';
-    }
+    $container =~ s/.*:\///o;
     return $container;
 }
 

------------------------------------------------------------------------------
Got Input?   Slashdot Needs You.
Take our quick survey online.  Come on, we don't ask for help often.
Plus, you'll get a chance to win $100 to spend on ThinkGeek.
http://p.sf.net/sfu/slashdot-survey
_______________________________________________
Lxc-users mailing list
Lxc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-users

Reply via email to