[CRIU] [PATCH] util: disable log service in cr_system_userns if error fd was -1

Pavel Emelyanov xemul at virtuozzo.com
Fri Apr 22 08:58:08 PDT 2016


On 04/22/2016 06:23 PM, Stanislav Kinsburskiy wrote:
> In case of error fd was negative, log_fd is _moved_ as STDERR for the child.
> After move, log_fd is closed, and thus log service is broken and any error
> prints will disappear.
> This patch disables log service, thus redirecting error output to STDERR
> (which is log fd in this case).
> 
> Calling of log fini is:
> 1) to early: reopen_fd_as_nocheck will fail
> 2) to much: close_safe will print error message, because log fd was already
> closed
> 
> Signed-off-by: Stanislav Kinsburskiy <skinsbursky at virtuozzo.com>
> ---
>  criu/util.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/criu/util.c b/criu/util.c
> index dae6031..12ce8b4 100644
> --- a/criu/util.c
> +++ b/criu/util.c
> @@ -641,9 +641,6 @@ int cr_system_userns(int in, int out, int err, char *cmd,
>  		    move_img_fd(&err, STDIN_FILENO))
>  			goto out_chld;
>  
> -		if (stop_log_fd)
> -			log_fini();
> -
>  		if (in < 0) {
>  			close(STDIN_FILENO);
>  		} else {
> @@ -660,6 +657,9 @@ int cr_system_userns(int in, int out, int err, char *cmd,
>  		if (reopen_fd_as_nocheck(STDERR_FILENO, err))
>  			goto out_chld;
>  
> +		if (stop_log_fd)
> +			clear_bit(LOG_FD_OFF, sfd_map);

Messing directly with sfd_map here is bad idea. Add call __log_fini()
that finis the log with dead file descriptor.

> +
>  		execvp(cmd, argv);
>  
>  		pr_perror("exec failed");
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
> 



More information about the CRIU mailing list