[CRIU] [PATCH] pipes: Use pde as a reference in pipe_data_rst
Cyrill Gorcunov
gorcunov at openvz.org
Wed Jul 11 04:59:57 EDT 2012
Need it for PB transition.
Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
include/pipes.h | 2 +-
pipes.c | 27 +++++++++++++++------------
2 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/include/pipes.h b/include/pipes.h
index 655440f..eccfcf1 100644
--- a/include/pipes.h
+++ b/include/pipes.h
@@ -16,7 +16,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;
};
diff --git a/pipes.c b/pipes.c
index 5959f76..ff865f2 100644
--- a/pipes.c
+++ b/pipes.c
@@ -56,21 +56,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);
@@ -131,7 +134,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 */
@@ -143,11 +146,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;
@@ -155,7 +158,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;
}
--
1.7.7.6
More information about the CRIU
mailing list