Commit 4a3861ac authored by Pavel Emelyanov's avatar Pavel Emelyanov

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: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 1fb1d941
......@@ -87,8 +87,7 @@ err:
return ret;
}
static int reg_files_fd = -1;
int sk_queues_fd = -1;
struct cr_fdset *glob_fdset;
struct fd_parms {
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)
{
char fd_str[128];
int len;
int len, rfd;
struct reg_file_entry rfe;
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.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;
if (write_img_buf(reg_files_fd, big_buffer, len))
if (write_img_buf(rfd, big_buffer, len))
return -1;
return 0;
......@@ -1494,12 +1495,8 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
collect_sockets();
reg_files_fd = open_image(CR_FD_REG_FILES, O_RDWR | O_CREAT | O_EXCL);
if (reg_files_fd < 0)
goto err;
sk_queues_fd = open_image(CR_FD_SK_QUEUES, O_RDWR | O_CREAT | O_EXCL);
if (sk_queues_fd < 0)
glob_fdset = cr_glob_fdset_open(O_DUMP);
if (!glob_fdset)
goto err;
nr_shmems = 0;
......@@ -1520,8 +1517,7 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
fd_id_show_tree();
err:
close(sk_queues_fd);
close(reg_files_fd);
close_cr_fdset(&glob_fdset);
pstree_switch_state(&pstree_list, opts);
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);
}
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)
{
const char *end = ptr + strlen(ptr);
......
......@@ -47,8 +47,10 @@ enum {
CR_FD_PSTREE,
CR_FD_SHMEM_PAGES,
_CR_FD_GLOB_FROM,
CR_FD_SK_QUEUES,
CR_FD_REG_FILES,
_CR_FD_GLOB_TO,
CR_FD_MAX
};
......@@ -129,6 +131,8 @@ static inline int fdset_fd(const struct cr_fdset *fdset, int type)
return fdset->_fds[idx];
}
extern struct cr_fdset *glob_fdset;
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_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_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 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_inetsk(int fd);
extern int show_sk_queues(int fd);
extern int sk_queues_fd;
#endif /* CR_SOCKETS_H__ */
......@@ -499,7 +499,7 @@ int parasite_dump_socket_info(struct parasite_ctl *ctl, struct cr_fdset *fdset,
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)
goto err_prepf;
......
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