[CRIU] [PATCH 2/5] tty: Get driver for info once

Pavel Emelyanov xemul at virtuozzo.com
Wed Jul 19 14:20:03 MSK 2017


Since we need tty driver for info, we may lookup the guy
when collecting info, not when attaching it to a file.

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

diff --git a/criu/tty.c b/criu/tty.c
index 6ce3eb6..222309b 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1515,6 +1515,7 @@ static int collect_one_tty_info_entry(void *obj, ProtobufCMessage *msg, struct c
 {
 	struct tty_info *info, *n;
 	TtyInfoEntry *tie;
+	struct tty_driver *driver;
 
 	tie = pb_msg(msg, TtyInfoEntry);
 
@@ -1540,11 +1541,19 @@ static int collect_one_tty_info_entry(void *obj, ProtobufCMessage *msg, struct c
 		return -1;
 	}
 
+	driver = get_tty_driver(tie->rdev, tie->dev);
+	if (driver == NULL) {
+		pr_err("Unable to find a tty driver (rdev %#x dev %#x)\n",
+				tie->rdev, tie->dev);
+		return -1;
+	}
+
 	list_for_each_entry_safe(info, n, &collected_ttys, list) {
 		if (info->tfe->tty_info_id != tie->id)
 			continue;
 
 		info->tie = tie;
+		info->driver = driver;
 		list_move_tail(&info->list, &all_ttys);
 
 		if (tty_info_setup(info))
@@ -1589,12 +1598,6 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 static int tty_info_setup(struct tty_info *info)
 {
 	INIT_LIST_HEAD(&info->sibling);
-	info->driver = get_tty_driver(info->tie->rdev, info->tie->dev);
-	if (info->driver == NULL) {
-		pr_err("Unable to find a tty driver (rdev %#x dev %#x)\n",
-		       info->tie->rdev, info->tie->dev);
-		return -1;
-	}
 	info->create = tty_is_master(info);
 	info->inherit = false;
 	info->ctl_tty = NULL;
-- 
2.1.4



More information about the CRIU mailing list