mininet/mininet — pull request #391 by cdburkard (2014-09-26 22:40:29+00:00)
Title: attach to cgroup first, then mount namespace

While running mininet with CPULimitedHosts, if we run the popen command, an error occurs: "cgroup: could not add to cgroup h1".

This happens when we attach the new process to it's calling host's mount namespace, and the cgroup directory for that host is no longer visible. This is because we mount the cgroup in the root namespace, so any new processes that are in separate namespaces will not be able to see this.

This fix simply reorders mnexec command so that we attach to the cgroup first. We may want to rethink this in the future. possible alternatives:

1. We may also be able to share the cgroup directories over mount namespaces. currently, this will not work because we remount /sys after creating a network namespace.

2. We can reorder mnexec to make sure we attach to a cgroup before we attach to a mount namespace if both options are in the same mnexec command

3. We could try to remount cgroups after remounting /sys in mnexec.