[CRIU] Re: [PATCH v2] show: logic for optionaly files introduced
Stanislav Kinsbursky
skinsbursky at parallels.com
Wed Feb 8 09:29:11 EST 2012
Drop this completely.
08.02.2012 16:41, Kinsbursky Stanislav пишет:
> v2: removed "opt" check from dump stage fdset initialization.
>
> 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 | 4 ++++
> include/crtools.h | 1 +
> namespaces.c | 3 ++-
> 3 files changed, 7 insertions(+), 1 deletions(-)
>
> diff --git a/crtools.c b/crtools.c
> index 4b93de9..7fe5933 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,
> },
> };
>
> @@ -237,6 +239,8 @@ struct cr_fdset *prep_cr_fdset_for_show(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 fc8ff6f..686be63 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 16a3a1e..89e594d 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