Difference between revisions of "Configuration files"

From CRIU
Jump to navigation Jump to search
m (Reword introduction)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== This Page Is Work In Progress - Not Ready ==
 
  
Many of CRIU's command-line options can also be influenced via configuration files. Configuration files are evaluated in [[CLI]] and [[RPC]] mode. It is important to know that configuration files are evaluated before the options set via CLI or RPC. This means that whatever is configured in the configuration files will be overwritten by explicitly set values via CLI or RPC.
+
Many of CRIU's command-line options can also be influenced via configuration files. These files are evaluated in [[CLI]] and [[RPC]] modebefore the options set via CLI or RPC (except for the RPC configuration file). This means that whatever is configured in the files will be overwritten by explicitly set values via CLI or RPC.
  
 
=== Configuration File Location ===
 
=== Configuration File Location ===
The default configuration files parsed by CRIU, it they are present on the system, are first <code>/etc/criu/default.conf</code> and then <code>$HOME/.criu/default.conf</code>. Settings in the file <code>/etc/criu/default.conf</code> are overridden by settings in <code>$HOME/.criu/default.conf</code>.
+
The default configuration files parsed by CRIU, if they are present on the system, are first <code>/etc/criu/default.conf</code> and then <code>$HOME/.criu/default.conf</code>. Settings in the file <code>/etc/criu/default.conf</code> are overridden by settings in <code>$HOME/.criu/default.conf</code>. CRIU also evaluates the configuration file specified via <code>CRIU_CONFIG_FILE</code>.
  
 
Without any additional parameters CRIU configuration file parsing works like this:
 
Without any additional parameters CRIU configuration file parsing works like this:
Line 10: Line 9:
 
# <code>/etc/criu/default.conf</code>; these values can be overridden by
 
# <code>/etc/criu/default.conf</code>; these values can be overridden by
 
# <code>$HOME/.criu/default.conf</code>; these values can be overridden by
 
# <code>$HOME/.criu/default.conf</code>; these values can be overridden by
 +
# <code>CRIU_CONFIG_FILE</code>; these values can be overridden by
 +
# <code>--config FILENAME</code>; these values can be overridden by
 
# CLI or RPC configuration options
 
# CLI or RPC configuration options
 +
# RPC configuration file (only in RPC mode)
  
The user can tell CRIU to completely ignore any configuration file in one of the default locations with the <code>--no-default-config</code> option. In this case the user can still tell CRIU to use a configuration file with the <code>--config FILENAME</code> option. CRIU also honours the environment variable <code>CRIU_CONFIG_FILE</code> just as <code>--config FILENAME</code> option.
+
The user can tell CRIU to completely ignore configuration files in one of the default locations (/etc or $HOME) with the <code>--no-default-config</code> option. In this case the user can still tell CRIU to use a configuration file with the <code>--config FILENAME</code> option. CRIU also honours the environment variable <code>CRIU_CONFIG_FILE</code> just as <code>--config FILENAME</code> option.
  
 
=== Configuration File Syntax ===
 
=== Configuration File Syntax ===
Line 25: Line 27:
  
 
=== Configuration Files in RPC Mode ===
 
=== Configuration Files in RPC Mode ===
As configuration file settings are overridden by CLI and RPC mode, there is a special RPC options which lets configuration file settings override RPC settings. This is different than the normal sequence and can lead to situation which break the RPC client -> CRIU setup. As this can lead to broken setups the RPC client has to explicitly enable this mode: <code>opts.prefer_config_file = True</code>.
+
As configuration file settings are overridden by CLI and RPC mode, there is a special RPC option which let's the RPC user define a configuration file that will overwrite all other configuration file or RPC settings. Using <code>"req.opts.config_file = '/path/to/file'"</code> it is possible to provide such a configuration file that overwrites all other settings.
 +
 
 +
'''This can lead to undesired behavior of criu and should only be used carefully.'''
 +
 
 +
=== Related ===
 +
* [https://github.com/checkpoint-restore/criu/issues/278 CRIU issue #278 : Add /etc/criu.conf and/or /etc/criu.d/ dir]
 +
* [https://github.com/checkpoint-restore/criu/issues/506 CRIU issue #506 : Pass options from docker cli to criu]
  
 
[[Category:CLI]]
 
[[Category:CLI]]
 
[[Category:API]]
 
[[Category:API]]

Latest revision as of 23:56, 26 November 2018

Many of CRIU's command-line options can also be influenced via configuration files. These files are evaluated in CLI and RPC mode, before the options set via CLI or RPC (except for the RPC configuration file). This means that whatever is configured in the files will be overwritten by explicitly set values via CLI or RPC.

Configuration File Location[edit]

The default configuration files parsed by CRIU, if they are present on the system, are first /etc/criu/default.conf and then $HOME/.criu/default.conf. Settings in the file /etc/criu/default.conf are overridden by settings in $HOME/.criu/default.conf. CRIU also evaluates the configuration file specified via CRIU_CONFIG_FILE.

Without any additional parameters CRIU configuration file parsing works like this:

  1. /etc/criu/default.conf; these values can be overridden by
  2. $HOME/.criu/default.conf; these values can be overridden by
  3. CRIU_CONFIG_FILE; these values can be overridden by
  4. --config FILENAME; these values can be overridden by
  5. CLI or RPC configuration options
  6. RPC configuration file (only in RPC mode)

The user can tell CRIU to completely ignore configuration files in one of the default locations (/etc or $HOME) with the --no-default-config option. In this case the user can still tell CRIU to use a configuration file with the --config FILENAME option. CRIU also honours the environment variable CRIU_CONFIG_FILE just as --config FILENAME option.

Configuration File Syntax[edit]

Comments are supported using the '#' character. The rest of the line is ignored. Options are the same as command line options without the '--' prefix, use one option per line (with corresponding argument if applicable, divided by whitespaces). If needed, the argument can be provided in double quotes (this should be needed only if the argument contains whitespaces). In case this type of argument contains a literal double quote as well, it can be escaped using the '\' character. Usage of commands is disallowed and all other escape sequences are interpreted literally.

Example of Configuration File[edit]

$ cat ~/.criu/default.conf
tcp-established
work-dir "/home/USERNAME/criu/my \"work\" directory"
#this is a comment
no-restore-sibling   # this is another comment

Configuration Files in RPC Mode[edit]

As configuration file settings are overridden by CLI and RPC mode, there is a special RPC option which let's the RPC user define a configuration file that will overwrite all other configuration file or RPC settings. Using "req.opts.config_file = '/path/to/file'" it is possible to provide such a configuration file that overwrites all other settings.

This can lead to undesired behavior of criu and should only be used carefully.

Related[edit]