[CRIU] [PATCH]

Cyrill Gorcunov gorcunov at openvz.org
Thu Sep 13 07:49:31 EDT 2012


While I've not yet implemented support for slaves ttys without master
peers better to  exit with error instead of hanging on restore.

	Cyrill
-------------- next part --------------
>From 9f7ed8fee2aa448b1c7e79d8b29aa1bba4267c45 Mon Sep 17 00:00:00 2001
From: Cyrill Gorcunov <gorcunov at openvz.org>
Date: Thu, 13 Sep 2012 15:30:41 +0400
Subject: [PATCH] tty: Make sure we have paired tty

We can't restore dangling slaves yet.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-dump.c     |    8 ++++++++
 include/tty.h |    1 +
 tty.c         |   17 +++++++++++++++++
 3 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index ee8d233..0c3449d 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1608,6 +1608,14 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
 			goto err;
 	}
 
+	/*
+	 * FIXME
+	 * Drop it once slaves without masters are
+	 * implemented.
+	 */
+	if (tty_check_orphans())
+		goto err;
+
 	if (dump_zombies())
 		goto err;
 
diff --git a/include/tty.h b/include/tty.h
index 2a8f746..43d9f5e 100644
--- a/include/tty.h
+++ b/include/tty.h
@@ -17,5 +17,6 @@ extern int dump_tty(struct fd_parms *p, int lfd, const struct cr_fdset *set);
 extern int collect_tty(void);
 extern int tty_is_master(struct fdinfo_list_entry *le);
 extern int tty_prepare_shared(void);
+extern int tty_check_orphans(void);
 
 #endif /* CR_TTY_H__ */
diff --git a/tty.c b/tty.c
index ae8045c..04a97af 100644
--- a/tty.c
+++ b/tty.c
@@ -196,6 +196,23 @@ static int tty_test_and_set_index(int index)
 	return ret;
 }
 
+int tty_check_orphans(void)
+{
+	int i;
+
+	for (i = 0; i < (MAX_TTYS << 1) - 1; i += 2) {
+		int a = test_bit(i, tty_bitmap);
+		int b = test_bit(i + 1, tty_bitmap);
+
+		if (a && (a ^ b)) {
+			pr_err("Found slave without master\n");
+			return -1;
+		}
+	}
+
+	return 0;
+}
+
 static int pty_open_ptmx_index(int flags, int index)
 {
 	int fds[32], i, ret = -1, cur_idx;
-- 
1.7.7.6



More information about the CRIU mailing list