mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
pipe: dump all data from a pipe
Currently we use an additional pipe to steal data from a pipe, but we don't check that we steal all data. And the additional pipe can have a smaller size. Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
25
criu/pipes.c
25
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) {
|
||||
|
Reference in New Issue
Block a user