diff --git a/src/init.c b/src/init.c index b40e686..27f22c8 100644 --- a/src/init.c +++ b/src/init.c @@ -414,7 +414,7 @@ int hyper_start_containers(struct hyper_pod *pod) return 0; } -static int hyper_setup_container(struct hyper_pod *pod) +static int hyper_setup_pod_init(struct hyper_pod *pod) { int stacksize = getpagesize() * 4; int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | @@ -461,11 +461,6 @@ static int hyper_setup_container(struct hyper_pod *pod) goto out; } - if (hyper_start_containers(pod) < 0) { - fprintf(stderr, "start containers failed\n"); - goto out; - } - ret = 0; out: close(arg.ctl_pipe[1]); @@ -587,7 +582,7 @@ static int hyper_setup_pod(struct hyper_pod *pod) return -1; } - if (hyper_setup_container(pod) < 0) { + if (hyper_setup_pod_init(pod) < 0) { fprintf(stderr, "start container failed\n"); return -1; } @@ -641,6 +636,12 @@ static int hyper_start_pod(char *json, int length) return -1; } + if (hyper_start_containers(pod) < 0) { + fprintf(stderr, "start containers failed\n"); + hyper_destroy_pod(pod); + return -1; + } + return 0; }