[CRIU] Re: [PATCH 1/5] pipes: Make dump_one_pipe_data/restore_pipe_data being non-static

Pavel Emelyanov xemul at parallels.com
Tue Jun 26 05:40:13 EDT 2012


> @@ -124,28 +124,24 @@ void mark_pipe_master(void)
>  	handle_pipes_data();
>  }
>  
> -static int restore_pipe_data(int pfd, struct pipe_info *pi)
> +int restore_pipe_data(int img, int pfd, u32 id, int bytes, off_t off)
>  {
> -	int fd, size = 0, ret;
> +	int size = 0, ret;
>  
> -	fd = open_image_ro(CR_FD_PIPES_DATA);
> -	if (fd < 0)
> -		return -1;

I'd better pass the open_image_ro's arg into this function rather than the image fd.

> +	lseek(img, off, SEEK_SET);
>  
> -	lseek(fd, pi->off, SEEK_SET);
> +	pr_info("\t\tSplicing data size=%d off=%ld\n", bytes, off);
>  
> -	pr_info("\t\tSplicing data size=%d off=%ld\n", pi->bytes, pi->off);
> -
> -	while (size != pi->bytes) {
> -		ret = splice(fd, NULL, pfd, NULL, pi->bytes - size, 0);
> +	while (size != bytes) {
> +		ret = splice(img, NULL, pfd, NULL, bytes - size, 0);
>  		if (ret < 0) {
> -			pr_perror("%#x: Error splicing data", pi->pe.id);
> +			pr_perror("%#x: Error splicing data", id);
>  			goto err;
>  		}
>  
>  		if (ret == 0) {
>  			pr_err("%#x: Wanted to restore %d bytes, but got %d\n",
> -				pi->pe.id, pi->bytes, size);
> +			       id, bytes, size);
>  			ret = -1;
>  			goto err;
>  		}

> @@ -304,7 +303,7 @@ int collect_pipes(void)
>  static u32 pipes_with_data[1024];	/* pipes for which data already dumped */
>  static int nr_pipes;
>  
> -static int dump_one_pipe_data(int lfd, u32 id, const struct fd_parms *p)
> +int dump_one_pipe_data(int img, int lfd, u32 id, const struct fd_parms *p)

Same here.

>  {
>  	int pipe_size, i, bytes;
>  	int steal_pipe[2];


More information about the CRIU mailing list