start: only preserve CLONE_NEWCGROUP when supported

parent eb42a0de
...@@ -1402,6 +1402,7 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1402,6 +1402,7 @@ static int lxc_spawn(struct lxc_handler *handler)
if (lxc_sync_barrier_child(handler, LXC_SYNC_READY_START)) if (lxc_sync_barrier_child(handler, LXC_SYNC_READY_START))
return -1; return -1;
if (cgns_supported()) {
ret = lxc_preserve_ns(handler->pid, "cgroup"); ret = lxc_preserve_ns(handler->pid, "cgroup");
if (ret < 0) { if (ret < 0) {
ERROR("%s - Failed to preserve cgroup namespace", strerror(errno)); ERROR("%s - Failed to preserve cgroup namespace", strerror(errno));
...@@ -1409,6 +1410,7 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1409,6 +1410,7 @@ static int lxc_spawn(struct lxc_handler *handler)
} }
handler->nsfd[LXC_NS_CGROUP] = ret; handler->nsfd[LXC_NS_CGROUP] = ret;
DEBUG("Preserved cgroup namespace via fd %d", ret); DEBUG("Preserved cgroup namespace via fd %d", ret);
}
if (lxc_network_recv_name_and_ifindex_from_child(handler) < 0) { if (lxc_network_recv_name_and_ifindex_from_child(handler) < 0) {
ERROR("Failed to receive names and ifindices for network " ERROR("Failed to receive names and ifindices for network "
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment