[CRIU] [PATCH 2/2] headers: Move vma_priv into vma.h

Pavel Emelyanov xemul at parallels.com
Thu Feb 26 08:30:35 PST 2015


On 02/25/2015 06:42 PM, Cyrill Gorcunov wrote:
> This allows us to reuse this helper on both
> sides: dump and restore.

OK, I will delay this till 1.5 release. One comment inline :)

> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  cr-dump.c          | 34 ++++------------------------------
>  include/restorer.h |  4 ----
>  include/vma.h      |  6 ++++++
>  3 files changed, 10 insertions(+), 34 deletions(-)
> 
> diff --git a/cr-dump.c b/cr-dump.c
> index cc524558989a..922dc602abe5 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -84,37 +84,11 @@ static char loc_buf[PAGE_SIZE];
>  bool privately_dump_vma(struct vma_area *vma)

Can we have both calls be

a) either static inline or #define
b) located in one header/c-file one after another

?

>  {
>  	/*
> -	 * The special areas are not dumped.
> +	 * We only dump contents for regular areas which
> +	 * lay inside user address space and consists of
> +	 * private data.
>  	 */
> -	if (!(vma->e->status & VMA_AREA_REGULAR))
> -		return false;
> -
> -	/* No dumps for file-shared mappings */
> -	if (vma->e->status & VMA_FILE_SHARED)
> -		return false;
> -
> -	/* No dumps for SYSV IPC mappings */
> -	if (vma->e->status & VMA_AREA_SYSVIPC)
> -		return false;
> -
> -#ifdef CONFIG_VDSO
> -	/* No dumps for vDSO VVAR data */
> -	if (vma->e->status & VMA_AREA_VVAR)
> -		return false;
> -#endif
> -	if (vma_area_is(vma, VMA_ANON_SHARED))
> -		return false;
> -
> -	if (!vma_area_is(vma, VMA_ANON_PRIVATE) &&
> -			!vma_area_is(vma, VMA_FILE_PRIVATE)) {
> -		pr_warn("Unexpected VMA area found\n");
> -		return false;
> -	}
> -
> -	if (vma->e->end > TASK_SIZE)
> -		return false;
> -
> -	return true;
> +	return (vma_priv(vma->e) && vma->e->end <= TASK_SIZE);
>  }
>  
>  static void close_vma_file(struct vma_area *vma)
> diff --git a/include/restorer.h b/include/restorer.h
> index 746810583477..ded084a522df 100644
> --- a/include/restorer.h
> +++ b/include/restorer.h
> @@ -197,8 +197,4 @@ enum {
>  /* the restorer_blob_offset__ prefix is added by gen_offsets.sh */
>  #define restorer_sym(rblob, name)	((void *)(rblob) + restorer_blob_offset__##name)
>  
> -#define vma_priv(vma) ((vma_entry_is(vma, VMA_AREA_REGULAR)) &&	\
> -			(vma_entry_is(vma, VMA_ANON_PRIVATE) || \
> -			vma_entry_is(vma, VMA_FILE_PRIVATE)))
> -
>  #endif /* __CR_RESTORER_H__ */
> diff --git a/include/vma.h b/include/vma.h
> index 878658cae342..b09ef37f8814 100644
> --- a/include/vma.h
> +++ b/include/vma.h
> @@ -76,6 +76,12 @@ extern bool privately_dump_vma(struct vma_area *vma);
>  #define vma_entry_is(vma, s)		(((vma)->status & (s)) == (s))
>  #define vma_entry_len(vma)		((vma)->end - (vma)->start)
>  
> +/* Test if the area contents should be dumped/restored */
> +#define vma_priv(vma)					\
> +	(vma_entry_is(vma, VMA_AREA_REGULAR) &&		\
> +	 (vma_entry_is(vma, VMA_ANON_PRIVATE) ||	\
> +	  vma_entry_is(vma, VMA_FILE_PRIVATE)))
> +
>  /*
>   * vma_premmaped_start() can be used only in restorer.
>   * In other cases vma_area->premmaped_addr must be used.
> 



More information about the CRIU mailing list