mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-29 05:18:00 +00:00
dump: Images opening rework
Rename prep_cr_fdset_for_dump into cr_fdset_open and make it reentable, i.e. every next enter will open more files in the same fdset. Required for zombies and makes the code cleaner. Signed-off-by: Pavel Emelyanov <xemul@parallels.com> Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
parent
cfbb9239ec
commit
cf0550ce61
17
cr-dump.c
17
cr-dump.c
@ -1035,7 +1035,7 @@ static int dump_task_threads(struct pstree_item *item)
|
||||
if (item->pid == item->threads[i])
|
||||
continue;
|
||||
|
||||
cr_fdset_thread = prep_cr_fdset_for_dump(item->threads[i], CR_FD_DESC_CORE);
|
||||
cr_fdset_thread = cr_fdset_open(item->threads[i], CR_FD_DESC_CORE, NULL);
|
||||
if (!cr_fdset_thread)
|
||||
goto err;
|
||||
|
||||
@ -1075,6 +1075,10 @@ static int dump_one_task(struct pstree_item *item, struct cr_fdset *cr_fdset)
|
||||
if (ret < 0)
|
||||
goto err;
|
||||
|
||||
cr_fdset = cr_fdset_open(item->pid, CR_FD_DESC_NOPSTREE, cr_fdset);
|
||||
if (!cr_fdset)
|
||||
goto err;
|
||||
|
||||
ret = collect_mappings(pid, pid_dir, &vma_area_list);
|
||||
if (ret) {
|
||||
pr_err("Collect mappings (pid: %d) failed with %d\n", pid, ret);
|
||||
@ -1178,16 +1182,17 @@ int cr_dump_tasks(pid_t pid, struct cr_options *opts)
|
||||
collect_sockets();
|
||||
|
||||
list_for_each_entry(item, &pstree_list, list) {
|
||||
cr_fdset = cr_fdset_open(item->pid, CR_FD_DESC_NONE, NULL);
|
||||
if (!cr_fdset)
|
||||
goto err;
|
||||
|
||||
if (item->pid == pid) {
|
||||
cr_fdset = prep_cr_fdset_for_dump(item->pid, CR_FD_DESC_ALL);
|
||||
cr_fdset = cr_fdset_open(item->pid,
|
||||
CR_FD_DESC_USE(CR_FD_PSTREE), cr_fdset);
|
||||
if (!cr_fdset)
|
||||
goto err;
|
||||
if (dump_pstree(pid, &pstree_list, cr_fdset))
|
||||
goto err;
|
||||
} else {
|
||||
cr_fdset = prep_cr_fdset_for_dump(item->pid, CR_FD_DESC_NOPSTREE);
|
||||
if (!cr_fdset)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (dump_one_task(item, cr_fdset))
|
||||
|
13
crtools.c
13
crtools.c
@ -106,20 +106,23 @@ static struct cr_fdset *alloc_cr_fdset(void)
|
||||
return cr_fdset;
|
||||
}
|
||||
|
||||
struct cr_fdset *prep_cr_fdset_for_dump(int pid, unsigned long use_mask)
|
||||
struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask, struct cr_fdset *cr_fdset)
|
||||
{
|
||||
unsigned int i;
|
||||
int ret = -1;
|
||||
char path[PATH_MAX];
|
||||
struct cr_fdset *cr_fdset;
|
||||
|
||||
cr_fdset = alloc_cr_fdset();
|
||||
if (!cr_fdset)
|
||||
goto err;
|
||||
if (cr_fdset == NULL) {
|
||||
cr_fdset = alloc_cr_fdset();
|
||||
if (!cr_fdset)
|
||||
goto err;
|
||||
}
|
||||
|
||||
for (i = 0; i < CR_FD_MAX; i++) {
|
||||
if (!(use_mask & CR_FD_DESC_USE(i)))
|
||||
continue;
|
||||
if (cr_fdset->fds[i] != -1)
|
||||
continue;
|
||||
|
||||
ret = get_image_path(path, sizeof(path),
|
||||
fdset_template[i].fmt, pid);
|
||||
|
@ -88,7 +88,7 @@ int cr_restore_tasks(pid_t pid, struct cr_options *opts);
|
||||
int cr_show(unsigned long pid, struct cr_options *opts);
|
||||
int convert_to_elf(char *elf_path, int fd_core);
|
||||
|
||||
struct cr_fdset *prep_cr_fdset_for_dump(int pid, unsigned long use_mask);
|
||||
struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask, struct cr_fdset *);
|
||||
struct cr_fdset *prep_cr_fdset_for_restore(int pid, unsigned long use_mask);
|
||||
void close_cr_fdset(struct cr_fdset **cr_fdset);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user