From: Andrei Vagin <ava...@virtuozzo.com>

Introduce an internal CRIU limit (10Mb) and write a message to syslog.
This message is easily grep-able, so some time later we can grep our
reports from customers and find all those warnings and analyze them.

https://jira.sw.ru/browse/PSBM-68320
---
 criu/Makefile.crtools    |  1 +
 criu/files-reg.c         |  4 ++++
 criu/include/cr-syslog.h | 12 ++++++++++++
 criu/include/log.h       |  2 ++
 criu/syslog.c            | 19 +++++++++++++++++++
 5 files changed, 38 insertions(+)
 create mode 100644 criu/include/cr-syslog.h
 create mode 100644 criu/syslog.c

diff --git a/criu/Makefile.crtools b/criu/Makefile.crtools
index e07c568..2e8785c 100644
--- a/criu/Makefile.crtools
+++ b/criu/Makefile.crtools
@@ -82,6 +82,7 @@ obj-y                 += path.o
 obj-y                  += autofs.o
 obj-y                  += fdstore.o
 obj-y                  += spfs.o
+obj-y                  += syslog.o
 
 ifeq ($(VDSO),y)
 obj-y                  += pie-util-vdso.o
diff --git a/criu/files-reg.c b/criu/files-reg.c
index e7cb566..f7426e9 100644
--- a/criu/files-reg.c
+++ b/criu/files-reg.c
@@ -880,6 +880,10 @@ static int dump_ghost_remap(char *path, const struct stat 
*st,
 {
        pr_info("Dumping ghost file for fd %d id %#x\n", lfd, id);
 
+       if (st->st_size > (10 << 20)) {
+               pr_syslog("Dumping the ghost file %s (%"PRIu64" bytes)\n", 
path, st->st_size);
+       }
+
        if (st->st_size > opts.ghost_limit) {
                pr_err("Can't dump ghost file %s of %"PRIu64" size, increase 
limit\n",
                                path, st->st_size);
diff --git a/criu/include/cr-syslog.h b/criu/include/cr-syslog.h
new file mode 100644
index 0000000..c04b1ed
--- /dev/null
+++ b/criu/include/cr-syslog.h
@@ -0,0 +1,12 @@
+#ifndef __CR_SYSLOG_H__
+#define __CR_SYSLOG_H__
+
+/*
+ * pr_syslog can't be added into log.h, because LOG_* constants
+ * are defined in criu and in <syslog.h>.
+ */
+
+extern void pr_syslog(const char *format, ...);
+
+#endif
+
diff --git a/criu/include/log.h b/criu/include/log.h
index 9c4c283..f6b9ec2 100644
--- a/criu/include/log.h
+++ b/criu/include/log.h
@@ -3,6 +3,8 @@
 
 #include <inttypes.h>
 
+#include "cr-syslog.h"
+
 #ifndef CR_NOGLIBC
 
 #include <string.h>
diff --git a/criu/syslog.c b/criu/syslog.c
new file mode 100644
index 0000000..accefc2
--- /dev/null
+++ b/criu/syslog.c
@@ -0,0 +1,19 @@
+#include <syslog.h>
+#include <stdarg.h>
+
+#include "cr-syslog.h"
+
+void pr_syslog(const char *format, ...)
+{
+       static int open = 0;
+       va_list params;
+
+       if (!open) {
+               open = 1;
+               openlog("criu", LOG_PID, LOG_DAEMON);
+       }
+
+       va_start(params, format);
+       vsyslog(LOG_NOTICE, format, params);
+       va_end(params);
+}
-- 
1.8.3.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to