diff --git a/criu/pipes.c b/criu/pipes.c index f1a66bf5d..8e781c998 100644 --- a/criu/pipes.c +++ b/criu/pipes.c @@ -168,6 +168,16 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash return -1; } + if (pd->pde->has_size) { + pr_info("Restoring size %#x for %#x\n", + pd->pde->size, pd->pde->pipe_id); + ret = fcntl(pfd, F_SETPIPE_SZ, pd->pde->size); + if (ret < 0) { + pr_perror("Can't restore pipe size"); + goto err; + } + } + iov.iov_base = pd->data; iov.iov_len = pd->pde->bytes; @@ -203,15 +213,6 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash pd->data = NULL; out: ret = 0; - if (pd->pde->has_size) { - pr_info("Restoring size %#x for %#x\n", - pd->pde->size, pd->pde->pipe_id); - ret = fcntl(pfd, F_SETPIPE_SZ, pd->pde->size); - if (ret < 0) - pr_perror("Can't restore pipe size"); - else - ret = 0; - } err: return ret; } @@ -442,6 +443,12 @@ int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms goto err; } + /* steal_pipe has to be able to fit all data from a target pipe */ + if (fcntl(steal_pipe[1], F_SETPIPE_SZ, pipe_size) < 0) { + pr_perror("Unable to set a pipe size"); + goto err; + } + bytes = tee(lfd, steal_pipe[1], pipe_size, SPLICE_F_NONBLOCK); if (bytes < 0) { if (errno != EAGAIN) {