[CRIU] [PATCH 4/6] tty: No need to test unpaired slaves if --ext-tty passed

Cyrill Gorcunov gorcunov at openvz.org
Wed Sep 26 09:05:45 EDT 2012


In case if --ext-tty passed we're informed that we should
restore any external slave tty we've met.

The external tty is rather a slave peer connected to some
master peer which doesn't belong any process in our dumpee
process tree.

A typical example -- top session inside bash. The user
might dump only top itself without parent bash process.

Actually this is not encouraged, because if such top
process restore from another bash session -- we simply
can't restore session back loosing controlling terminal
settings.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 cr-dump.c     |    2 +-
 include/tty.h |    3 ++-
 tty.c         |    9 ++++++++-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/cr-dump.c b/cr-dump.c
index 0541e5c..22402f2 100644
--- a/cr-dump.c
+++ b/cr-dump.c
@@ -1630,7 +1630,7 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
 	if (ret)
 		goto err;
 
-	ret = tty_verify_active_pairs();
+	ret = tty_verify_active_pairs(opts);
 	if (ret)
 		goto err;
 
diff --git a/include/tty.h b/include/tty.h
index eccc3f2..982bffb 100644
--- a/include/tty.h
+++ b/include/tty.h
@@ -18,6 +18,7 @@ extern int collect_tty(void);
 extern int prepare_shared_tty(void);
 extern void tty_setup_slavery(void);
 
-extern int tty_verify_active_pairs(void);
+struct cr_options;
+extern int tty_verify_active_pairs(const struct cr_options *opts);
 
 #endif /* CR_TTY_H__ */
diff --git a/tty.c b/tty.c
index ee63273..1ee1b9b 100644
--- a/tty.c
+++ b/tty.c
@@ -144,10 +144,17 @@ static int tty_get_index(u32 id)
 }
 
 /* Make sure the active pairs do exist */
-int tty_verify_active_pairs(void)
+int tty_verify_active_pairs(const struct cr_options *opts)
 {
 	unsigned long i;
 
+	/*
+	 * If we're allowed to connect to external
+	 * master peers -- we can deal with any data.
+	 */
+	if (opts->ext_tty)
+		return 0;
+
 	for (i = 0; i < sizeof(tty_active_pairs); i++) {
 		i = find_next_bit(tty_active_pairs,
 				  sizeof(tty_active_pairs), i);
-- 
1.7.7.6



More information about the CRIU mailing list