[CRIU] [PATCH 2/4] restore: TASK_HELPERs live until RESTORE stage

Tycho Andersen tycho.andersen at canonical.com
Fri Sep 12 13:59:30 PDT 2014


On Sat, Sep 13, 2014 at 12:22:56AM +0400, Andrew Vagin wrote:
> On Fri, Sep 12, 2014 at 01:13:00PM -0500, Tycho Andersen wrote:
> > In order to use TASK_HELPERS to open files from dead processes, they should
> > persist until the end of the restore stage, so that the /proc files exist when
> > setting up the fds.
> > 
> > This commit is in preparation for the remap_dead_pid commits.
> > 
> > v2: wait() on helpers after restore stage is over
> > 
> > Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
> > ---
> >  cr-restore.c | 13 +++++++------
> >  1 file changed, 7 insertions(+), 6 deletions(-)
> > 
> > diff --git a/cr-restore.c b/cr-restore.c
> > index 4d5ccd5..75d3afa 100644
> > --- a/cr-restore.c
> > +++ b/cr-restore.c
> > @@ -702,7 +702,7 @@ static int pstree_wait_helpers()
> >  {
> >  	struct pstree_item *pi;
> >  
> > -	list_for_each_entry(pi, &current->children, sibling) {
> > +	for_each_pstree_item(pi) {
> 
> I think you remember, that a process can wait only its children.

Urgh, yes, I forgot it was the session helpers that were the whole
point, I was just thinking of the new helpers. I will fix both this
and the other issue you pointed out and repost.

Tycho

> >  		int status, ret;
> >  
> >  		if (pi->state != TASK_HELPER)
> > @@ -770,9 +770,6 @@ static int restore_one_alive_task(int pid, CoreEntry *core)
> >  
> >  	rst_mem_switch_to_private();
> >  
> > -	if (pstree_wait_helpers())
> > -		return -1;
> > -
> >  	if (prepare_fds(current))
> >  		return -1;
> >  
> > @@ -931,9 +928,10 @@ static int restore_one_task(int pid, CoreEntry *core)
> >  		ret = restore_one_alive_task(pid, core);
> >  	else if (current->state == TASK_DEAD)
> >  		ret = restore_one_zombie(pid, core);
> > -	else if (current->state == TASK_HELPER)
> > +	else if (current->state == TASK_HELPER) {
> > +		restore_finish_stage(CR_STATE_RESTORE);
> >  		ret = 0;
> > -	else {
> > +	} else {
> >  		pr_err("Unknown state in code %d\n", (int)core->tc->task_state);
> >  		ret = -1;
> >  	}
> > @@ -1711,6 +1709,9 @@ static int restore_root_task(struct pstree_item *init)
> >  	if (ret < 0)
> >  		goto out_kill;
> >  
> > +	if (pstree_wait_helpers() < 0)
> > +		goto out_kill;
> > +
> >  	ret = run_scripts(ACT_POST_RESTORE);
> >  	if (ret != 0) {
> >  		pr_err("Aborting restore due to script ret code %d\n", ret);
> > -- 
> > 1.9.1
> > 
> > _______________________________________________
> > CRIU mailing list
> > CRIU at openvz.org
> > https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list