Commit e18a6d83 authored by Radostin Stoyanov's avatar Radostin Stoyanov Committed by Andrei Vagin

config: Add check_options helper

The purpose of this helper function is to perform actions common to
different interfaces, after all CRIU options have been parsed. This can
be used, for instance, to verify that a specific option was passed to
CRIU via CLI, RPC or config file.
Signed-off-by: 's avatarRadostin Stoyanov <rstoyanov1@gmail.com>
Acked-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@gmail.com>
parent 844a7237
......@@ -802,3 +802,36 @@ bad_arg:
long_opts[idx].name, optarg);
return 1;
}
int check_options()
{
if (opts.tcp_established_ok)
pr_info("Will dump/restore TCP connections\n");
if (opts.tcp_skip_in_flight)
pr_info("Will skip in-flight TCP connections\n");
if (opts.tcp_close)
pr_info("Will drop all TCP connections on restore\n");
if (opts.link_remap_ok)
pr_info("Will allow link remaps on FS\n");
if (opts.weak_sysctls)
pr_info("Will skip non-existant sysctls on restore\n");
if (opts.deprecated_ok)
pr_info("Turn deprecated stuff ON\n");
else if (getenv("CRIU_DEPRECATED")) {
pr_info("Turn deprecated stuff ON via env\n");
opts.deprecated_ok = true;
}
if (!opts.restore_detach && opts.restore_sibling) {
pr_err("--restore-sibling only makes sense with --restore-detach\n");
return 1;
}
if (check_namespace_opts()) {
pr_err("Error: namespace flags conflict\n");
return 1;
}
return 0;
}
......@@ -639,8 +639,6 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (req->orphan_pts_master)
opts.orphan_pts_master = true;
if (check_namespace_opts())
goto err;
/* Evaluate additional configuration file a second time to overwrite
* all RPC settings. */
......@@ -650,7 +648,10 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
if (i)
goto err;
}
log_set_loglevel(opts.log_level);
if (check_options())
goto err;
return 0;
......
......@@ -110,31 +110,8 @@ int main(int argc, char *argv[], char *envp[])
return cr_service_work(atoi(argv[2]));
}
if (opts.deprecated_ok)
pr_msg("Turn deprecated stuff ON\n");
if (opts.tcp_skip_in_flight)
pr_msg("Will skip in-flight TCP connections\n");
if (opts.tcp_established_ok)
pr_info("Will dump TCP connections\n");
if (opts.link_remap_ok)
pr_info("Will allow link remaps on FS\n");
if (opts.weak_sysctls)
pr_msg("Will skip non-existant sysctls on restore\n");
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 conflict\n");
if (check_options())
return 1;
}
if (!opts.restore_detach && opts.restore_sibling) {
pr_msg("--restore-sibling only makes sense with --restore-detach\n");
return 1;
}
if (opts.imgs_dir == NULL)
SET_CHAR_OPTS(imgs_dir, ".");
......
......@@ -144,6 +144,7 @@ extern struct cr_options opts;
char *rpc_cfg_file;
extern int parse_options(int argc, char **argv, bool *usage_error, bool *has_exec_cmd, int state);
extern int check_options();
extern void init_opts();
#endif /* __CR_OPTIONS_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment