Quoting Stéphane Graber (stgra...@ubuntu.com): > Update add_device_node to use the new set_cgroup_item call instead > of having to figure out the cgroup paths and update the entries manually. > > Signed-off-by: Stéphane Graber <stgra...@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hal...@ubuntu.com> > --- > src/python-lxc/lxc/__init__.py.in | 40 > ++++++++++----------------------------- > 1 file changed, 10 insertions(+), 30 deletions(-) > > diff --git a/src/python-lxc/lxc/__init__.py.in > b/src/python-lxc/lxc/__init__.py.in > index 91a59ed..07c956b 100644 > --- a/src/python-lxc/lxc/__init__.py.in > +++ b/src/python-lxc/lxc/__init__.py.in > @@ -172,37 +172,17 @@ class Container(_lxc.Container): > path_stat = os.stat(path) > mode = stat.S_IMODE(path_stat.st_mode) > > - # Lookup the cgroup > - cgroup_path = None > - with open("/proc/%s/cgroup" % self.init_pid, "r") as fd: > - for line in fd: > - if ":devices:" in line: > - cgroup_path = line.split(":")[-1].strip() > - break > - else: > - return False > - > - # Lookup the cgroup mount point > - cgroup = None > - with open("/proc/mounts", "r") as fd: > - for line in fd: > - mount = line.split() > - if (mount[2] == "cgroup" and "devices" in mount[3] > - and os.path.exists("%s/%s" % (mount[1], > cgroup_path))): > - cgroup = "%s/%s" % (mount[1], cgroup_path) > - break > - > - if not os.path.exists(cgroup): > - return False > - > # Allow the target > - with open("%s/devices.allow" % cgroup, "a") as fd: > - if stat.S_ISBLK(path_stat.st_mode): > - fd.write("b %s:%s rwm" % (int(path_stat.st_rdev / 256), > - int(path_stat.st_rdev % 256))) > - elif stat.S_ISCHR(path_stat.st_mode): > - fd.write("c %s:%s rwm" % (int(path_stat.st_rdev / 256), > - int(path_stat.st_rdev % 256))) > + if stat.S_ISBLK(path_stat.st_mode): > + self.set_cgroup_item("devices.allow", > + "b %s:%s rwm" % > + (int(path_stat.st_rdev / 256), > + int(path_stat.st_rdev % 256))) > + elif stat.S_ISCHR(path_stat.st_mode): > + self.set_cgroup_item("devices.allow", > + "c %s:%s rwm" % > + (int(path_stat.st_rdev / 256), > + int(path_stat.st_rdev % 256))) > > # Create the target > rootfs = "/proc/%s/root/" % self.init_pid > -- > 1.8.0 > > > ------------------------------------------------------------------------------ > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial > Remotely access PCs and mobile devices and provide instant support > Improve your efficiency, and focus on delivering more value-add services > Discover what IT Professionals Know. Rescue delivers > http://p.sf.net/sfu/logmein_12329d2d > _______________________________________________ > Lxc-devel mailing list > Lxc-devel@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/lxc-devel ------------------------------------------------------------------------------ LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial Remotely access PCs and mobile devices and provide instant support Improve your efficiency, and focus on delivering more value-add services Discover what IT Professionals Know. Rescue delivers http://p.sf.net/sfu/logmein_12329d2d _______________________________________________ Lxc-devel mailing list Lxc-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/lxc-devel