[CRIU] [PATCH] tty: Fix deprecation detection logic

Cyrill Gorcunov gorcunov at openvz.org
Wed Sep 7 11:39:15 PDT 2016


When collecting tty records the @id may come in
as external tty entry which has no regular file
record (because it gonna be inherited on the
restore from the command line option).

Thus, make sure that deprecated_ok() is never
called on external ttys.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
Obviously untested :-)

 criu/tty.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/criu/tty.c b/criu/tty.c
index b1526850aa9f..401b72c83fe5 100644
--- a/criu/tty.c
+++ b/criu/tty.c
@@ -1538,10 +1538,17 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 	 * The image might have no reg file record in old CRIU, so
 	 * lets don't fail for a while. After a couple of releases
 	 * simply require the record to present.
+	 *
+	 * Note for external ttys it's fine to not have any
+	 * reg file rectord because they are inherited from
+	 * command line on restore.
 	 */
 	info->reg_d = try_collect_special_file(info->tfe->id, 1);
 	if (!info->reg_d) {
-		if (!deprecated_ok("TTY w/o regfile"))
+		if (info->driver->type != TTY_TYPE__EXT_TTY) {
+			pr_err("No reg_d descriptor for id %#x\n", info->tfe->id);
+			return -1;
+		} else if (!deprecated_ok("TTY w/o regfile"))
 			return -1;
 
 		if (is_pty(info->driver)) {
@@ -1551,9 +1558,6 @@ static int collect_one_tty(void *obj, ProtobufCMessage *msg, struct cr_img *i)
 				       info->tfe->id);
 				return -1;
 			}
-		} else if (info->driver->type != TTY_TYPE__EXT_TTY) {
-			pr_err("No reg_d descriptor for id %#x\n", info->tfe->id);
-			return -1;
 		}
 	}
 
-- 
2.7.4



More information about the CRIU mailing list