[Devel] [PATCH 1/6] vzctl: split ct_env_create
Kir Kolyshkin
kir at openvz.org
Fri May 17 10:24:55 PDT 2013
On 05/16/2013 09:47 AM, Andrey Wagin wrote:
> 2013/5/16 Glauber Costa <glommer at parallels.com>:
>> On 05/16/2013 04:14 PM, Andrey Vagin wrote:
>>> + ret = ct_env_create_real(arg);
>>> + if (ret < 0)
>>> return VZ_RESOURCE_ERROR;
>>> - }
>> Isn't it better to just keep the return values intact in create_real,
>> and then return them as is if ret != 0 ?
> It returns PID of the init process. VZ_RESOURCE_ERROR is positive too
>
It does not (maybe it's a bug in your patch).
+ /*
+ * 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 -1;
+ }
+
+ return 0;
+}
Did you mean "return ret" here?
Also, to not change all those return statements, I suggest to pass pid_t * as a second argument.
More information about the Devel
mailing list