[v3,4/7] RPC: Evaluate configuration file before switching to RPC mode

Submitted by Adrian Reber on June 28, 2018, 4:02 p.m.

Details

Message ID 1530201754-4493-5-git-send-email-adrian@lisas.de
State New
Series "Series without cover letter"
Headers show

Commit Message

Adrian Reber June 28, 2018, 4:02 p.m.
From: Adrian Reber <areber@redhat.com>

When CRIU is started in RPC mode ('criu swrk') it used to ignore all
command-line options and configuration files. This moves the jump to RPC
mode after the configuration file parsing to enable configuration.

With this configuration files are now also evaluated in RPC mode and it
is possible to change the behavior of CRIU via the configuration file if
used via RPC.

Signed-off-by: Adrian Reber <areber@redhat.com>
---
 criu/crtools.c | 29 +++++++++++++----------------
 1 file changed, 13 insertions(+), 16 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/crtools.c b/criu/crtools.c
index add54e9..66f3ca2 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -383,22 +383,6 @@  int main(int argc, char *argv[], char *envp[])
 
 	init_opts();
 
-	if (!strcmp(argv[1], "swrk")) {
-		if (argc < 3)
-			goto usage;
-
-		if (early_init())
-			return -1;
-
-		/*
-		 * This is to start criu service worker from libcriu calls.
-		 * The usage is "criu swrk <fd>" and is not for CLI/scripts.
-		 * The arguments semantics can change at any time with the
-		 * corresponding lib call change.
-		 */
-		opts.swrk_restore = true;
-		return cr_service_work(atoi(argv[2]));
-	}
 
 	ret = init_config(argc, argv, &global_cfg_argc, &user_cfg_argc,
 			  &usage_error);
@@ -745,6 +729,19 @@  int main(int argc, char *argv[], char *envp[])
 	if (early_init())
 		return -1;
 
+	if (!strcmp(argv[1], "swrk")) {
+		if (argc < 3)
+			goto usage;
+		/*
+		 * This is to start criu service worker from libcriu calls.
+		 * The usage is "criu swrk <fd>" and is not for CLI/scripts.
+		 * The arguments semantics can change at any time with the
+		 * corresponding lib call change.
+		 */
+		opts.swrk_restore = true;
+		return cr_service_work(atoi(argv[2]));
+	}
+
 	if (opts.deprecated_ok)
 		pr_msg("Turn deprecated stuff ON\n");
 	if (opts.tcp_skip_in_flight)