[CRIU] [PATCH v6 4/7] mount: Create binfmt_misc image w/o device suffix

Pavel Emelyanov xemul at virtuozzo.com
Mon Aug 29 07:20:53 PDT 2016


On 08/23/2016 07:16 PM, Kirill Tkhai wrote:
> Use name binfmt_misc.img for any mounted binfmt_misc.
> Note, that newly created binfmt_misc images won't restore
> on old criu.
> 
> Iterate over binfmt_misc_list if it's not empty on restore.
> 
> Also, because of above, let's change a behaviour of dump and now
> we do not create binfmt_misc images if there is no registered
> binfmt_misc entries.
> 
> v5: New
> v6: Use {open,close}_image sequence to determ if image exists
>     Iterate over binfmt_misc_list
> 
> Suggested-by: Pavel Emelyanov <xemul at virtuozzo.com>
> Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
> ---
>  criu/mount.c |   29 ++++++++++++++++++++++++-----
>  1 file changed, 24 insertions(+), 5 deletions(-)
> 
> diff --git a/criu/mount.c b/criu/mount.c
> index 768e739..9b22eeb 100644
> --- a/criu/mount.c
> +++ b/criu/mount.c
> @@ -1369,7 +1369,7 @@ static int dump_binfmt_misc_entry(int dfd, char *name, struct cr_img *img)
>  
>  static int binfmt_misc_dump(struct mount_info *pm)
>  {
> -	struct cr_img *img;
> +	struct cr_img *img = NULL;
>  	struct dirent *de;
>  	DIR *fdir = NULL;
>  	int fd, ret;
> @@ -1389,10 +1389,6 @@ static int binfmt_misc_dump(struct mount_info *pm)
>  	}
>  
>  	ret = -1;
> -	img = open_image(CR_FD_BINFMT_MISC_OLD, O_DUMP, pm->s_dev);
> -	if (!img)
> -		goto out;
> -
>  	while ((de = readdir(fdir))) {
>  		if (dir_dots(de))
>  			continue;
> @@ -1401,6 +1397,13 @@ static int binfmt_misc_dump(struct mount_info *pm)
>  		if (!strcmp(de->d_name, "status"))
>  			continue;
>  
> +		if (!img) {
> +			/* Create image only if an extry exists, i.e. here */
> +			img = open_image(CR_FD_BINFMT_MISC, O_DUMP);
> +			if (!img)
> +				goto out;
> +		}
> +
>  		if (dump_binfmt_misc_entry(fd, de->d_name, img))
>  			goto out;
>  	}
> @@ -1528,8 +1531,24 @@ static int binfmt_misc_restore(struct mount_info *mi)
>  	if (!buf)
>  		return -1;
>  
> +	if (!list_empty(&binfmt_misc_list)) {
> +		struct binfmt_misc_info *bmi;
> +
> +		list_for_each_entry(bmi, &binfmt_misc_list, list) {

Old code restored a single bmi object for the given mi. And thus was prepared to
have multiple _different_ binfmt-misc super blocks. New code takes _all_ the bmi-s
found in the images and restored them all into _every_ new binfmt-misc mount point.

This is odd. Either we should add some ID into the new image file, or explicitly
ban more than one entry in it.

> +			ret = binfmt_misc_restore_bme(mi, bmi->bme, buf);
> +			if (ret)
> +				break;
> +		}
> +		goto free_buf;
> +	}
> +
>  	img = open_image(CR_FD_BINFMT_MISC_OLD, O_RSTR, mi->s_dev);
>  	if (!img) {
> +		pr_err("Can't open binfmt_misc_old image\n");
> +		goto free_buf;
> +	} else if (empty_image(img)) {
> +		close_image(img);
> +		ret = 0;
>  		goto free_buf;
>  	}
>  
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu
> .
> 



More information about the CRIU mailing list