[CRIU] [PATCH 1/3] dump: Introduce "post-dump" script action

Andrew Vagin avagin at parallels.com
Mon Jul 15 08:58:30 EDT 2013


On Mon, Jul 15, 2013 at 03:49:46PM +0400, Cyrill Gorcunov wrote:
> On Mon, Jul 15, 2013 at 03:42:28PM +0400, Cyrill Gorcunov wrote:
> > 
> > After thinking some more I tend to agree. Letme check if I find some better
> > code. Thanks!
> 
> Something like below? Look, I kept retcode 32 in post-dump.sh since in zdtm
> we will need to find which code criu exited and somehow distinct it from
> error cases, no?
> 
> 	Cyrill

Acked-by: Andrew Vagin <avagin at parallels.com>

Pls, look at one inline comment

> From f7d96439384f015e494495cec63755cc83f794dd Mon Sep 17 00:00:00 2001
> From: Cyrill Gorcunov <gorcunov at openvz.org>
> Date: Fri, 12 Jul 2013 23:08:01 +0400
> Subject: [PATCH] dump: Introduce "post-dump" script action
> 
> This is usefull if one needs to do some final action before checkpoint
> is complete. For example in case of online migration one may provide
> a script which would check the restore procedure on remote note
> ended without errors, thus the script returns zero code and criu
> simply kills running instance of application.
> 
> In turn, if migration failed, the script can return nonzero code
> and criu won't kill the application but continue its execution
> instead.
> 
> https://bugzilla.openvz.org/show_bug.cgi?id=2583
> 
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
>  cr-dump.c | 26 +++++++++++++++++++++++---
>  util.c    |  2 ++
>  2 files changed, 25 insertions(+), 3 deletions(-)
> 
> diff --git a/cr-dump.c b/cr-dump.c
> index 863bffd..13ff6d4 100644
> --- a/cr-dump.c
> +++ b/cr-dump.c
> @@ -1637,6 +1637,7 @@ err:
>  int cr_dump_tasks(pid_t pid)
>  {
>  	struct pstree_item *item;
> +	int post_dump_ret = 0;
>  	int ret = -1;
>  
>  	pr_info("========================================\n");
> @@ -1717,15 +1718,34 @@ int cr_dump_tasks(pid_t pid)
>  err:
>  	close_cr_fdset(&glob_fdset);
>  
> +	if (!ret) {
> +		/*
> +		 * It might be a migration case, where we're asked
> +		 * to dump everything, then some script transfer
> +		 * image on a new node and we're supposed to kill
> +		 * dumpee because it continue running somewhere
> +		 * else.
> +		 *
> +		 * Thus ask user via script if we're to break
> +		 * checkpoint.
> +		 */
> +		post_dump_ret = run_scripts("post-dump");
> +		if (post_dump_ret) {
> +			post_dump_ret = WEXITSTATUS(post_dump_ret);
> +			pr_info("Post dump script passed with %d\n", post_dump_ret);
> +		}
> +	}
> +
>  	/*
>  	 * If we've failed to do anything -- unlock all TCP sockets
>  	 * so that the connections can go on. But if we succeeded --
>  	 * don't, just close them silently.
>  	 */
> -	if (ret)
> +	if (ret || post_dump_ret)
>  		network_unlock();
>  	pstree_switch_state(root_item,
> -			ret ? TASK_ALIVE : opts.final_state);
> +			    (ret || post_dump_ret) ?
> +			    TASK_ALIVE : opts.final_state);
>  	timing_stop(TIME_FROZEN);
>  	free_pstree(root_item);
>  	free_file_locks();
> @@ -1740,5 +1760,5 @@ err:
>  		pr_info("Dumping finished successfully\n");
>  	}
>  
> -	return ret;
> +	return post_dump_ret ? : ret;
>  }
> diff --git a/util.c b/util.c
> index 69ecf5d..74c14ac 100644
> --- a/util.c
> +++ b/util.c
> @@ -1,3 +1,5 @@
> +#define _XOPEN_SOURCE
> +

^^^^ a part of another patch

>  #include <stdlib.h>
>  #include <stdio.h>
>  #include <stdarg.h>
> -- 
> 1.8.1.4
> 



More information about the CRIU mailing list