[CRIU] [PATCH 1/2] criu: Introduce the --deprecated/CRIU_DEPRECATED option

Pavel Emelyanov xemul at virtuozzo.com
Fri Aug 12 04:08:49 PDT 2016


This is the option that would enable the deprecated (to be removed)
functionality. For convenience it's also possible to set one via
the environment.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/crtools.c            | 23 +++++++++++++++++++++++
 criu/include/cr_options.h |  8 ++++++++
 criu/include/crtools.h    |  2 +-
 3 files changed, 32 insertions(+), 1 deletion(-)

diff --git a/criu/crtools.c b/criu/crtools.c
index 7e11c22..bde8a48 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -249,6 +249,17 @@ int add_external(char *key)
 	return 0;
 }
 
+bool deprecated_ok(char *what)
+{
+	if (opts.deprecated_ok)
+		return true;
+
+	pr_err("Deprecated functionality (%s) rejected.\n", what);
+	pr_err("Use the --deprecated option or set CRIU_DEPRECATED environment.\n");
+	pr_err("For details visit https://criu.org/Deprecation\n");
+	return false;
+}
+
 int main(int argc, char *argv[], char *envp[])
 {
 	pid_t pid = 0, tree_id = 0;
@@ -324,6 +335,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	},
+		{ "deprecated",			no_argument,		0, 1084 },
 		{ },
 	};
 
@@ -639,6 +651,10 @@ 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 1094:
+			pr_msg("Turn deprecated stuff ON\n");
+			opts.deprecated_ok = true;
+			break;
 		case 'V':
 			pr_msg("Version: %s\n", CRIU_VERSION);
 			if (strcmp(CRIU_GITID, "0"))
@@ -652,6 +668,11 @@ int main(int argc, char *argv[], char *envp[])
 		}
 	}
 
+	if (getenv("CRIU_DEPRECATED")) {
+		pr_msg("Turn deprecated stuff ON via env\n");
+		opts.deprecated_ok = true;
+	}
+
 	if (check_namespace_opts()) {
 		pr_msg("Error: namespace flags confict\n");
 		return 1;
@@ -726,6 +747,8 @@ int main(int argc, char *argv[], char *envp[])
 		return 1;
 
 	pr_debug("Version: %s (gitid %s)\n", CRIU_VERSION, CRIU_GITID);
+	if (opts.deprecated_ok)
+		pr_debug("DEPRECATED ON\n");
 
 	if (!list_empty(&opts.inherit_fds)) {
 		if (strcmp(argv[optind], "restore")) {
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index 35c1ace..cd27ec4 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -113,6 +113,14 @@ struct cr_options {
 	bool			lazy_pages;
 	bool			tcp_skip_in_flight;
 	char			*work_dir;
+
+	/*
+	 * When we scheduler for removal some functionality we first
+	 * deprecate it and it sits in criu for some time. By default
+	 * the deprecated stuff is not working, but it's still possible
+	 * to turn one ON while the code is in.
+	 */
+	bool			deprecated_ok;
 };
 
 extern struct cr_options opts;
diff --git a/criu/include/crtools.h b/criu/include/crtools.h
index f3c9f7f..878e6a1 100644
--- a/criu/include/crtools.h
+++ b/criu/include/crtools.h
@@ -15,7 +15,7 @@ extern int check_img_inventory(void);
 extern int write_img_inventory(InventoryEntry *he);
 extern int prepare_inventory(InventoryEntry *he);
 extern int add_post_prepare_cb(int (*actor)(void *data), void *data);
-
+extern bool deprecated_ok(char *what);
 extern int cr_dump_tasks(pid_t pid);
 extern int cr_pre_dump_tasks(pid_t pid);
 extern int cr_restore_tasks(void);
-- 
2.5.0



More information about the CRIU mailing list