ct_env_create will able to execute CT and to resume CT Signed-off-by: Andrey Vagin <ava...@openvz.org> --- src/lib/hooks_ct.c | 45 +++++++++++++++++++++++++++------------------ 1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/src/lib/hooks_ct.c b/src/lib/hooks_ct.c index 6a5e766..184c26a 100644 --- a/src/lib/hooks_ct.c +++ b/src/lib/hooks_ct.c @@ -224,15 +224,13 @@ static int _env_create(void *data) return exec_container_init(arg, &create_param); } -static int ct_env_create(struct arg_start *arg) +static int ct_env_create_real(struct arg_start *arg) { long stack_size; char *child_stack; int clone_flags; int ret; - char procpath[STR_SIZE]; - char ctpath[STR_SIZE]; stack_size = get_pagesize(); if (stack_size < 0) @@ -245,6 +243,31 @@ static int ct_env_create(struct arg_start *arg) } child_stack += stack_size; + /* + * Belong in the setup phase + */ + clone_flags = SIGCHLD; + /* FIXME: USERNS is still work in progress */ + clone_flags |= CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWIPC; + clone_flags |= CLONE_NEWNET|CLONE_NEWNS; + + ret = clone(_env_create, child_stack, clone_flags, arg); + if (ret < 0) { + logger(-1, errno, "Unable to clone"); + /* FIXME: remove ourselves from container first */ + destroy_container(arg->veid); + return VZ_RESOURCE_ERROR; + } + + return 0; +} + +int ct_env_create(struct arg_start *arg) +{ + int ret; + char procpath[STR_SIZE]; + char ctpath[STR_SIZE]; + /* non-fatal */ if ((ret = ct_destroy(arg->h, arg->veid))) logger(0, 0, "Could not properly cleanup container: %s", @@ -268,21 +291,7 @@ static int ct_env_create(struct arg_start *arg) return VZ_RESOURCE_ERROR; } - /* - * Belong in the setup phase - */ - clone_flags = SIGCHLD; - /* FIXME: USERNS is still work in progress */ - clone_flags |= CLONE_NEWUTS|CLONE_NEWPID|CLONE_NEWIPC; - clone_flags |= CLONE_NEWNET|CLONE_NEWNS; - - ret = clone(_env_create, child_stack, clone_flags, arg); - if (ret < 0) { - logger(-1, errno, "Unable to clone"); - /* FIXME: remove ourselves from container first */ - destroy_container(arg->veid); - return VZ_RESOURCE_ERROR; - } + ret = ct_env_create_real(arg); snprintf(procpath, STR_SIZE, "/proc/%d/ns/net", ret); ret = symlink(procpath, ctpath); -- 1.8.2 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel