[CRIU] [PATCH] service: add ability to set inherit file descriptors

Pavel Emelyanov xemul at parallels.com
Fri Mar 27 13:45:06 PDT 2015


> @@ -344,6 +345,11 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
>  			goto err;
>  	}
>  
> +	for (i = 0; i < req->n_inherit_fd; i++) {
> +		if (inherit_fd_add(req->inherit_fd[i]->fd, req->inherit_fd[i]->key))
> +			goto err;
> +	}

You should check that we're in swrk mode here not to let inherit fds
from standalone service.

> +
>  	for (i = 0; i < req->n_cg_root; i++) {
>  		if (new_cg_root_add(req->cg_root[i]->ctrl,
>  					req->cg_root[i]->path))
> diff --git a/crtools.c b/crtools.c
> index 0b3c497..4412e4c 100644
> --- a/crtools.c
> +++ b/crtools.c

> @@ -1253,14 +1253,13 @@ static int inherit_fd_reused(struct inherit_fd *inh)
>   * We can't print diagnostics messages in this function because the
>   * log file isn't initialized yet.
>   */
> -int inherit_fd_add(char *optarg)
> +int inherit_fd_add(int fd, char *key);

This forward declaration isn't needed as the function in question
is already declared in the header.

> +int inherit_fd_parse(char *optarg)
>  {
>  	char *cp = NULL;
>  	int n = -1;
>  	int fd = -1;
>  	int dbg = 0;
> -	struct stat sbuf;
> -	struct inherit_fd *inh;
>  
>  	/*
>  	 * Parse the argument.



More information about the CRIU mailing list