[CRIU] [PATCH CRIU 3/7] log_dirty: add dirty-log.img to save dirty memory pages stats

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Thu Apr 7 06:28:42 PDT 2016


Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 criu/dirty-logger.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/criu/dirty-logger.c b/criu/dirty-logger.c
index 6620626..5e8baa5 100644
--- a/criu/dirty-logger.c
+++ b/criu/dirty-logger.c
@@ -1,6 +1,37 @@
+#include <stdio.h>
+#include <unistd.h>
 #include <pthread.h>
 
+#include "imgset.h"
+
+#define CR_DIRTY_LOG "dirty-log.img"
+
 void *dirty_logger_pthread(void *arg)
 {
+	int fd;
+	FILE *fp;
+	int *pret = (int *)arg;
+
+	fd = openat(get_service_fd(IMG_FD_OFF), CR_DIRTY_LOG, O_DUMP);
+	if (fd == -1) {
+		pr_perror("Failed openat %s", CR_DIRTY_LOG);
+		*pret = -1;
+		pthread_exit(NULL);
+	}
+	pthread_cleanup_push(close, fd);
+
+	fp = fdopen(fd, "w");
+	if (!fp) {
+		pr_perror("Failed fdopen");
+		*pret = -1;
+		pthread_exit(NULL);
+	}
+	pthread_cleanup_push(fclose, fp);
+
+	fprintf(fp, "==== Dirty Log ====\n");
+
+	*pret = 0;
+	pthread_cleanup_pop(1);
+	pthread_cleanup_pop(1);
 	pthread_exit(NULL);
 }
-- 
1.9.3



More information about the CRIU mailing list