[CRIU] [PATCH 10/22] parasite: Switch parasite to daemon mode

Pavel Emelyanov xemul at parallels.com
Wed May 15 09:03:31 EDT 2013


> +static int noinline parasite_daemon(struct parasite_init_args *args)
> +{
> +	struct tid_state_s *s;
> +	unsigned long new_sp = 0;
> +	bool is_leader = false;
> +
> +	s = find_thread_state(args->real);
> +	if (!s)
> +		return -ENOENT;
> +
> +	if (s->real == thread_leader->real)
> +		is_leader = true;
> +
> +	pr_info("Parasite entering daemon mode for %d\n", s->real);
> +	new_sp = (unsigned long)(void *)&s->stack[PARASITE_STACK_SIZE - 8];
> +
> +	if (is_leader)
> +		call_daemon_thread(new_sp, args, s, __parasite_daemon_thread_leader);

Why does leader need yet another stack?

> +	else
> +		call_daemon_thread(new_sp, args, s, __parasite_daemon_thread);
> +
> +	pr_info("Parasite leaving daemon mode for %d\n", s->real);
> +
> +	if (is_leader)
> +		sys_munmap(tid_state, TID_STATE_SIZE(nr_tid_state));
> +
> +	asm_trap();
> +	return 0;
>  }



More information about the CRIU mailing list