[CRIU] [PATCH 06/22] parasite: Initialize tid_state_s::real on parasite bootstrap

Pavel Emelyanov xemul at parallels.com
Wed May 15 09:08:18 EDT 2013


On 05/08/2013 05:28 PM, Andrey Vagin wrote:
> From: Cyrill Gorcunov <gorcunov at openvz.org>

Can (should) be merged with patch #5's part adding real on tid state.

> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  include/parasite.h | 1 +
>  parasite-syscall.c | 5 +++++
>  pie/parasite.c     | 7 ++++---
>  3 files changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/include/parasite.h b/include/parasite.h
> index 5e4143c..becee67 100644
> --- a/include/parasite.h
> +++ b/include/parasite.h
> @@ -47,6 +47,7 @@ struct parasite_init_args {
>  	struct sockaddr_un	p_addr;
>  
>  	int			nr_threads;
> +	pid_t			real;
>  };
>  
>  struct parasite_log_args {
> diff --git a/parasite-syscall.c b/parasite-syscall.c
> index 205e41e..505c264 100644
> --- a/parasite-syscall.c
> +++ b/parasite-syscall.c
> @@ -296,6 +296,7 @@ static int parasite_init(struct parasite_ctl *ctl, pid_t pid, int nr_threads)
>  	args->h_addr_len = gen_parasite_saddr(&args->h_addr, getpid());
>  	args->p_addr_len = gen_parasite_saddr(&args->p_addr, pid);
>  	args->nr_threads = nr_threads;
> +	args->real = pid;
>  
>  	if (sock == -1) {
>  		int rst = -1;
> @@ -538,12 +539,16 @@ int parasite_get_proc_fd_seized(struct parasite_ctl *ctl)
>  
>  int parasite_init_threads_seized(struct parasite_ctl *ctl, struct pstree_item *item)
>  {
> +	struct parasite_init_args *args;
>  	int ret = 0, i;
>  
> +	args = parasite_args(ctl, struct parasite_init_args);
> +
>  	for (i = 0; i < item->nr_threads; i++) {
>  		if (item->pid.real == item->threads[i].real)
>  			continue;
>  
> +		args->real = item->threads[i].real;
>  		ret = parasite_execute_trap_by_pid(PARASITE_CMD_INIT_THREAD, ctl,
>  					      item->threads[i].real);
>  		if (ret) {
> diff --git a/pie/parasite.c b/pie/parasite.c
> index e7e6455..93260fe 100644
> --- a/pie/parasite.c
> +++ b/pie/parasite.c
> @@ -211,7 +211,7 @@ static int dump_thread(struct parasite_dump_thread *args)
>  	return 0;
>  }
>  
> -static int init_thread(void)
> +static int init_thread(struct parasite_init_args *args)
>  {
>  	k_rtsigset_t to_block;
>  	int ret;
> @@ -226,6 +226,7 @@ static int init_thread(void)
>  	if (ret >= 0)
>  		tid_state[next_tid_state].use_sig_blocked = true;
>  	tid_state[next_tid_state].tid = sys_gettid();
> +	tid_state[next_tid_state].real = args->real;
>  
>  	next_tid_state++;
>  
> @@ -263,7 +264,7 @@ static int init(struct parasite_init_args *args)
>  
>  	nr_tid_state = args->nr_threads;
>  
> -	ret = init_thread();
> +	ret = init_thread(args);
>  	if (ret < 0)
>  		return ret;
>  
> @@ -435,7 +436,7 @@ int __used parasite_service(unsigned int cmd, void *args)
>  	case PARASITE_CMD_INIT:
>  		return init(args);
>  	case PARASITE_CMD_INIT_THREAD:
> -		return init_thread();
> +		return init_thread(args);
>  	case PARASITE_CMD_FINI:
>  		return fini();
>  	case PARASITE_CMD_FINI_THREAD:
> 




More information about the CRIU mailing list