2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-29 21:38:16 +00:00

restore: read core.img before forking to know a child state

It's necessary to get a number of zombies.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Andrey Vagin 2013-03-25 23:39:52 +04:00 committed by Pavel Emelyanov
parent 9af6770279
commit c2b081102b
2 changed files with 25 additions and 16 deletions

View File

@ -775,20 +775,9 @@ out:
return ret < 0 ? ret : 0;
}
static int restore_one_task(int pid)
static int restore_one_task(int pid, CoreEntry *core)
{
int fd, ret;
CoreEntry *core;
fd = open_image_ro(CR_FD_CORE, pid);
if (fd < 0)
return -1;
ret = pb_read_one(fd, &core, PB_CORE);
close(fd);
if (ret < 0)
return -1;
int ret;
if (check_core(core)) {
ret = -1;
@ -820,6 +809,8 @@ struct cr_clone_arg {
struct pstree_item *item;
unsigned long clone_flags;
int fd;
CoreEntry *core;
};
static void write_pidfile(char *pfname, int pid)
@ -839,10 +830,25 @@ static void write_pidfile(char *pfname, int pid)
static inline int fork_with_pid(struct pstree_item *item)
{
int ret = -1;
int ret = -1, fd;
struct cr_clone_arg ca;
pid_t pid = item->pid.virt;
if (item->state != TASK_HELPER) {
fd = open_image_ro(CR_FD_CORE, pid);
if (fd < 0)
return -1;
ret = pb_read_one(fd, &ca.core, PB_CORE);
close(fd);
if (ret < 0)
return -1;
if (ca.core->tc->task_state == TASK_DEAD)
item->parent->rst->nr_zombies++;
} else
ca.core = NULL;
ca.item = item;
ca.clone_flags = item->rst->clone_flags;
@ -901,6 +907,8 @@ err_unlock:
close(ca.fd);
}
err:
if (ca.core)
core_entry__free_unpacked(ca.core, NULL);
return ret;
}
@ -1134,7 +1142,7 @@ static int restore_task_with_children(void *_arg)
return restore_one_fake();
restore_finish_stage(CR_STATE_RESTORE_PGID);
return restore_one_task(current->pid.virt);
return restore_one_task(current->pid.virt, ca->core);
}
static inline int stage_participants(int next_stage)

View File

@ -274,9 +274,10 @@ struct rst_info {
unsigned long premmapped_len;
unsigned long clone_flags;
int nr_zombies;
int service_fd_id;
struct fdt *fdt;
};
static inline int in_vma_area(struct vma_area *vma, unsigned long addr)