[CRIU] [PATCH 1/5] pipe: don't create a tranport descriptor for inhereted pipes
Andrew Vagin
avagin at odin.com
Mon Jul 13 07:00:02 PDT 2015
On Mon, Jul 13, 2015 at 03:15:43PM +0300, Pavel Emelyanov wrote:
> On 07/02/2015 12:47 PM, Andrey Vagin wrote:
> > Otherwise we can get an error like this:
> > 1: \t\tCreate transport fd /crtools-fd-1-5
> > ...
> > 1: Found id pipe:[122747] (fd 8) in inherit fd list
> > 1: File pipe:[122747] will be restored from fd 9 duped from inherit
> >
> > 1: Error (util.c:131): fd 5 already in use (called at files.c:872)
>
> Frankly, I don't get what this error means. Can you share more details on it, please?
When we have a few descriptors which is associated with one inherited
pipe, we create a transport sockets for all descriptors except one. It's
our standard engine to restore file descriptors. But when we restore
inhereted fd, we alread have a descriptors which can be used to restore
a pipe and we use it. The code which restore inhereted pipes knows
nothing about transport sockets and fails if a required descriptor is
busy.
>
> > Signed-off-by: Andrey Vagin <avagin at openvz.org>
> > ---
> > files.c | 3 +++
> > pipes.c | 20 ++++++++++++--------
> > 2 files changed, 15 insertions(+), 8 deletions(-)
> >
> > diff --git a/files.c b/files.c
> > index 4eeb988..3e69be7 100644
> > --- a/files.c
> > +++ b/files.c
> > @@ -1394,6 +1394,9 @@ bool inherited_fd(struct file_desc *d, int *fd_p)
> > if (i_fd < 0)
> > return false;
> >
> > + if (fd_p == NULL)
> > + return true;
> > +
> > *fd_p = dup(i_fd);
> > if (*fd_p < 0)
> > pr_perror("Inherit fd DUP failed");
> > diff --git a/pipes.c b/pipes.c
> > index 7590472..62f550c 100644
> > --- a/pipes.c
> > +++ b/pipes.c
> > @@ -393,18 +393,22 @@ static int collect_one_pipe(void *o, ProtobufCMessage *base)
> > pr_info("Collected pipe entry ID %#x PIPE ID %#x\n",
> > pi->pe->id, pi->pe->pipe_id);
> >
> > - list_for_each_entry(tmp, &pipes, list)
> > - if (pi->pe->pipe_id == tmp->pe->pipe_id)
> > - break;
> > + if (file_desc_add(&pi->d, pi->pe->id, &pipe_desc_ops))
> > + return -1;
> >
> > - if (&tmp->list == &pipes)
> > - INIT_LIST_HEAD(&pi->pipe_list);
> > - else
> > - list_add(&pi->pipe_list, &tmp->pipe_list);
> > + INIT_LIST_HEAD(&pi->pipe_list);
> > + if (!inherited_fd(&pi->d, NULL)) {
> > + list_for_each_entry(tmp, &pipes, list)
> > + if (pi->pe->pipe_id == tmp->pe->pipe_id)
> > + break;
> > +
> > + if (&tmp->list != &pipes)
> > + list_add(&pi->pipe_list, &tmp->pipe_list);
> > + }
> >
> > list_add_tail(&pi->list, &pipes);
> > - return file_desc_add(&pi->d, pi->pe->id, &pipe_desc_ops);
> >
> > + return 0;
> > }
> >
> > struct collect_image_info pipe_cinfo = {
> >
>
More information about the CRIU
mailing list