2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 13:28:27 +00:00

pipes: Use pde as a reference in pipe_data_rst

Need it for PB transition.

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Cyrill Gorcunov 2012-07-11 12:59:00 +04:00 committed by Pavel Emelyanov
parent 12a0462f7e
commit 906f08133b
2 changed files with 16 additions and 13 deletions

View File

@ -21,7 +21,7 @@ struct pipe_data_dump {
extern int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms *p);
struct pipe_data_rst {
struct pipe_data_entry pde;
struct pipe_data_entry *pde;
struct pipe_data_rst *next;
};

27
pipes.c
View File

@ -53,21 +53,24 @@ int collect_pipe_data(int img_type, struct pipe_data_rst **hash)
r = xmalloc(sizeof(*r));
if (!r)
break;
r->pde = xmalloc(sizeof(*r->pde));
if (!r->pde)
break;
ret = read_img_eof(fd, &r->pde);
ret = read_img_eof(fd, r->pde);
if (ret <= 0)
break;
off = r->pde.off + lseek(fd, 0, SEEK_CUR);
lseek(fd, r->pde.bytes + r->pde.off, SEEK_CUR);
r->pde.off = off;
off = r->pde->off + lseek(fd, 0, SEEK_CUR);
lseek(fd, r->pde->bytes + r->pde->off, SEEK_CUR);
r->pde->off = off;
ret = r->pde.pipe_id & PIPE_DATA_HASH_MASK;
ret = r->pde->pipe_id & PIPE_DATA_HASH_MASK;
r->next = hash[ret];
hash[ret] = r;
pr_info("Collected pipe data for %#x (chain %u)\n",
r->pde.pipe_id, ret);
r->pde->pipe_id, ret);
}
close(fd);
@ -128,7 +131,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
struct pipe_data_rst *pd;
for (pd = hash[id & PIPE_DATA_HASH_MASK]; pd != NULL; pd = pd->next)
if (pd->pde.pipe_id == id)
if (pd->pde->pipe_id == id)
break;
if (!pd) { /* no data for this pipe */
@ -140,11 +143,11 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
if (img < 0)
return -1;
pr_info("\t\tSplicing data size=%u off=%u\n", pd->pde.bytes, pd->pde.off);
lseek(img, pd->pde.off, SEEK_SET);
pr_info("\t\tSplicing data size=%u off=%u\n", pd->pde->bytes, pd->pde->off);
lseek(img, pd->pde->off, SEEK_SET);
while (size != pd->pde.bytes) {
ret = splice(img, NULL, pfd, NULL, pd->pde.bytes - size, 0);
while (size != pd->pde->bytes) {
ret = splice(img, NULL, pfd, NULL, pd->pde->bytes - size, 0);
if (ret < 0) {
pr_perror("%#x: Error splicing data", id);
goto err;
@ -152,7 +155,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
if (ret == 0) {
pr_err("%#x: Wanted to restore %d bytes, but got %d\n",
id, pd->pde.bytes, size);
id, pd->pde->bytes, size);
ret = -1;
goto err;
}