[CRIU] [PATCH 28/32] tools: cpt2 -- Add writing of pstree entries

Cyrill Gorcunov gorcunov at openvz.org
Mon Apr 1 07:17:28 EDT 2013


On Mon, Apr 01, 2013 at 03:04:22PM +0400, Pavel Emelyanov wrote:
> On 04/01/2013 02:54 PM, Cyrill Gorcunov wrote:
> > On Mon, Apr 01, 2013 at 02:29:23PM +0400, Pavel Emelyanov wrote:
> >>> +	list_for_each_entry(task, &task_list, list) {
> >>> +		ret = write_pstree_item(pstree_fd, task, &e,
> >>> +					threads, max_threads);
> >>> +		if (ret)
> >>> +			goto out;
> >>> +		list_for_each_entry(child, &task->children, list) {
> >>> +			ret = write_pstree_item(pstree_fd, child,
> >>> +						&e, threads, max_threads);
> >>> +			if (ret)
> >>> +				goto out;
> >>> +		}
> >>> +	}
> >>
> >> Does task_list contain all tasks? In that case we'll write some tasks twice.
> >> Does it contain only even-levels of tasks? O_O
> > 
> > At first task_list gathers all tasks from cpt file, then we walk over
> > the tree and connect tasks to respective parents, to have process tree
> > at the end of ptocess.
> 
> So task_list contains all the tasks. Why do we write each entry _and_ _it's_
> _children_ on every loop? Won't children be in image twice after this?

read_tasks
	list_add_tail(&task->list, &task_list);

collect_task(struct task_struct *task)
	...
-->	list_move(&task->list, &t->children);

the entries get moved out of task_list to respective parents. Still
there is a nit in my code, I'm walking not deep enough in tasks
children, i'll fix.


More information about the CRIU mailing list