[CRIU] [PATCH 2/3] show: Always print informative messages

Cyrill Gorcunov gorcunov at openvz.org
Mon Feb 27 05:03:30 EST 2012


We use pr_info for "show" messages so
adjust log-level accordingly.

Same time "show" should print to stdout
instead of stderr (as it now) -- fix it
as well.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 crtools.c     |    2 ++
 include/log.h |    1 +
 log.c         |    6 ++++++
 3 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/crtools.c b/crtools.c
index fd7c707..47e3413 100644
--- a/crtools.c
+++ b/crtools.c
@@ -399,6 +399,8 @@ int main(int argc, char *argv[])
 		ret = cr_restore_tasks(pid, &opts);
 		break;
 	case 's':
+		set_logfd(STDOUT_FILENO);
+		set_loglevel(LOG_WARN);
 		ret = cr_show(pid, &opts);
 		break;
 	default:
diff --git a/include/log.h b/include/log.h
index 3c8f678..af90e7c 100644
--- a/include/log.h
+++ b/include/log.h
@@ -4,6 +4,7 @@
 extern int init_log(const char *name);
 extern void fini_log(void);
 extern int get_logfd(void);
+extern void set_logfd(int fd);
 
 #define LOG_ERROR	(0) /* Errors only */
 #define LOG_WARN	(1) /* Informative */
diff --git a/log.c b/log.c
index 4072aaa..de37b6b 100644
--- a/log.c
+++ b/log.c
@@ -19,6 +19,12 @@
 /* Note pr_ helpers rely on this descriptor! */
 static int logfd = STDERR_FILENO;
 
+void set_logfd(int fd)
+{
+	fini_log();
+	logfd = fd;
+}
+
 int get_logfd(void)
 {
 	return logfd;
-- 
1.7.7.6



More information about the CRIU mailing list