Commit 1de8adbf authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

tty: Verify active pairs once dump complete

We don't support yet detached terminals migration,
so fail early if we can't proceed.
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Acked-by: 's avatarAndrew Vagin <avagin@parallels.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent a3c886de
......@@ -1630,6 +1630,10 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
if (ret)
goto err;
ret = tty_verify_active_pairs();
if (ret)
goto err;
fd_id_show_tree();
err:
close_cr_fdset(&glob_fdset);
......
......@@ -18,4 +18,6 @@ extern int collect_tty(void);
extern int prepare_shared_tty(void);
extern void tty_setup_slavery(void);
extern int tty_verify_active_pairs(void);
#endif /* CR_TTY_H__ */
......@@ -138,6 +138,29 @@ static int tty_gen_id(int major, int index)
return (index << 1) + (major == TTYAUX_MAJOR);
}
static int tty_get_index(u32 id)
{
return id >> 1;
}
/* Make sure the active pairs do exist */
int tty_verify_active_pairs(void)
{
int i;
for (i = 0; i < (MAX_TTYS << 1); i += 2) {
if (test_bit(i, tty_active_pairs) &&
!test_bit(i + 1, tty_active_pairs)) {
pr_err("Found slave peer index %d without "
"correspond master peer\n",
tty_get_index(i));
return -1;
}
}
return 0;
}
static int parse_index(u32 id, int lfd, int major)
{
int index = -1;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment