[CRIU] [PATCH v3 5/7] config: check for CRIU_CONFIG_FILE environment variable
Adrian Reber
adrian at lisas.de
Thu Jun 28 19:02:32 MSK 2018
From: Adrian Reber <areber at redhat.com>
To be able to influence, especially via RPC, that another configuration
file should be used, this introduces the environment variable
CRIU_CONFIG_FILE.
If set, the file it points to will be used instead of the default
configuration files and also instead of the configuration file specified
via the command-line.
CRIU now first checks for CRIU_CONFIG_FILE and uses that, if that is not
set it looks for '--config FILEPATH' and uses that, if that is not set
it uses the default configuration files.
The idea behind this option is that now it is possible for an RPC client
to set CRIU_CONFIG_FILE and also set the RPC option
opts.prefer_config_file to tell CRIU to prefer the options from a
non-default configuration file over the options set via RPC.
Signed-off-by: Adrian Reber <areber at redhat.com>
---
criu/config.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/criu/config.c b/criu/config.c
index f3bf35b..d764832 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -157,6 +157,7 @@ int init_config(int argc, char **argv, int *global_cfg_argc, int *user_cfg_argc,
{
bool no_default_config = false;
char *cfg_file = NULL;
+ char *cfg_from_env = getenv("CRIU_CONFIG_FILE");
int i;
/*
@@ -188,6 +189,14 @@ int init_config(int argc, char **argv, int *global_cfg_argc, int *user_cfg_argc,
}
}
+ /*
+ * If the environment variable CRIU_CONFIG_FILE is set it
+ * will overwrite the configuration file set via '--config'.
+ */
+
+ if (cfg_from_env)
+ cfg_file = cfg_from_env;
+
init_configuration(argc, argv, no_default_config, cfg_file);
if (global_conf != NULL)
*global_cfg_argc = count_elements(global_conf);
--
1.8.3.1
More information about the CRIU
mailing list