[CRIU] [PATCH 7/8] tty: Merge tty post actions

Pavel Emelyanov xemul at virtuozzo.com
Thu May 18 02:36:45 PDT 2017


No need to schedule both post-actions, we can merge them. This
also sanitizes the "void *unised" arguments for both.

Signed-off-by: Pavel Emelyanov <xemul at virtuozzo.com>
---
 criu/tty.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/criu/tty.c b/criu/tty.c
index eb6c7e4..7888444 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -372,7 +372,7 @@ static int tty_get_index(u32 id)
 }
 
 /* Make sure the active pairs do exist */
-static int tty_verify_active_pairs(void * unused)
+static int tty_verify_active_pairs(void)
 {
 	unsigned long i, unpaired_slaves = 0;
 
@@ -1360,7 +1360,7 @@ static int tty_setup_orphan_slavery(void)
 	return 0;
 }
 
-static int tty_setup_slavery(void * unused)
+static int tty_setup_slavery(void)
 {
 	struct tty_info *info, *peer, *m;
 
@@ -1556,6 +1556,15 @@ struct collect_image_info tty_info_cinfo = {
 	.collect	= collect_one_tty_info_entry,
 };
 
+static int prep_tty_restore(void *unused)
+{
+	if (tty_verify_active_pairs())
+		return -1;
+	if (tty_setup_slavery())
+		return -1;
+	return 0;
+}
+
 static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 {
 	struct tty_info *info = obj;
@@ -1626,8 +1635,7 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 
 	pr_info("Collected tty ID %#x (%s)\n", info->tfe->id, info->driver->name);
 
-	if (add_post_prepare_cb_once(tty_verify_active_pairs, NULL) ||
-	    add_post_prepare_cb_once(tty_setup_slavery, NULL))
+	if (add_post_prepare_cb_once(prep_tty_restore, NULL))
 		return -1;
 
 	info->fdstore_id = -1;
@@ -2152,7 +2160,7 @@ int tty_post_actions(void)
 {
 	if (tty_verify_ctty())
 		return -1;
-	if (tty_verify_active_pairs(NULL))
+	if (tty_verify_active_pairs())
 		return -1;
 	else if (tty_dump_queued_data())
 		return -1;
-- 
2.1.4



More information about the CRIU mailing list