[CRIU] Re: [PATCH] show: logic for optionaly files introduced

Stanislav Kinsbursky skinsbursky at parallels.com
Wed Feb 8 07:32:19 EST 2012


Drop this.

08.02.2012 16:29, Kinsbursky Stanislav пишет:
> Some dump files (like UTS and IPC ns files) may not present after dump. But
> "show all" call have to take it into account and fail trying to open dump
> these files.
> "Opt" variable in struct cr_fd_desc_tmpl has been introduced to solve this
> problem. If this variable is set, then open failure for such files doesn't
> lead to failure of whole "show all" sequence.
> Also, added check for file validity of UTS ns file descriptor before
> show_utsns() call.
>
> Signed-off-by: Stanislav Kinsbursky<skinsbursky at parallels.com>
>
> ---
>   crtools.c         |    6 ++++++
>   include/crtools.h |    1 +
>   namespaces.c      |    3 ++-
>   3 files changed, 9 insertions(+), 1 deletions(-)
>
> diff --git a/crtools.c b/crtools.c
> index 8cfe866..6600451 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -109,12 +109,14 @@ struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX] = {
>   	[CR_FD_UTSNS] = {
>   		.fmt	= FMT_FNAME_UTSNS,
>   		.magic	= UTSNS_MAGIC,
> +		.opt	= 1,
>   	},
>
>   	/* IPC namespace variables */
>   	[CR_FD_IPCNS_VAR] = {
>   		.fmt	= FMT_FNAME_IPCNS_VAR,
>   		.magic	= IPCNS_VAR_MAGIC,
> +		.opt	= 1,
>   	},
>   };
>
> @@ -194,6 +196,8 @@ struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask, struct cr_fdset
>
>   		ret = open(path, O_RDWR | O_CREAT | O_EXCL, CR_FD_PERM);
>   		if (ret<  0) {
> +			if (fdset_template[i].opt)
> +				continue;
>   			pr_perror("Unable to open %s", path);
>   			goto err;
>   		}
> @@ -237,6 +241,8 @@ struct cr_fdset *prep_cr_fdset_for_restore(int pid, unsigned long use_mask)
>
>   		ret = open(path, O_RDWR, CR_FD_PERM);
>   		if (ret<  0) {
> +			if (fdset_template[i].opt)
> +				continue;
>   			pr_perror("Unable to open %s", path);
>   			goto err;
>   		}
> diff --git a/include/crtools.h b/include/crtools.h
> index acb6a6d..ff28f62 100644
> --- a/include/crtools.h
> +++ b/include/crtools.h
> @@ -60,6 +60,7 @@ struct cr_options {
>   struct cr_fd_desc_tmpl {
>   	const char	*fmt;			/* format for the name */
>   	u32		magic;			/* magic in the header */
> +	bool		opt;			/* optional presence flag */
>   };
>
>   extern struct cr_fd_desc_tmpl fdset_template[CR_FD_MAX];
> diff --git a/namespaces.c b/namespaces.c
> index 1e245b8..8a7cdb1 100644
> --- a/namespaces.c
> +++ b/namespaces.c
> @@ -122,7 +122,8 @@ int try_show_namespaces(int ns_pid)
>   	if (!fdset)
>   		return -1;
>
> -	show_utsns(fdset->fds[CR_FD_UTSNS]);
> +	if (fdset->fds[CR_FD_UTSNS] != -1)
> +		show_utsns(fdset->fds[CR_FD_UTSNS]);
>
>   	close_cr_fdset(&fdset);
>   	return 0;
>


-- 
Best regards,
Stanislav Kinsbursky



More information about the CRIU mailing list