[CRIU] [PATCH] clear opts before setting

Pavel Emelyanov xemul at parallels.com
Mon Oct 14 02:20:16 PDT 2013


On 10/14/2013 12:46 AM, Ruslan Kuprieiev wrote:
> Hi!
> 
> Lets clear the opts, before resetting them in cr-service, so old options won't affect the new ones.
> We don't do some "free"s here, because we have only char pointers and they point only to constant strings.
> 
> Signed-off-by: Ruslan Kuprieiev <kupruser at gmail.com>
> ---
>  cr-service.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/cr-service.c b/cr-service.c
> index 771944c..ecc39dd 100644
> --- a/cr-service.c
> +++ b/cr-service.c
> @@ -97,6 +97,11 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
>  	socklen_t ids_len = sizeof(struct ucred);
>  	char images_dir_path[PATH_MAX];
>  
> +	/* clear opts from old data */
> +	(void)memset(&opts, 0, sizeof(opts));

This would kill opts.restore_detach from restore_using_req.
Also introduce the init_opts() fn and call it from main()
and from cr_service_work().

> +	INIT_LIST_HEAD(&opts.veth_pairs);
> +	INIT_LIST_HEAD(&opts.scripts);
> +
>  	if (getsockopt(sk, SOL_SOCKET, SO_PEERCRED, &ids, &ids_len)) {
>  		pr_perror("Can't get socket options.");
>  		return -1;
> @@ -140,6 +145,8 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
>  	/* checking flags from client */
>  	if (req->has_leave_running && req->leave_running)
>  		opts.final_state = TASK_ALIVE;
> +	else
> +		opts.final_state = TASK_DEAD;
>  
>  	if (!req->has_pid) {
>  		req->has_pid = true;
> 




More information about the CRIU mailing list