[CRIU] [PATCH 2/4] deduplication: add dedup comand to criu

Pavel Emelyanov xemul at parallels.com
Thu Oct 10 01:51:42 PDT 2013


On 10/09/2013 06:06 PM, Tikhomirov Pavel wrote:
> 
> Signed-off-by: Tikhomirov Pavel <snorcht at gmail.com>
> ---
>  Makefile.crtools   |    1 +
>  cr-dedup.c         |   17 +++++++++++++++++
>  crtools.c          |    9 +++++++++
>  include/cr-dedup.h |    7 +++++++
>  include/crtools.h  |    1 +
>  5 files changed, 35 insertions(+)
>  create mode 100644 cr-dedup.c
>  create mode 100644 include/cr-dedup.h
> 
> diff --git a/Makefile.crtools b/Makefile.crtools
> index facd8bc..35f2f25 100644
> --- a/Makefile.crtools
> +++ b/Makefile.crtools
> @@ -11,6 +11,7 @@ obj-y	+= proc_parse.o
>  obj-y	+= cr-dump.o
>  obj-y	+= cr-show.o
>  obj-y	+= cr-check.o
> +obj-y	+= cr-dedup.o
>  obj-y	+= util.o
>  obj-y	+= sysctl.o
>  obj-y	+= ptrace.o
> diff --git a/cr-dedup.c b/cr-dedup.c
> new file mode 100644
> index 0000000..aa3c8a2
> --- /dev/null
> +++ b/cr-dedup.c
> @@ -0,0 +1,17 @@
> +#include <sys/time.h>
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <stdarg.h>
> +#include <signal.h>
> +#include <limits.h>
> +#include <unistd.h>
> +#include <errno.h>
> +#include <string.h>
> +
> +#include "crtools.h"
> +#include "cr-dedup.h"
> +
> +int cr_dedup(pid_t pid)
> +{
> +	return 0;
> +}
> diff --git a/crtools.c b/crtools.c
> index 62ec810..cbc236e 100644
> --- a/crtools.c
> +++ b/crtools.c
> @@ -30,6 +30,7 @@
>  #include "tty.h"
>  #include "file-lock.h"
>  #include "cr-service.h"
> +#include "cr-dedup.h"
>  
>  struct cr_options opts;
>  
> @@ -345,6 +346,12 @@ int main(int argc, char *argv[])
>  	if (!strcmp(argv[optind], "service"))
>  		return cr_service(opts.restore_detach);
>  
> +	if (!strcmp(argv[optind], "dedup")) {
> +		if (!tree_id)
> +                        goto opt_pid_missing;

Dedup doesn't need pid to work on. It only needs the directory to
read images from.

> +		return cr_dedup(tree_id);
> +	}
> +
>  	pr_msg("Unknown command \"%s\"\n", argv[optind]);
>  usage:
>  	pr_msg("\n"
> @@ -356,6 +363,7 @@ usage:
>  "  criu exec -p PID <syscall-string>\n"
>  "  criu page-server\n"
>  "  criu service [<options>]\n"
> +"  criu dedup -t PID\n"
>  "\n"
>  "Commands:\n"
>  "  dump           checkpoint a process/tree identified by pid\n"
> @@ -366,6 +374,7 @@ usage:
>  "  exec           execute a system call by other task\n"
>  "  page-server    launch page server\n"
>  "  service        launch service\n"
> +"  dedup          remove dublicates in memory dump\n"
>  	);
>  
>  	if (argc < 2) {
> diff --git a/include/cr-dedup.h b/include/cr-dedup.h
> new file mode 100644
> index 0000000..4a66e03
> --- /dev/null
> +++ b/include/cr-dedup.h
> @@ -0,0 +1,7 @@
> +#ifndef __CR_DEDUP_H__
> +#define __CR_DEDUP_H__
> +
> +int cr_dedup(pid_t pid);
> +
> +#endif
> +
> diff --git a/include/crtools.h b/include/crtools.h
> index bb8a794..f4484a1 100644
> --- a/include/crtools.h
> +++ b/include/crtools.h
> @@ -118,6 +118,7 @@ int cr_show(int pid);
>  int convert_to_elf(char *elf_path, int fd_core);
>  int cr_check(void);
>  int cr_exec(int pid, char **opts);
> +int cr_dedup(pid_t pid);
>  
>  #define O_DUMP	(O_RDWR | O_CREAT | O_EXCL)
>  #define O_SHOW	(O_RDONLY)
> 




More information about the CRIU mailing list