]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
start: reorder START_SYNC_POST_CONFIGURE
authorChristian Brauner <christian.brauner@ubuntu.com>
Fri, 21 May 2021 09:18:21 +0000 (11:18 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Fri, 21 May 2021 15:27:58 +0000 (17:27 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/start.c

index f732eb52f1759f0fa589f7895391a847a9dc7f23..2080e3cf63a8c8f2c5b8043b881b1959503d4da6 100644 (file)
@@ -1800,32 +1800,32 @@ static int lxc_spawn(struct lxc_handler *handler)
                        ERROR("Failed to create the network");
                        goto out_delete_net;
                }
-
-               ret = lxc_network_send_to_child(handler);
-               if (ret < 0) {
-                       ERROR("Failed to send veth names to child");
-                       goto out_delete_net;
-               }
        }
 
+       /* Tell the child to continue its initialization. */
+       if (!lxc_sync_wake_child(handler, START_SYNC_POST_CONFIGURE))
+               goto out_delete_net;
+
        ret = lxc_rootfs_prepare_parent(handler);
        if (ret) {
                ERROR("Failed to prepare rootfs");
                goto out_delete_net;
        }
 
+       if (handler->ns_clone_flags & CLONE_NEWNET) {
+               ret = lxc_network_send_to_child(handler);
+               if (ret < 0) {
+                       ERROR("Failed to send veth names to child");
+                       goto out_delete_net;
+               }
+       }
+
        if (!lxc_list_empty(&conf->procs)) {
                ret = setup_proc_filesystem(&conf->procs, handler->pid);
                if (ret < 0)
                        goto out_delete_net;
        }
 
-       /* Tell the child to continue its initialization. We'll get
-        * START_SYNC_CGROUP when it is ready for us to setup cgroups.
-        */
-       if (!lxc_sync_barrier_child(handler, START_SYNC_POST_CONFIGURE))
-               goto out_delete_net;
-
        if (!lxc_list_empty(&conf->limits)) {
                ret = setup_resource_limits(&conf->limits, handler->pid);
                if (ret < 0) {
@@ -1834,6 +1834,13 @@ static int lxc_spawn(struct lxc_handler *handler)
                }
        }
 
+       /*
+        * Wait for the child to tell us that it's ready for us to prepare
+        * cgroups.
+        */
+       if (!lxc_sync_wait_child(handler, START_SYNC_CGROUP))
+               goto out_delete_net;
+
        if (!lxc_sync_barrier_child(handler, START_SYNC_CGROUP_UNSHARE))
                goto out_delete_net;