[CRIU] [PATCH 09/10] deuplication: add auto-dedup option

Pavel Emelyanov xemul at parallels.com
Tue Nov 19 09:41:16 PST 2013


On 11/19/2013 02:28 PM, Tikhomirov Pavel wrote:
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
>  crtools.c         |   22 ++++++++++++++++++----
>  include/crtools.h |    1 +
>  2 files changed, 19 insertions(+), 4 deletions(-)
> 
> diff --git a/crtools.c b/crtools.c
> index d8e8bcb..182d41b 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -126,6 +126,7 @@ int main(int argc, char *argv[])
>  			{ "prev-images-dir", required_argument, 0, 53},
>  			{ "ms", no_argument, 0, 54},
>  			{ "track-mem", no_argument, 0, 55},
> +			{ "auto-dedup", no_argument, 0, 56},
>  			{ },
>  		};
>  
> @@ -269,6 +270,9 @@ int main(int argc, char *argv[])
>  		case 55:
>  			opts.track_mem = true;
>  			break;
> +		case 56:
> +			opts.auto_dedup = true;
> +			break;
>  		case 54:
>  			opts.check_ms_kernel = true;
>  			break;
> @@ -306,7 +310,10 @@ int main(int argc, char *argv[])
>  	if (!strcmp(argv[optind], "dump")) {
>  		if (!tree_id)
>  			goto opt_pid_missing;
> -		return cr_dump_tasks(tree_id);
> +		ret = cr_dump_tasks(tree_id);
> +		if (ret == 0 && !opts.use_page_server && opts.auto_dedup)
> +			return cr_dedup();
> +		return ret;
>  	}
>  
>  	if (!strcmp(argv[optind], "pre-dump")) {
> @@ -323,7 +330,10 @@ int main(int argc, char *argv[])
>  			opts.final_state = TASK_ALIVE;
>  		}
>  
> -		return cr_pre_dump_tasks(tree_id);
> +		ret = cr_pre_dump_tasks(tree_id);
> +		if (ret == 0 && !opts.use_page_server && opts.auto_dedup)
> +			return cr_dedup();
> +		return ret;
>  	}
>  
>  	if (!strcmp(argv[optind], "restore")) {
> @@ -346,8 +356,12 @@ int main(int argc, char *argv[])
>  		return cr_exec(pid, argv + optind + 1);
>  	}
>  
> -	if (!strcmp(argv[optind], "page-server"))
> -		return cr_page_server(opts.restore_detach);
> +	if (!strcmp(argv[optind], "page-server")) {
> +		ret = cr_page_server(opts.restore_detach);
> +		if (ret == 0 && opts.auto_dedup)
> +			return cr_dedup();

Deduplication should occur together with adding pages to snapshot,
i.e. -- added page, punched it from parent. Not after all is done.

> +		return ret;
> +	}
>  
>  	if (!strcmp(argv[optind], "service"))
>  		return cr_service(opts.restore_detach);
> diff --git a/include/crtools.h b/include/crtools.h
> index 679fcb0..428f18a 100644
> --- a/include/crtools.h
> +++ b/include/crtools.h
> @@ -38,6 +38,7 @@ struct cr_options {
>  	char			*addr;
>  	bool			track_mem;
>  	char			*img_parent;
> +	bool			auto_dedup;
>  };
>  
>  extern struct cr_options opts;
> 




More information about the CRIU mailing list