Commit b3e5cf75 authored by Evgeniy Akimov's avatar Evgeniy Akimov Committed by Pavel Emelyanov

restore: split finalize_restore into two stages

First stage of finalize_restore unmaps the restorer blob, second stage
detaches from processes. After first stage process tree is completely
restored and processes are ready to continue run through sigreturn.
This splitting allows us to execute something between these stages (e.g.
restore freezer cgroup state).
Signed-off-by: 's avatarEvgeniy Akimov <geka666@gmail.com>
Signed-off-by: 's avatarEugene Batalov <eabatalov89@gmail.com>
Acked-by: 's avatarAndrew Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 34662a68
...@@ -1779,25 +1779,21 @@ static int clear_breakpoints() ...@@ -1779,25 +1779,21 @@ static int clear_breakpoints()
return ret; return ret;
} }
static void finalize_restore(int status) static void finalize_restore(void)
{ {
struct pstree_item *item; struct pstree_item *item;
for_each_pstree_item(item) { for_each_pstree_item(item) {
pid_t pid = item->pid.real; pid_t pid = item->pid.real;
struct parasite_ctl *ctl; struct parasite_ctl *ctl;
int i;
if (!task_alive(item)) if (!task_alive(item))
continue; continue;
if (status < 0)
goto detach;
/* Unmap the restorer blob */ /* Unmap the restorer blob */
ctl = parasite_prep_ctl(pid, NULL); ctl = parasite_prep_ctl(pid, NULL);
if (ctl == NULL) if (ctl == NULL)
goto detach; continue;
parasite_unmap(ctl, (unsigned long)rsti(item)->munmap_restorer); parasite_unmap(ctl, (unsigned long)rsti(item)->munmap_restorer);
...@@ -1805,7 +1801,20 @@ static void finalize_restore(int status) ...@@ -1805,7 +1801,20 @@ static void finalize_restore(int status)
if (item->state == TASK_STOPPED) if (item->state == TASK_STOPPED)
kill(item->pid.real, SIGSTOP); kill(item->pid.real, SIGSTOP);
detach: }
}
static void finalize_restore_detach(int status)
{
struct pstree_item *item;
for_each_pstree_item(item) {
pid_t pid;
int i;
if (!task_alive(item))
continue;
for (i = 0; i < item->nr_threads; i++) { for (i = 0; i < item->nr_threads; i++) {
pid = item->threads[i].real; pid = item->threads[i].real;
if (pid < 0) { if (pid < 0) {
...@@ -2047,11 +2056,11 @@ static int restore_root_task(struct pstree_item *init) ...@@ -2047,11 +2056,11 @@ static int restore_root_task(struct pstree_item *init)
if (clear_breakpoints()) if (clear_breakpoints())
pr_err("Unable to flush breakpoints\n"); pr_err("Unable to flush breakpoints\n");
/* if (ret == 0)
* finalize_restore() always detaches from processes and finalize_restore();
* they continue run through sigreturn.
*/ /* Detaches from processes and they continue run through sigreturn. */
finalize_restore(ret); finalize_restore_detach(ret);
write_stats(RESTORE_STATS); write_stats(RESTORE_STATS);
......
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