Commit 906f0813 authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

pipes: Use pde as a reference in pipe_data_rst

Need it for PB transition.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 12a0462f
...@@ -21,7 +21,7 @@ struct pipe_data_dump { ...@@ -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); 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_rst {
struct pipe_data_entry pde; struct pipe_data_entry *pde;
struct pipe_data_rst *next; struct pipe_data_rst *next;
}; };
......
...@@ -53,21 +53,24 @@ int collect_pipe_data(int img_type, struct pipe_data_rst **hash) ...@@ -53,21 +53,24 @@ int collect_pipe_data(int img_type, struct pipe_data_rst **hash)
r = xmalloc(sizeof(*r)); r = xmalloc(sizeof(*r));
if (!r) if (!r)
break; 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) if (ret <= 0)
break; break;
off = r->pde.off + lseek(fd, 0, SEEK_CUR); off = r->pde->off + lseek(fd, 0, SEEK_CUR);
lseek(fd, r->pde.bytes + r->pde.off, SEEK_CUR); lseek(fd, r->pde->bytes + r->pde->off, SEEK_CUR);
r->pde.off = off; 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]; r->next = hash[ret];
hash[ret] = r; hash[ret] = r;
pr_info("Collected pipe data for %#x (chain %u)\n", pr_info("Collected pipe data for %#x (chain %u)\n",
r->pde.pipe_id, ret); r->pde->pipe_id, ret);
} }
close(fd); close(fd);
...@@ -128,7 +131,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash ...@@ -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; struct pipe_data_rst *pd;
for (pd = hash[id & PIPE_DATA_HASH_MASK]; pd != NULL; pd = pd->next) 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; break;
if (!pd) { /* no data for this pipe */ 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 ...@@ -140,11 +143,11 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
if (img < 0) if (img < 0)
return -1; return -1;
pr_info("\t\tSplicing data size=%u off=%u\n", pd->pde.bytes, pd->pde.off); pr_info("\t\tSplicing data size=%u off=%u\n", pd->pde->bytes, pd->pde->off);
lseek(img, pd->pde.off, SEEK_SET); lseek(img, pd->pde->off, SEEK_SET);
while (size != pd->pde.bytes) { while (size != pd->pde->bytes) {
ret = splice(img, NULL, pfd, NULL, pd->pde.bytes - size, 0); ret = splice(img, NULL, pfd, NULL, pd->pde->bytes - size, 0);
if (ret < 0) { if (ret < 0) {
pr_perror("%#x: Error splicing data", id); pr_perror("%#x: Error splicing data", id);
goto err; goto err;
...@@ -152,7 +155,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash ...@@ -152,7 +155,7 @@ int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash
if (ret == 0) { if (ret == 0) {
pr_err("%#x: Wanted to restore %d bytes, but got %d\n", pr_err("%#x: Wanted to restore %d bytes, but got %d\n",
id, pd->pde.bytes, size); id, pd->pde->bytes, size);
ret = -1; ret = -1;
goto err; goto err;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment