Commit c2b08110 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

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

It's necessary to get a number of zombies.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9af67702
...@@ -775,20 +775,9 @@ out: ...@@ -775,20 +775,9 @@ out:
return ret < 0 ? ret : 0; return ret < 0 ? ret : 0;
} }
static int restore_one_task(int pid) static int restore_one_task(int pid, CoreEntry *core)
{ {
int fd, ret; int 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;
if (check_core(core)) { if (check_core(core)) {
ret = -1; ret = -1;
...@@ -820,6 +809,8 @@ struct cr_clone_arg { ...@@ -820,6 +809,8 @@ struct cr_clone_arg {
struct pstree_item *item; struct pstree_item *item;
unsigned long clone_flags; unsigned long clone_flags;
int fd; int fd;
CoreEntry *core;
}; };
static void write_pidfile(char *pfname, int pid) static void write_pidfile(char *pfname, int pid)
...@@ -839,10 +830,25 @@ 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) static inline int fork_with_pid(struct pstree_item *item)
{ {
int ret = -1; int ret = -1, fd;
struct cr_clone_arg ca; struct cr_clone_arg ca;
pid_t pid = item->pid.virt; 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.item = item;
ca.clone_flags = item->rst->clone_flags; ca.clone_flags = item->rst->clone_flags;
...@@ -901,6 +907,8 @@ err_unlock: ...@@ -901,6 +907,8 @@ err_unlock:
close(ca.fd); close(ca.fd);
} }
err: err:
if (ca.core)
core_entry__free_unpacked(ca.core, NULL);
return ret; return ret;
} }
...@@ -1134,7 +1142,7 @@ static int restore_task_with_children(void *_arg) ...@@ -1134,7 +1142,7 @@ static int restore_task_with_children(void *_arg)
return restore_one_fake(); return restore_one_fake();
restore_finish_stage(CR_STATE_RESTORE_PGID); 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) static inline int stage_participants(int next_stage)
......
...@@ -274,9 +274,10 @@ struct rst_info { ...@@ -274,9 +274,10 @@ struct rst_info {
unsigned long premmapped_len; unsigned long premmapped_len;
unsigned long clone_flags; unsigned long clone_flags;
int nr_zombies;
int service_fd_id; int service_fd_id;
struct fdt *fdt; struct fdt *fdt;
}; };
static inline int in_vma_area(struct vma_area *vma, unsigned long addr) static inline int in_vma_area(struct vma_area *vma, unsigned long addr)
......
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