[CRIU] [PATCH 08/15] service: don't include pstree.h

Pavel Emelyanov xemul at parallels.com
Wed Nov 6 00:42:24 PST 2013


On 11/05/2013 12:33 PM, Andrey Vagin wrote:
> and don't try to send response, if tasks are not restored.

The "and" in separate patch please.

> Signed-off-by: Andrey Vagin <avagin at openvz.org>
> ---
>  cr-restore.c | 8 ++++++--
>  cr-service.c | 9 +++++----
>  crtools.c    | 2 +-
>  3 files changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/cr-restore.c b/cr-restore.c
> index 761da9d..3b2208a 100644
> --- a/cr-restore.c
> +++ b/cr-restore.c
> @@ -1448,6 +1448,7 @@ detach:
>  	}
>  }
>  
> +/* This function returns pid of the root task in success case. */
>  static int restore_root_task(struct pstree_item *init)
>  {
>  	int ret, fd;
> @@ -1594,7 +1595,7 @@ out_kill:
>  out:
>  	__restore_switch_stage(CR_STATE_FAIL);
>  	pr_err("Restoring FAILED.\n");
> -	return 1;
> +	return -1;
>  }
>  
>  static int prepare_task_entries()
> @@ -1641,7 +1642,10 @@ int cr_restore_tasks(void)
>  	if (crtools_prepare_shared() < 0)
>  		return -1;
>  
> -	return restore_root_task(root_item);
> +	if (restore_root_task(root_item))
> +		return -1;
> +
> +	return root_item->pid.real;
>  }
>  
>  static long restorer_get_vma_hint(pid_t pid, struct list_head *tgt_vma_list,
> diff --git a/cr-service.c b/cr-service.c
> index 510553f..f61e4d3 100644
> --- a/cr-service.c
> +++ b/cr-service.c
> @@ -16,7 +16,6 @@
>  #include "crtools.h"
>  #include "util-pie.h"
>  #include "log.h"
> -#include "pstree.h"

What's wrong in having pstree in cr-service?

>  #include "cr-service.h"
>  
>  unsigned int service_sk_ino = -1;
> @@ -190,6 +189,7 @@ exit:
>  
>  static int restore_using_req(int sk, CriuOpts *req)
>  {
> +	int pid;
>  	bool success = false;
>  
>  	/*
> @@ -205,16 +205,17 @@ static int restore_using_req(int sk, CriuOpts *req)
>  		goto exit;
>  	}
>  
> -	if (cr_restore_tasks())
> +	pid = cr_restore_tasks();
> +	if (pid < 0)
>  		goto exit;
>  
>  	success = true;
> -exit:
> -	if (send_criu_restore_resp(sk, success, root_item->pid.real) == -1) {
> +	if (send_criu_restore_resp(sk, success, pid) == -1) {
>  		pr_perror("Can't send response");
>  		success = false;
>  	}
>  
> +exit:
>  	return success ? 0 : 1;
>  }
>  
> diff --git a/crtools.c b/crtools.c
> index 3b2919b..66d207c 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -329,7 +329,7 @@ int main(int argc, char *argv[])
>  	if (!strcmp(argv[optind], "restore")) {
>  		if (tree_id)
>  			pr_warn("Using -t with criu restore is obsoleted\n");
> -		return cr_restore_tasks();
> +		return cr_restore_tasks() < 0 ? 1 : 0;

Ugly :(

>  	}
>  
>  	if (!strcmp(argv[optind], "show"))
> 




More information about the CRIU mailing list