[CRIU] [PATCH 11/12] posix-timer: Restore timers, need create and delete 'fake' timers

Pavel Tikhomirov snorcht at gmail.com
Wed May 29 19:36:20 EDT 2013


Signed-off-by: Pavel Tikhomirov <snorcht at gmail.com>
---
 pie/restorer.c |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)

diff --git a/pie/restorer.c b/pie/restorer.c
index 69f0a0d..a367773 100644
--- a/pie/restorer.c
+++ b/pie/restorer.c
@@ -473,6 +473,50 @@ static int vma_remap(unsigned long src, unsigned long dst, unsigned long len)
 	return 0;
 }
 
+static int restore_posix_timers(struct task_restore_core_args *args)
+{
+	int ret = 0;
+	if (args->timer_n > 0) {
+		int i, j;
+		int tmp_id = 0;
+		timer_t timeridt;
+		timer_t timerid;
+		struct sigevent sev;
+		for (i = 0; i < args->timer_n; i++) {
+			for (j = tmp_id; j < args->posix_timers[i].it_id; j++) {
+				ret = sys_timer_create(CLOCK_REALTIME, NULL, &timeridt);
+				if (ret < 0) {
+					pr_err("Can't create temporary posix timer %lx\n", (long) timeridt);
+					return ret;
+				}
+				ret = sys_timer_delete(timeridt);
+				if (ret < 0) {
+					pr_err("Can't remove temporaty posix timer %lx\n", (long) timeridt);
+					return ret;
+				}
+			}
+			sev.sigev_notify = args->posix_timers[i].it_sigev_notify;
+			sev.sigev_signo = args->posix_timers[i].si_signo;
+			sev.sigev_value.sival_ptr = args->posix_timers[i].sival_ptr.p;
+
+			ret = sys_timer_create(args->posix_timers[i].clock_id, &sev, &timerid);
+			if (ret < 0) {
+				pr_err("Can't create posix timer - %d\n", i);
+				return ret;
+			}
+
+			ret = sys_timer_settime(timerid, 0, &args->posix_timers[i].val, NULL);
+			if (ret < 0) {
+				pr_err("Can't set posix timer %lx\n", (long) timerid);
+				return ret;
+			}
+
+			tmp_id = args->posix_timers[i].it_id + 1;
+		}
+	}
+	return 0;
+}
+
 /*
  * The main routine to restore task via sigreturn.
  * This one is very special, we never return there
@@ -839,6 +883,12 @@ long __export_restore_task(struct task_restore_core_args *args)
 		}
 	}
 
+	ret = restore_posix_timers(args);
+	if (ret < 0){
+		pr_err("Can't restore posix timers %ld\n", ret);
+		goto core_restore_end;
+	}
+
 	rst_tcp_socks_all(args->rst_tcp_socks, args->rst_tcp_socks_size);
 
 	/* 
-- 
1.7.9.5



More information about the CRIU mailing list