[CRIU] [PATCH v1 02/12] gc: mock implementation of new gc command
Eugene Batalov
eabatalov89 at gmail.com
Wed Jul 27 22:14:38 PDT 2016
From: Maxim Kuzmin <maxriderg at gmail.com>
gc is a new CRIU command. Its aim is to remove objects left
in the system after dump was performed.
Its main use case is to cleanup on node where dump was
performed but restore isn't planned.
CRIU gc accepts dump dir path as an input and removes:
1. Link remaps created for ps tree
2. Netfilter rules that drop ps tree tcp packets
Currently this is all that CRIU dump leaves in the system
--show option changes gc command behavior. It only
shows what was left in the system without objects removal.
Signed-off-by: Eugene Batalov <eabatalov89 at gmail.com>
---
criu/Makefile.crtools | 1 +
criu/cr-gc.c | 6 ++++++
criu/crtools.c | 12 ++++++++++++
criu/include/cr_options.h | 1 +
criu/include/crtools.h | 1 +
5 files changed, 21 insertions(+)
create mode 100644 criu/cr-gc.c
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index 8e9c3b4..8bd0f05 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -7,6 +7,7 @@ obj-y += bitmap.o
obj-y += cgroup.o
obj-y += cgroup-props.o
obj-y += cr-check.o
+obj-y += cr-gc.o
obj-y += cr-dedup.o
obj-y += cr-dump.o
obj-y += cr-errno.o
diff --git a/criu/cr-gc.c b/criu/cr-gc.c
new file mode 100644
index 0000000..bdd3723
--- /dev/null
+++ b/criu/cr-gc.c
@@ -0,0 +1,6 @@
+#include "crtools.h"
+
+int cr_gc(void)
+{
+ return 0;
+}
diff --git a/criu/crtools.c b/criu/crtools.c
index 0102730..63a7aae 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -324,6 +324,7 @@ int main(int argc, char *argv[], char *envp[])
{ "cgroup-props-file", required_argument, 0, 1081 },
{ "cgroup-dump-controller", required_argument, 0, 1082 },
{ SK_INFLIGHT_PARAM, no_argument, 0, 1083 },
+ { "show", no_argument, 0, 1084 },
{ },
};
@@ -639,6 +640,9 @@ int main(int argc, char *argv[], char *envp[])
pr_msg("Will skip in-flight TCP connections\n");
opts.tcp_skip_in_flight = true;
break;
+ case 1084:
+ opts.show = true;
+ break;
case 'V':
pr_msg("Version: %s\n", CRIU_VERSION);
if (strcmp(CRIU_GITID, "0"))
@@ -807,6 +811,9 @@ int main(int argc, char *argv[], char *envp[])
return cpuinfo_check();
}
+ if (!strcmp(argv[optind], "gc"))
+ return cr_gc();
+
pr_msg("Error: unknown command: %s\n", argv[optind]);
usage:
pr_msg("\n"
@@ -819,6 +826,7 @@ usage:
" criu service [<options>]\n"
" criu dedup\n"
" criu lazy-pages -D DIR [<options>]\n"
+" criu gc -D DIR [<options>]\n"
"\n"
"Commands:\n"
" dump checkpoint a process/tree identified by pid\n"
@@ -831,6 +839,7 @@ usage:
" dedup remove duplicates in memory dump\n"
" cpuinfo dump writes cpu information into image file\n"
" cpuinfo check validates cpu information read from image file\n"
+" gc removes what was left in the system after dump\n"
);
if (usage_error) {
@@ -974,6 +983,9 @@ usage:
" --port PORT port of page server\n"
" -d|--daemon run in the background after creating socket\n"
"\n"
+"Garbage collection options:\n"
+" --show show what will be deleted without actual deletion\n"
+"\n"
"Other options:\n"
" -h|--help show this text\n"
" -V|--version show version\n"
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index f6de39e..ee0c969 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -113,6 +113,7 @@ struct cr_options {
bool lazy_pages;
bool tcp_skip_in_flight;
char *work_dir;
+ bool show;
};
extern struct cr_options opts;
diff --git a/criu/include/crtools.h b/criu/include/crtools.h
index f3c9f7f..8f961f0 100644
--- a/criu/include/crtools.h
+++ b/criu/include/crtools.h
@@ -24,6 +24,7 @@ extern int cr_check(void);
extern int cr_exec(int pid, char **opts);
extern int cr_dedup(void);
extern int cr_lazy_pages(void);
+extern int cr_gc(void);
extern int check_add_feature(char *arg);
--
1.9.1
More information about the CRIU
mailing list