mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-01 06:45:35 +00:00
pipe/fifo: Collect data via cinfo engine
Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com>
This commit is contained in:
@@ -180,6 +180,8 @@ static struct collect_image_info *cinfos[] = {
|
|||||||
&ext_file_cinfo,
|
&ext_file_cinfo,
|
||||||
&timerfd_cinfo,
|
&timerfd_cinfo,
|
||||||
&file_locks_cinfo,
|
&file_locks_cinfo,
|
||||||
|
&pipe_data_cinfo,
|
||||||
|
&fifo_data_cinfo,
|
||||||
&sk_queues_cinfo,
|
&sk_queues_cinfo,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -241,11 +243,6 @@ static int root_prepare_shared(void)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collect_pipes())
|
|
||||||
return -1;
|
|
||||||
if (collect_fifo())
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (tty_verify_active_pairs())
|
if (tty_verify_active_pairs())
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
11
criu/fifo.c
11
criu/fifo.c
@@ -162,7 +162,14 @@ struct collect_image_info fifo_cinfo = {
|
|||||||
.collect = collect_one_fifo,
|
.collect = collect_one_fifo,
|
||||||
};
|
};
|
||||||
|
|
||||||
int collect_fifo(void)
|
static int collect_fifo_data(void *obj, ProtobufCMessage *msg, struct cr_img *img)
|
||||||
{
|
{
|
||||||
return collect_pipe_data(CR_FD_FIFO_DATA, pd_hash_fifo);
|
return do_collect_pipe_data(obj, msg, img, pd_hash_fifo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct collect_image_info fifo_data_cinfo = {
|
||||||
|
.fd_type = CR_FD_FIFO_DATA,
|
||||||
|
.pb_type = PB_PIPE_DATA,
|
||||||
|
.priv_size = sizeof(struct pipe_data_rst),
|
||||||
|
.collect = collect_fifo_data,
|
||||||
|
};
|
||||||
|
@@ -6,6 +6,6 @@ struct cr_imgset;
|
|||||||
|
|
||||||
extern const struct fdtype_ops fifo_dump_ops;
|
extern const struct fdtype_ops fifo_dump_ops;
|
||||||
extern struct collect_image_info fifo_cinfo;
|
extern struct collect_image_info fifo_cinfo;
|
||||||
extern int collect_fifo(void);
|
extern struct collect_image_info fifo_data_cinfo;
|
||||||
|
|
||||||
#endif /* __CR_FIFO_H__ */
|
#endif /* __CR_FIFO_H__ */
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
#include "images/pipe.pb-c.h"
|
#include "images/pipe.pb-c.h"
|
||||||
|
|
||||||
extern struct collect_image_info pipe_cinfo;
|
extern struct collect_image_info pipe_cinfo;
|
||||||
extern int collect_pipes(void);
|
extern struct collect_image_info pipe_data_cinfo;
|
||||||
extern const struct fdtype_ops pipe_dump_ops;
|
extern const struct fdtype_ops pipe_dump_ops;
|
||||||
|
|
||||||
static inline u32 pipe_id(const struct fd_parms *p)
|
static inline u32 pipe_id(const struct fd_parms *p)
|
||||||
@@ -33,7 +33,8 @@ struct pipe_data_rst {
|
|||||||
#define PIPE_DATA_HASH_SIZE (1 << PIPE_DATA_HASH_BITS)
|
#define PIPE_DATA_HASH_SIZE (1 << PIPE_DATA_HASH_BITS)
|
||||||
#define PIPE_DATA_HASH_MASK (PIPE_DATA_HASH_SIZE - 1)
|
#define PIPE_DATA_HASH_MASK (PIPE_DATA_HASH_SIZE - 1)
|
||||||
|
|
||||||
extern int collect_pipe_data(int img_type, struct pipe_data_rst **hash);
|
extern int do_collect_pipe_data(struct pipe_data_rst *,
|
||||||
|
ProtobufCMessage *, struct cr_img *, struct pipe_data_rst **hash);
|
||||||
extern int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash);
|
extern int restore_pipe_data(int img_type, int pfd, u32 id, struct pipe_data_rst **hash);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
59
criu/pipes.c
59
criu/pipes.c
@@ -53,44 +53,22 @@ static int pipe_data_read(struct cr_img *img, struct pipe_data_rst *r)
|
|||||||
return read_img_buf(img, r->data, bytes);
|
return read_img_buf(img, r->data, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int collect_pipe_data(int img_type, struct pipe_data_rst **hash)
|
int do_collect_pipe_data(struct pipe_data_rst *r, ProtobufCMessage *msg,
|
||||||
|
struct cr_img *img, struct pipe_data_rst **hash)
|
||||||
{
|
{
|
||||||
int ret;
|
int aux;
|
||||||
struct cr_img *img;
|
|
||||||
struct pipe_data_rst *r = NULL;
|
|
||||||
|
|
||||||
img = open_image(img_type, O_RSTR);
|
r->pde = pb_msg(msg, PipeDataEntry);
|
||||||
if (!img)
|
aux = pipe_data_read(img, r);
|
||||||
return -1;
|
if (aux < 0)
|
||||||
|
return aux;
|
||||||
|
|
||||||
while (1) {
|
aux = r->pde->pipe_id & PIPE_DATA_HASH_MASK;
|
||||||
ret = -1;
|
r->next = hash[aux];
|
||||||
r = xmalloc(sizeof(*r));
|
hash[aux] = r;
|
||||||
if (!r)
|
pr_info("Collected pipe data for %#x (chain %u)\n",
|
||||||
break;
|
r->pde->pipe_id, aux);
|
||||||
|
return 0;
|
||||||
ret = pb_read_one_eof(img, &r->pde, PB_PIPE_DATA);
|
|
||||||
if (ret <= 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
ret = pipe_data_read(img, r);
|
|
||||||
if (ret < 0)
|
|
||||||
break;
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (r && r->pde)
|
|
||||||
pipe_data_entry__free_unpacked(r->pde, NULL);
|
|
||||||
xfree(r);
|
|
||||||
|
|
||||||
close_image(img);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Choose who will restore a pipe. */
|
/* Choose who will restore a pipe. */
|
||||||
@@ -412,11 +390,18 @@ struct collect_image_info pipe_cinfo = {
|
|||||||
.collect = collect_one_pipe,
|
.collect = collect_one_pipe,
|
||||||
};
|
};
|
||||||
|
|
||||||
int collect_pipes(void)
|
static int collect_pipe_data(void *obj, ProtobufCMessage *msg, struct cr_img *img)
|
||||||
{
|
{
|
||||||
return collect_pipe_data(CR_FD_PIPES_DATA, pd_hash_pipes);
|
return do_collect_pipe_data(obj, msg, img, pd_hash_pipes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct collect_image_info pipe_data_cinfo = {
|
||||||
|
.fd_type = CR_FD_PIPES_DATA,
|
||||||
|
.pb_type = PB_PIPE_DATA,
|
||||||
|
.priv_size = sizeof(struct pipe_data_rst),
|
||||||
|
.collect = collect_pipe_data,
|
||||||
|
};
|
||||||
|
|
||||||
int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms *p)
|
int dump_one_pipe_data(struct pipe_data_dump *pd, int lfd, const struct fd_parms *p)
|
||||||
{
|
{
|
||||||
struct cr_img *img;
|
struct cr_img *img;
|
||||||
|
Reference in New Issue
Block a user