[CRIU] [PATCH 04/10] config: move init_opts() to config.c

Adrian Reber adrian at lisas.de
Wed Aug 1 19:31:16 MSK 2018


From: Adrian Reber <areber at redhat.com>

This just moves the functions init_opts() and deprecated_ok() also to
config.c as that is where most of the option and configuration setup
and handling is done today.

Signed-off-by: Adrian Reber <areber at redhat.com>
---
 criu/config.c  | 36 ++++++++++++++++++++++++++++++++++++
 criu/crtools.c | 36 ------------------------------------
 2 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/criu/config.c b/criu/config.c
index fd192173b..21dc61c3a 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -29,6 +29,8 @@
 
 #include "common/xmalloc.h"
 
+struct cr_options opts;
+
 char **global_conf = NULL;
 char **user_conf = NULL;
 
@@ -219,6 +221,40 @@ static int init_config(int argc, char **argv, int *global_cfg_argc, int *user_cf
 	return 0;
 }
 
+void init_opts(void)
+{
+	memset(&opts, 0, sizeof(opts));
+
+	/* Default options */
+	opts.final_state = TASK_DEAD;
+	INIT_LIST_HEAD(&opts.ext_mounts);
+	INIT_LIST_HEAD(&opts.inherit_fds);
+	INIT_LIST_HEAD(&opts.external);
+	INIT_LIST_HEAD(&opts.join_ns);
+	INIT_LIST_HEAD(&opts.new_cgroup_roots);
+	INIT_LIST_HEAD(&opts.irmap_scan_paths);
+
+	opts.cpu_cap = CPU_CAP_DEFAULT;
+	opts.manage_cgroups = CG_MODE_DEFAULT;
+	opts.ps_socket = -1;
+	opts.ghost_limit = DEFAULT_GHOST_LIMIT;
+	opts.timeout = DEFAULT_TIMEOUT;
+	opts.empty_ns = 0;
+	opts.status_fd = -1;
+	opts.log_level = DEFAULT_LOGLEVEL;
+}
+
+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;
+}
+
 static int parse_cpu_cap(struct cr_options *opts, const char *optarg)
 {
 	bool inverse = false;
diff --git a/criu/crtools.c b/criu/crtools.c
index d300da61e..452bf0624 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -53,42 +53,6 @@
 #include "sysctl.h"
 #include "img-remote.h"
 
-struct cr_options opts;
-
-void init_opts(void)
-{
-	memset(&opts, 0, sizeof(opts));
-
-	/* Default options */
-	opts.final_state = TASK_DEAD;
-	INIT_LIST_HEAD(&opts.ext_mounts);
-	INIT_LIST_HEAD(&opts.inherit_fds);
-	INIT_LIST_HEAD(&opts.external);
-	INIT_LIST_HEAD(&opts.join_ns);
-	INIT_LIST_HEAD(&opts.new_cgroup_roots);
-	INIT_LIST_HEAD(&opts.irmap_scan_paths);
-
-	opts.cpu_cap = CPU_CAP_DEFAULT;
-	opts.manage_cgroups = CG_MODE_DEFAULT;
-	opts.ps_socket = -1;
-	opts.ghost_limit = DEFAULT_GHOST_LIMIT;
-	opts.timeout = DEFAULT_TIMEOUT;
-	opts.empty_ns = 0;
-	opts.status_fd = -1;
-	opts.log_level = DEFAULT_LOGLEVEL;
-}
-
-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;
-}
-
 static void rlimit_unlimit_nofile_self(void)
 {
 	struct rlimit new;
-- 
2.18.0



More information about the CRIU mailing list