From 3e86fb12bc37c2fd62365cee595b8a7ebd1ab718 Mon Sep 17 00:00:00 2001 From: Andrei Vagin Date: Fri, 6 Apr 2018 10:27:19 +0300 Subject: [PATCH] criu: print criu and kernel versions from log_init() log_init() opens a log file. We want to have criu and kernel versions in each log file, so it looks reasonable to print them from log_init(). Without this patch, versions are not printed, if criu is called in the swrk mode. Reviewed-by: Dmitry Safonov <0x7f454c46@gmail.com> Acked-by: Adrian Reber Signed-off-by: Andrei Vagin --- criu/cr-service.c | 2 -- criu/crtools.c | 2 -- criu/include/util.h | 2 -- criu/log.c | 21 +++++++++++++++++++++ criu/util.c | 18 ------------------ 5 files changed, 21 insertions(+), 24 deletions(-) diff --git a/criu/cr-service.c b/criu/cr-service.c index d1323dbce..0928df880 100644 --- a/criu/cr-service.c +++ b/criu/cr-service.c @@ -307,8 +307,6 @@ static int setup_opts_from_req(int sk, CriuOpts *req) goto err; } - print_versions(); - /* checking flags from client */ if (req->has_leave_running && req->leave_running) opts.final_state = TASK_ALIVE; diff --git a/criu/crtools.c b/criu/crtools.c index 259580f36..2c3e0c613 100644 --- a/criu/crtools.c +++ b/criu/crtools.c @@ -727,8 +727,6 @@ int main(int argc, char *argv[], char *envp[]) if (log_init(opts.output)) return 1; - print_versions(); - if (opts.deprecated_ok) pr_debug("DEPRECATED ON\n"); diff --git a/criu/include/util.h b/criu/include/util.h index 757defd55..5c18e69f7 100644 --- a/criu/include/util.h +++ b/criu/include/util.h @@ -377,6 +377,4 @@ static inline void print_stack_trace(pid_t pid) {} ___ret; \ }) -extern void print_versions(void); - #endif /* __CR_UTIL_H__ */ diff --git a/criu/log.c b/criu/log.c index 22c6f2950..6a13266eb 100644 --- a/criu/log.c +++ b/criu/log.c @@ -9,6 +9,7 @@ #include #include #include +#include #include @@ -20,6 +21,8 @@ #include "rst-malloc.h" #include "common/lock.h" #include "string.h" +#include "version.h" + #include "../soccr/soccr.h" #include "compel/log.h" @@ -135,6 +138,22 @@ char *log_first_err(void) return first_err->s; } +static void print_versions(void) +{ + struct utsname buf; + + pr_info("Version: %s (gitid %s)\n", CRIU_VERSION, CRIU_GITID); + + if (uname(&buf) < 0) { + pr_perror("Reading kernel version failed!"); + /* This pretty unlikely, just keep on running. */ + return; + } + + pr_info("Running on %s %s %s %s %s\n", buf.nodename, buf.sysname, + buf.release, buf.version, buf.machine); +} + int log_init(const char *output) { int new_logfd, fd; @@ -167,6 +186,8 @@ int log_init(const char *output) if (fd < 0) goto err; + print_versions(); + return 0; err: diff --git a/criu/util.c b/criu/util.c index d6d03a502..cf617bed4 100644 --- a/criu/util.c +++ b/criu/util.c @@ -34,7 +34,6 @@ #include #include #include -#include #include "bitops.h" #include "page.h" @@ -54,7 +53,6 @@ #include "cr-service.h" #include "files.h" #include "pstree.h" -#include "version.h" #include "cr-errno.h" @@ -1517,19 +1515,3 @@ void print_stack_trace(pid_t pid) free(strings); } #endif - -void print_versions(void) -{ - struct utsname buf; - - pr_info("Version: %s (gitid %s)\n", CRIU_VERSION, CRIU_GITID); - - if (uname(&buf) < 0) { - pr_perror("Reading kernel version failed!"); - /* This pretty unlikely, just keep on running. */ - return; - } - - pr_info("Running on %s %s %s %s %s\n", buf.nodename, buf.sysname, - buf.release, buf.version, buf.machine); -}