fi
}
+# Set up cgroup CPU accounting (cpuacct)
+accounting() {
+ # 1-- once, system wide
+ grep -q "/sys/fs/cgroup cgroup" /proc/mounts || \
+ mount -t cgroup -ocpuacct none /sys/fs/cgroup
+ if [ -d /sys/fs/cgroup/$NAME ] ; then
+ : # reset?
+ else
+ mkdir /sys/fs/cgroup/$NAME
+ # the following fixes things that sometimes are broken?
+ for f in cpuset.mems cpuset.cpus ; do
+ [ -z "$(cat /sys/fs/cgroups/$NAME/$F)" ] && \
+ echo 0 > /sys/fs/cgroups/$NAME/$F
+ done
+
+ fi
+ # Register this task for subhost accounting
+ echo $$ > /sys/fs/cgroup/$NAME/tasks
+}
+
case "$CMD" in
start)
[ -e "/run/netns/$NSNAME" ] || setup_network
setup_rootfs
START=/bin/bash
[ -x $TARGET/startup ] && START=/startup
+ accounting
exec ip netns exec $NSNAME unshare \
--fork --pid --mount-proc --kill-child \
--uts --ipc --mount --cgroup \
umount $TARGET
[ -e $IMAGE ] && umount $MOUNT
ip netns del $NSNAME
+ rmdir /sys/fs/cgroup/$NAME
;;
*)
usage