[CRIU] [PATCH 3/6] tty: Setup tty slavery via post_cb engine

Pavel Emelyanov xemul at virtuozzo.com
Thu Mar 24 06:00:57 PDT 2016


Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/cr-restore.c  |  4 ----
 criu/include/tty.h |  1 -
 criu/tty.c         | 12 +++++++++++-
 3 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/criu/cr-restore.c b/criu/cr-restore.c
index 13e07c5..d446e10 100644
--- a/criu/cr-restore.c
+++ b/criu/cr-restore.c
@@ -271,10 +271,6 @@ static int root_prepare_shared(void)
 	if (ret < 0)
 		goto err;
 
-	ret = tty_setup_slavery();
-	if (ret)
-		goto err;
-
 	ret = prepare_restorer_blob();
 	if (ret)
 		goto err;
diff --git a/criu/include/tty.h b/criu/include/tty.h
index c8b6209..48f743e 100644
--- a/criu/include/tty.h
+++ b/criu/include/tty.h
@@ -22,7 +22,6 @@ extern int dump_verify_tty_sids(void);
 extern struct collect_image_info tty_info_cinfo;
 extern struct collect_image_info tty_cinfo;
 extern int prepare_shared_tty(void);
-extern int tty_setup_slavery(void);
 
 extern int tty_verify_active_pairs(void);
 
diff --git a/criu/tty.c b/criu/tty.c
index ba44af6..fd02227 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -15,6 +15,7 @@
 #include "compiler.h"
 #include "asm/types.h"
 
+#include "crtools.h"
 #include "files.h"
 #include "cr_options.h"
 #include "imgset.h"
@@ -1221,7 +1222,7 @@ static int tty_setup_orphan_slavery(void)
 	return 0;
 }
 
-int tty_setup_slavery(void)
+static int tty_setup_slavery(void * unused)
 {
 	struct tty_info *info, *peer, *m;
 
@@ -1452,6 +1453,15 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg)
 
 	pr_info("Collected tty ID %#x (%s)\n", info->tfe->id, info->driver->name);
 
+	if (list_empty(&all_ttys))
+		/*
+		 * XXX -- not every tty requires this.
+		 * Check that we have such here and queue
+		 * post-cb only if required.
+		 */
+		if (add_post_prepare_cb(tty_setup_slavery, NULL))
+			return -1;
+
 	list_add(&info->list, &all_ttys);
 	return file_desc_add(&info->d, info->tfe->id, &tty_desc_ops);
 }
-- 
2.5.0



More information about the CRIU mailing list