Commit 3e86fb12 authored by Andrei Vagin's avatar Andrei Vagin

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: 's avatarDmitry Safonov <0x7f454c46@gmail.com>
Acked-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 8338cbc4
...@@ -307,8 +307,6 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -307,8 +307,6 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
goto err; goto err;
} }
print_versions();
/* checking flags from client */ /* checking flags from client */
if (req->has_leave_running && req->leave_running) if (req->has_leave_running && req->leave_running)
opts.final_state = TASK_ALIVE; opts.final_state = TASK_ALIVE;
......
...@@ -727,8 +727,6 @@ int main(int argc, char *argv[], char *envp[]) ...@@ -727,8 +727,6 @@ int main(int argc, char *argv[], char *envp[])
if (log_init(opts.output)) if (log_init(opts.output))
return 1; return 1;
print_versions();
if (opts.deprecated_ok) if (opts.deprecated_ok)
pr_debug("DEPRECATED ON\n"); pr_debug("DEPRECATED ON\n");
......
...@@ -377,6 +377,4 @@ static inline void print_stack_trace(pid_t pid) {} ...@@ -377,6 +377,4 @@ static inline void print_stack_trace(pid_t pid) {}
___ret; \ ___ret; \
}) })
extern void print_versions(void);
#endif /* __CR_UTIL_H__ */ #endif /* __CR_UTIL_H__ */
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/resource.h> #include <sys/resource.h>
#include <sys/utsname.h>
#include <fcntl.h> #include <fcntl.h>
...@@ -20,6 +21,8 @@ ...@@ -20,6 +21,8 @@
#include "rst-malloc.h" #include "rst-malloc.h"
#include "common/lock.h" #include "common/lock.h"
#include "string.h" #include "string.h"
#include "version.h"
#include "../soccr/soccr.h" #include "../soccr/soccr.h"
#include "compel/log.h" #include "compel/log.h"
...@@ -135,6 +138,22 @@ char *log_first_err(void) ...@@ -135,6 +138,22 @@ char *log_first_err(void)
return first_err->s; 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 log_init(const char *output)
{ {
int new_logfd, fd; int new_logfd, fd;
...@@ -167,6 +186,8 @@ int log_init(const char *output) ...@@ -167,6 +186,8 @@ int log_init(const char *output)
if (fd < 0) if (fd < 0)
goto err; goto err;
print_versions();
return 0; return 0;
err: err:
......
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <netinet/tcp.h> #include <netinet/tcp.h>
#include <sched.h> #include <sched.h>
#include <ctype.h> #include <ctype.h>
#include <sys/utsname.h>
#include "bitops.h" #include "bitops.h"
#include "page.h" #include "page.h"
...@@ -54,7 +53,6 @@ ...@@ -54,7 +53,6 @@
#include "cr-service.h" #include "cr-service.h"
#include "files.h" #include "files.h"
#include "pstree.h" #include "pstree.h"
#include "version.h"
#include "cr-errno.h" #include "cr-errno.h"
...@@ -1517,19 +1515,3 @@ void print_stack_trace(pid_t pid) ...@@ -1517,19 +1515,3 @@ void print_stack_trace(pid_t pid)
free(strings); free(strings);
} }
#endif #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);
}
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