[CRIU] [PATCH] Add ability to restore with missing sysctls on the target node

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Nov 29 07:35:51 PST 2016


Do it through new --weak-sysctls option to "criu restore".

When we migrate from source with newer kernel with some modern sysctl
to destination with older kernel without it or just with a kernel
configured without it (e.g. no CONFIG_IPV6_ROUTER_PREF), we face a
problem that not all of dumped sysctls can be successfuly restored
on the destination. So to address these problem introduce weak sysctls
migration, where we restore only available sysctls and skip others.

https://github.com/xemul/criu/issues/248

While on it, fix workaround for stable_secret eio skip.

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/crtools.c            | 8 ++++++++
 criu/include/cr_options.h | 1 +
 criu/net.c                | 7 +++++--
 3 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/criu/crtools.c b/criu/crtools.c
index 710059f..65ec947 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -285,6 +285,7 @@ int main(int argc, char *argv[], char *envp[])
 		{ "deprecated",			no_argument,		0, 1084 },
 		{ "check-only",			no_argument,		0, 1085 },
 		{ "display-stats",		no_argument,		0, 1086 },
+		{ "weak-sysctls",		no_argument,		0, 1087 },
 		{ },
 	};
 
@@ -608,6 +609,10 @@ int main(int argc, char *argv[], char *envp[])
 		case 1086:
 			opts.display_stats = true;
 			break;
+		case 1087:
+			pr_msg("Will skip non-existant sysctls on restore\n");
+			opts.weak_sysctls = true;
+			break;
 		case 'V':
 			pr_msg("Version: %s\n", CRIU_VERSION);
 			if (strcmp(CRIU_GITID, "0"))
@@ -841,6 +846,9 @@ int main(int argc, char *argv[], char *envp[])
 "  --check-only          check if checkpointing/restoring will actually work\n"
 "                        the process will keep on running and memory pages\n"
 "                        will not be dumped\n"
+"  --weak-sysctls        silently skip restoring sysctl if it is not available,\n"
+"                        these helps to overcome problems with restore on older\n"
+"                        kernel or with some kernel configuration disabled\n"
 "\n"
 "* External resources support:\n"
 "  --external RES        dump objects from this list as external resources:\n"
diff --git a/criu/include/cr_options.h b/criu/include/cr_options.h
index e017236..38d746c 100644
--- a/criu/include/cr_options.h
+++ b/criu/include/cr_options.h
@@ -118,6 +118,7 @@ struct cr_options {
 	bool			deprecated_ok;
 	bool			display_stats;
 	bool			check_only;
+	bool			weak_sysctls;
 };
 
 extern struct cr_options opts;
diff --git a/criu/net.c b/criu/net.c
index 329c97c..3bf53c5 100644
--- a/criu/net.c
+++ b/criu/net.c
@@ -185,6 +185,9 @@ static int net_conf_op(char *tgt, SysctlEntry **conf, int n, int op, char *proto
 	if (n > size)
 		pr_warn("The image contains unknown sysctl-s\n");
 
+	if (opts.weak_sysctls)
+		flags = CTL_FLAGS_OPTIONAL;
+
 	rconf = xmalloc(sizeof(SysctlEntry *) * size);
 	if (!rconf)
 		return -1;
@@ -216,6 +219,7 @@ static int net_conf_op(char *tgt, SysctlEntry **conf, int n, int op, char *proto
 
 		snprintf(path[i], MAX_CONF_OPT_PATH, CONF_OPT_PATH, proto, tgt, devconfs[i]);
 		req[ri].name = path[i];
+		req[ri].flags = flags;
 		switch (conf[i]->type) {
 			case SYSCTL_TYPE__CTL_32:
 				req[ri].type = CTL_32;
@@ -228,7 +232,7 @@ static int net_conf_op(char *tgt, SysctlEntry **conf, int n, int op, char *proto
 				break;
 			case SYSCTL_TYPE__CTL_STR:
 				req[ri].type = CTL_STR(MAX_STR_CONF_LEN);
-				flags |= op == CTL_READ && !strcmp(devconfs[i], "stable_secret")
+				req[ri].flags |= op == CTL_READ && !strcmp(devconfs[i], "stable_secret")
 					? CTL_FLAGS_READ_EIO_SKIP : 0;
 
 				/* skip non-existing sysctl */
@@ -240,7 +244,6 @@ static int net_conf_op(char *tgt, SysctlEntry **conf, int n, int op, char *proto
 			default:
 				continue;
 		}
-		req[ri].flags = flags;
 		rconf[ri] = conf[i];
 		ri++;
 	}
-- 
2.7.4



More information about the CRIU mailing list