mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-03 15:55:53 +00:00
fdset: Introduce glbal fdset
This contains reg-files and sk-queues images, as they contain data which is potentially generated by every task, so keep it open all the time dump goes. Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
22
cr-dump.c
22
cr-dump.c
@@ -87,8 +87,7 @@ err:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int reg_files_fd = -1;
|
struct cr_fdset *glob_fdset;
|
||||||
int sk_queues_fd = -1;
|
|
||||||
|
|
||||||
struct fd_parms {
|
struct fd_parms {
|
||||||
unsigned long fd_name;
|
unsigned long fd_name;
|
||||||
@@ -103,7 +102,7 @@ struct fd_parms {
|
|||||||
static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
|
static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
|
||||||
{
|
{
|
||||||
char fd_str[128];
|
char fd_str[128];
|
||||||
int len;
|
int len, rfd;
|
||||||
struct reg_file_entry rfe;
|
struct reg_file_entry rfe;
|
||||||
|
|
||||||
snprintf(fd_str, sizeof(fd_str), "/proc/self/fd/%d", lfd);
|
snprintf(fd_str, sizeof(fd_str), "/proc/self/fd/%d", lfd);
|
||||||
@@ -122,9 +121,11 @@ static int dump_one_reg_file(int lfd, u32 id, const struct fd_parms *p)
|
|||||||
rfe.pos = p->pos;
|
rfe.pos = p->pos;
|
||||||
rfe.id = id;
|
rfe.id = id;
|
||||||
|
|
||||||
if (write_img(reg_files_fd, &rfe))
|
rfd = fdset_fd(glob_fdset, CR_FD_REG_FILES);
|
||||||
|
|
||||||
|
if (write_img(rfd, &rfe))
|
||||||
return -1;
|
return -1;
|
||||||
if (write_img_buf(reg_files_fd, big_buffer, len))
|
if (write_img_buf(rfd, big_buffer, len))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1494,12 +1495,8 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
|
|||||||
|
|
||||||
collect_sockets();
|
collect_sockets();
|
||||||
|
|
||||||
reg_files_fd = open_image(CR_FD_REG_FILES, O_RDWR | O_CREAT | O_EXCL);
|
glob_fdset = cr_glob_fdset_open(O_DUMP);
|
||||||
if (reg_files_fd < 0)
|
if (!glob_fdset)
|
||||||
goto err;
|
|
||||||
|
|
||||||
sk_queues_fd = open_image(CR_FD_SK_QUEUES, O_RDWR | O_CREAT | O_EXCL);
|
|
||||||
if (sk_queues_fd < 0)
|
|
||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
nr_shmems = 0;
|
nr_shmems = 0;
|
||||||
@@ -1520,8 +1517,7 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
|
|||||||
|
|
||||||
fd_id_show_tree();
|
fd_id_show_tree();
|
||||||
err:
|
err:
|
||||||
close(sk_queues_fd);
|
close_cr_fdset(&glob_fdset);
|
||||||
close(reg_files_fd);
|
|
||||||
pstree_switch_state(&pstree_list, opts);
|
pstree_switch_state(&pstree_list, opts);
|
||||||
free_pstree(&pstree_list);
|
free_pstree(&pstree_list);
|
||||||
|
|
||||||
|
@@ -233,6 +233,11 @@ struct cr_fdset *cr_ns_fdset_open(int pid, int mode)
|
|||||||
return cr_fdset_open(pid, _CR_FD_NS_FROM, _CR_FD_NS_TO, mode);
|
return cr_fdset_open(pid, _CR_FD_NS_FROM, _CR_FD_NS_TO, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct cr_fdset *cr_glob_fdset_open(int mode)
|
||||||
|
{
|
||||||
|
return cr_fdset_open(-1 /* ignored */, _CR_FD_GLOB_FROM, _CR_FD_GLOB_TO, mode);
|
||||||
|
}
|
||||||
|
|
||||||
static int parse_ns_string(const char *ptr, unsigned int *flags)
|
static int parse_ns_string(const char *ptr, unsigned int *flags)
|
||||||
{
|
{
|
||||||
const char *end = ptr + strlen(ptr);
|
const char *end = ptr + strlen(ptr);
|
||||||
|
@@ -47,8 +47,10 @@ enum {
|
|||||||
CR_FD_PSTREE,
|
CR_FD_PSTREE,
|
||||||
CR_FD_SHMEM_PAGES,
|
CR_FD_SHMEM_PAGES,
|
||||||
|
|
||||||
|
_CR_FD_GLOB_FROM,
|
||||||
CR_FD_SK_QUEUES,
|
CR_FD_SK_QUEUES,
|
||||||
CR_FD_REG_FILES,
|
CR_FD_REG_FILES,
|
||||||
|
_CR_FD_GLOB_TO,
|
||||||
|
|
||||||
CR_FD_MAX
|
CR_FD_MAX
|
||||||
};
|
};
|
||||||
@@ -129,6 +131,8 @@ static inline int fdset_fd(const struct cr_fdset *fdset, int type)
|
|||||||
return fdset->_fds[idx];
|
return fdset->_fds[idx];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern struct cr_fdset *glob_fdset;
|
||||||
|
|
||||||
int cr_dump_tasks(pid_t pid, const struct cr_options *opts);
|
int cr_dump_tasks(pid_t pid, const struct cr_options *opts);
|
||||||
int cr_restore_tasks(pid_t pid, struct cr_options *opts);
|
int cr_restore_tasks(pid_t pid, struct cr_options *opts);
|
||||||
int cr_show(unsigned long pid, struct cr_options *opts);
|
int cr_show(unsigned long pid, struct cr_options *opts);
|
||||||
@@ -140,6 +144,8 @@ int cr_check(void);
|
|||||||
|
|
||||||
struct cr_fdset *cr_task_fdset_open(int pid, int mode);
|
struct cr_fdset *cr_task_fdset_open(int pid, int mode);
|
||||||
struct cr_fdset *cr_ns_fdset_open(int pid, int mode);
|
struct cr_fdset *cr_ns_fdset_open(int pid, int mode);
|
||||||
|
struct cr_fdset *cr_glob_fdset_open(int mode);
|
||||||
|
|
||||||
void close_cr_fdset(struct cr_fdset **cr_fdset);
|
void close_cr_fdset(struct cr_fdset **cr_fdset);
|
||||||
|
|
||||||
void free_mappings(struct list_head *vma_area_list);
|
void free_mappings(struct list_head *vma_area_list);
|
||||||
|
@@ -30,6 +30,5 @@ extern int prepare_sockets(int pid);
|
|||||||
extern void show_unixsk(int fd);
|
extern void show_unixsk(int fd);
|
||||||
extern void show_inetsk(int fd);
|
extern void show_inetsk(int fd);
|
||||||
extern int show_sk_queues(int fd);
|
extern int show_sk_queues(int fd);
|
||||||
extern int sk_queues_fd;
|
|
||||||
|
|
||||||
#endif /* CR_SOCKETS_H__ */
|
#endif /* CR_SOCKETS_H__ */
|
||||||
|
@@ -499,7 +499,7 @@ int parasite_dump_socket_info(struct parasite_ctl *ctl, struct cr_fdset *fdset,
|
|||||||
xfree(tmp);
|
xfree(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = parasite_prep_file(sk_queues_fd, ctl);
|
ret = parasite_prep_file(fdset_fd(glob_fdset, CR_FD_SK_QUEUES), ctl);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto err_prepf;
|
goto err_prepf;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user