[CRIU] [PATCH v4 03/12] gc: mock implementation of new gc command
Eugene Batalov
eabatalov89 at gmail.com
Sun Sep 11 10:14:42 PDT 2016
From: Maxim Kuzmin <maxriderg at gmail.com>
gc is a new CRIU command. Its aim is to remove helper objects
needed for restore that were 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.
Dumped ps tree should be dead on criu gc invocation.
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 | 13 +++++++++++++
criu/include/cr_options.h | 1 +
criu/include/crtools.h | 1 +
5 files changed, 22 insertions(+)
create mode 100644 criu/cr-gc.c
diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index 52c00ec..bb13459 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -6,6 +6,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 bcae557..70323f9 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -292,6 +292,7 @@ int main(int argc, char *argv[], char *envp[])
{ "cgroup-dump-controller", required_argument, 0, 1082 },
{ SK_INFLIGHT_PARAM, no_argument, 0, 1083 },
{ "deprecated", no_argument, 0, 1084 },
+ { "show", no_argument, 0, 1085 },
{ },
};
@@ -607,6 +608,9 @@ int main(int argc, char *argv[], char *envp[])
pr_msg("Turn deprecated stuff ON\n");
opts.deprecated_ok = true;
break;
+ case 1085:
+ opts.show = true;
+ break;
case 'V':
pr_msg("Version: %s\n", CRIU_VERSION);
if (strcmp(CRIU_GITID, "0"))
@@ -784,6 +788,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"
@@ -796,6 +803,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"
@@ -808,6 +816,8 @@ 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 deletes helper objects needed for restore that were left\n"
+" in the system after dump. Makes dump not restorable\n"
);
if (usage_error) {
@@ -944,6 +954,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 35748de..01b4fad 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -112,6 +112,7 @@ struct cr_options {
bool lazy_pages;
bool tcp_skip_in_flight;
char *work_dir;
+ bool show;
/*
* When we scheduler for removal some functionality we first
diff --git a/criu/include/crtools.h b/criu/include/crtools.h
index 2aa5e4a..a508215 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);
extern void pr_check_features(const char *offset, const char *sep, int width);
--
1.9.1
More information about the CRIU
mailing list