[CRIU] [PATCH] pagemap: fix reading pages from socket for --remote case

Pavel Emelyanov xemul at virtuozzo.com
Mon Apr 24 05:10:04 PDT 2017


On 04/21/2017 06:25 PM, Mike Rapoport wrote:
> When --remote option is specified, read_local_page tries to pread from a
> socket, and fails with "Illegal seek" error.
> Restore single pread call for regular image files case and use read syscall
> instead of pread for the --remote case.
> 
> Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
> ---
>  criu/pagemap.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)
> 
> diff --git a/criu/pagemap.c b/criu/pagemap.c
> index 6c741b4..7d25c6f 100644
> --- a/criu/pagemap.c
> +++ b/criu/pagemap.c
> @@ -265,15 +265,23 @@ static int read_local_page(struct page_read *pr, unsigned long vaddr,
>  		return -1;
>  
>  	pr_debug("\tpr%d-%u Read page from self %lx/%"PRIx64"\n", pr->pid, pr->id, pr->cvaddr, pr->pi_off);
> -	while (1) {
> +	if (!opts.remote) {

Maybe it's better to introduce separate ->maybe_read_page callback for opts.remote case?
This would let us localize the cache/proxy pages reading code in one place.

-- Pavel

>  		ret = pread(fd, buf + curr, len - curr, pr->pi_off + curr);
> -		if (ret < 1) {
> +		if (ret != len) {
>  			pr_perror("Can't read mapping page %d", ret);
>  			return -1;
>  		}
> -		curr += ret;
> -		if (curr == len)
> -			break;
> +	} else {
> +		while (1) {
> +			ret = read(fd, buf + curr, len - curr);
> +			if (ret < 0) {
> +				pr_perror("Can't read mapping page %d", ret);
> +				return -1;
> +			}
> +			curr += ret;
> +			if (curr == len)
> +				break;
> +		}
>  	}
>  
>  	if (opts.auto_dedup) {
> 



More information about the CRIU mailing list