[CRIU] [PATCH v3 5/7] config: check for CRIU_CONFIG_FILE environment variable
Pavel Emelyanov
xemul at virtuozzo.com
Fri Jul 6 12:33:27 MSK 2018
On 06/28/2018 07:02 PM, Adrian Reber wrote:
> 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.
But how is RPC client supposed to affect CRIU's environment if the latter is
fork-ed and exec-ed by some (Docker/LXD) daemon?
-- Pavel
> 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);
>
More information about the CRIU
mailing list