[CRIU] [crtools-bot] restore: sync threads

Cyrill Gorcunov gorcunov at openvz.org
Thu Feb 2 11:45:54 EST 2012


The commit is pushed to "master" and will appear on git://github.com/cyrillos/crtools.git
------>
commit e5929ab9711a000d2cb7d16715c00edc880d3bc8
Author: Andrey Vagin <avagin at openvz.org>
Date:   Thu Feb 2 13:38:07 2012 +0300

    restore: sync threads
    
    Use the save mechanosm as for processes.
    
    * Threads should starts together with processes
    * If a thread segfaulted, we should be able to detect it.
    
    Signed-off-by: Andrey Vagin <avagin at openvz.org>
    Acked-by: Pavel Emelyanov <xemul at parallels.com>
    Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-restore.c |    2 +-
 restorer.c   |    7 +++++++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/cr-restore.c b/cr-restore.c
index 7a1021c..12a01e3 100644
--- a/cr-restore.c
+++ b/cr-restore.c
@@ -422,7 +422,7 @@ static int prepare_shared(int ps_fd)
 
 		task_add_pid(e.pid);
 
-		task_entries->nr++;
+		task_entries->nr += e.nr_threads;
 
 		lseek(ps_fd, e.nr_children * sizeof(u32) + e.nr_threads * sizeof(u32), SEEK_CUR);
 	}
diff --git a/restorer.c b/restorer.c
index 5791dc9..f6f2caa 100644
--- a/restorer.c
+++ b/restorer.c
@@ -196,6 +196,13 @@ long restore_thread(struct thread_restore_args *args)
 		 */
 
 		restore_creds(NULL);
+		cr_wait_dec(&task_entries->nr_in_progress);
+
+		write_num(sys_gettid());
+		write_string_n(": Restored");
+
+		cr_wait_while(&task_entries->start, CR_STATE_RESTORE);
+		cr_wait_dec(&task_entries->nr_in_progress);
 
 		new_sp = (long)rt_sigframe + 8;
 		asm volatile(


More information about the CRIU mailing list