[CRIU] Re: [PATCH cr 05/16] restore: collect vma-s before creating children (v2)

Pavel Emelyanov xemul at parallels.com
Tue Oct 30 12:17:22 EDT 2012


> @@ -64,6 +64,9 @@ static int restore_task_with_children(void *);
>  static int sigreturn_restore(pid_t pid, CoreEntry *core, struct list_head *vmas, int nr_vmas);
>  static int prepare_restorer_blob(void);
>  
> +static LIST_HEAD(vma_list);
> +static int nr_vmas;

Since this becomes file-wide variable some better name is to be invented.

> +
>  static int shmem_remap(void *old_addr, void *new_addr, unsigned long size)
>  {
>  	void *ret;
> @@ -170,17 +173,22 @@ err:
>  	return ret;
>  }
>  
> -static int read_vmas(int pid, struct list_head *vmas, int *nr_vmas)
> +static int read_vmas(int pid)
>  {
> -	int fd, ret = -1;
> +	int fd, ret = 0;
> +	LIST_HEAD(old);
> +	struct vma_area *vma;
> +
> +	list_replace_init(&vma_list, &old);
> +	INIT_LIST_HEAD(&vma_list);

list_replace_init() did INIT_LIST_HEAD.

>  
> +	/* Skip errors, because a zombie doesn't have an image of vmas */
>  	fd = open_image_ro(CR_FD_VMAS, pid);
>  	if (fd < 0)
> -		return fd;
> +		goto out;

This can be not only ENOENT, but any other error. Do it the way it's done in
other places. Further, we'd better have some bullet-proof way of not-opening
optional image files.

>  
> -	*nr_vmas = 0;
> +	nr_vmas = 0;
>  	while (1) {
> -		struct vma_area *vma;
>  		VmaEntry *e;
>  
>  		ret = -1;


More information about the CRIU mailing list