[CRIU] [PATCH 2/2] criu: fix 'criu --version'
Mike Rapoport
rppt at linux.vnet.ibm.com
Thu Apr 26 18:52:18 MSK 2018
Currently kerndat_init() runs before command line parsing and running
simple 'criu --version' command may produce something like:
Warn (criu/kerndat.c:847): Can't load /run/criu.kdat
Error (criu/util.c:842): exited, status=3
Error (criu/util.c:842): exited, status=3
Write 4294967295 to /proc/self/loginuid failed: Operation not permittedWarn
(criu/net.c:2732): Unable to get socket network namespace
Warn (criu/net.c:2732): Unable to get tun network namespace
Warn (criu/sk-unix.c:213): sk unix: Unable to open a socket file:
Operation not permitted
Error (criu/net.c:3023): Unable create a network namespace: Operation not
permitted
Warn (criu/net.c:3069): NSID isn't reported for network links
Version: 3.6
GitID: v3.6-611-g0b27d0a
Group early calls to kerndat_* and init_service_fd calls into a function
and call this function after the command line parsing is finished.
Signed-off-by: Mike Rapoport <rppt at linux.vnet.ibm.com>
---
criu/crtools.c | 60 +++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 36 insertions(+), 24 deletions(-)
diff --git a/criu/crtools.c b/criu/crtools.c
index 0f55edb..26ae8d1 100644
--- a/criu/crtools.c
+++ b/criu/crtools.c
@@ -226,6 +226,35 @@ static void rlimit_unlimit_nofile_self(void)
pr_debug("rlimit: RLIMIT_NOFILE unlimited for self\n");
}
+static int early_init(void)
+{
+ /*
+ * Service fd engine implies that file descritprs
+ * used won't be borrowed by the rest of the code
+ * and default 1024 limit is not enough for high
+ * loaded test/containers. Thus use kdat engine
+ * to fetch current system level limit for numbers
+ * of files allowed to open up and lift up own
+ * limits.
+ *
+ * Note we have to do it before the service fd
+ * get inited and we dont exit with errors here
+ * because in worst scenario where clash of fd
+ * happen we simply exit with explicit error
+ * during real action stage.
+ */
+ if (!kerndat_files_stat(true))
+ rlimit_unlimit_nofile_self();
+
+ if (init_service_fd())
+ return 1;
+
+ if (kerndat_init())
+ return 1;
+
+ return 0;
+}
+
int main(int argc, char *argv[], char *envp[])
{
#define PARSING_GLOBAL_CONF 1
@@ -345,33 +374,13 @@ int main(int argc, char *argv[], char *envp[])
init_opts();
- /*
- * Service fd engine implies that file descritprs
- * used won't be borrowed by the rest of the code
- * and default 1024 limit is not enough for high
- * loaded test/containers. Thus use kdat engine
- * to fetch current system level limit for numbers
- * of files allowed to open up and lift up own
- * limits.
- *
- * Note we have to do it before the service fd
- * get inited and we dont exit with errors here
- * because in worst scenario where clash of fd
- * happen we simply exit with explicit error
- * during real action stage.
- */
- if (!kerndat_files_stat(true))
- rlimit_unlimit_nofile_self();
-
- if (init_service_fd())
- return 1;
-
- if (kerndat_init())
- return 1;
-
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.
@@ -663,6 +672,9 @@ int main(int argc, char *argv[], char *envp[])
}
}
+ if (early_init())
+ return -1;
+
if (opts.deprecated_ok)
pr_msg("Turn deprecated stuff ON\n");
if (opts.tcp_skip_in_flight)
--
2.7.4
More information about the CRIU
mailing list