[CRIU] Shell Dump Failure Question
Cyrill Gorcunov
gorcunov at gmail.com
Wed Feb 18 01:58:43 PST 2015
On Tue, Feb 17, 2015 at 01:51:12PM -0800, Saied Kazemi wrote:
> Thank you for your fast response and analysis! Please let me know if you
> need any additional information.
Saied, could you please give the patch attached a shot?
-------------- next part --------------
diff --git a/include/tty.h b/include/tty.h
index bb01d90d22a0..fa2633a33215 100644
--- a/include/tty.h
+++ b/include/tty.h
@@ -15,6 +15,7 @@ enum {
TTY_TYPE_PTS = 2,
TTY_TYPE_CONSOLE = 3,
TTY_TYPE_VT = 4,
+ TTY_TYPE_CTTY = 5,
TTY_TYPE_MAX
};
@@ -31,10 +32,12 @@ static inline int tty_type(int major, int minor)
{
switch (major) {
case TTYAUX_MAJOR:
- if (minor == 0 || minor == 2)
- return TTY_TYPE_PTM;
+ if (minor == 0)
+ return TTY_TYPE_CTTY;
else if (minor == 1)
return TTY_TYPE_CONSOLE;
+ else if (minor == 2)
+ return TTY_TYPE_PTM;
break;
case TTY_MAJOR:
if (minor > MIN_NR_CONSOLES && minor < MAX_NR_CONSOLES)
diff --git a/protobuf/tty.proto b/protobuf/tty.proto
index d4afe0642806..9da840c6e02b 100644
--- a/protobuf/tty.proto
+++ b/protobuf/tty.proto
@@ -29,6 +29,7 @@ enum TtyType {
PTY = 1;
CONSOLE = 2;
VT = 3;
+ CTTY = 4;
}
message tty_info_entry {
diff --git a/tty.c b/tty.c
index 01d8c3ea86b0..33e10f03bd50 100644
--- a/tty.c
+++ b/tty.c
@@ -126,6 +126,7 @@ static LIST_HEAD(all_ttys);
#define MAX_PTY_INDEX 1000
#define CONSOLE_INDEX 1002
#define VT_INDEX 1004
+#define CTTY_INDEX 1006
static DECLARE_BITMAP(tty_bitmap, (MAX_TTYS << 1));
static DECLARE_BITMAP(tty_active_pairs, (MAX_TTYS << 1));
@@ -247,12 +248,18 @@ static int parse_tty_index(u32 id, int lfd, const struct fd_parms *p, int type)
case TTY_TYPE_VT:
index = VT_INDEX;
break;
+
+ case TTY_TYPE_CTTY:
+ index = CTTY_INDEX;
+ break;
+
default:
BUG();
}
if (type != TTY_TYPE_CONSOLE &&
type != TTY_TYPE_VT &&
+ type != TTY_TYPE_CTTY &&
index > MAX_PTY_INDEX) {
pr_err("Index %d on tty %x is too big\n", index, id);
return -1;
@@ -522,6 +529,13 @@ static int tty_restore_ctl_terminal(struct file_desc *d, int fd)
pr_perror("Can't open %s", path_from_reg(info->reg_d));
goto err;
}
+ } else if (info->type == TTY_TYPE_CTTY) {
+ slave = open_pty_reg(info->reg_d, O_RDONLY);
+ index = CTTY_INDEX;
+ if (slave < 0) {
+ pr_perror("Can't open %s", path_from_reg(info->reg_d));
+ goto err;
+ }
} else if (info->type == TTY_TYPE_VT) {
slave = open_pty_reg(info->reg_d, O_RDONLY);
index = VT_INDEX;
@@ -556,6 +570,8 @@ static char *tty_name(int type)
case TTY_TYPE_CONSOLE:
return "console";
case TTY_TYPE_VT:
+ return "vt";
+ case TTY_TYPE_CTTY:
return "tty";
}
return "unknown";
@@ -563,12 +579,16 @@ static char *tty_name(int type)
static bool tty_is_master(struct tty_info *info)
{
- if (info->type == TTY_TYPE_PTM || info->type == TTY_TYPE_CONSOLE)
+ if (info->type == TTY_TYPE_PTM ||
+ info->type == TTY_TYPE_CONSOLE)
return true;
if (info->type == TTY_TYPE_VT && !opts.shell_job)
return true;
+ if (info->type == TTY_TYPE_CTTY && !opts.shell_job)
+ return true;
+
return false;
}
@@ -593,6 +613,9 @@ static void tty_show_pty_info(char *prefix, struct tty_info *info)
case TTY_TYPE_CONSOLE:
index = CONSOLE_INDEX;
break;
+ case TTY_TYPE_CTTY:
+ index = CTTY_INDEX;
+ break;
case TTY_TYPE_VT:
index = VT_INDEX;
break;
@@ -879,7 +902,7 @@ static int open_simple_tty(struct tty_info *info)
fd = open_pty_reg(info->reg_d, info->tfe->flags);
if (fd < 0) {
pr_perror("Can't open %s %x",
- info->type == TTY_TYPE_CONSOLE ? "console" : "virtual terminal",
+ tty_name(info->type),
info->tfe->id);
return -1;
}
@@ -905,7 +928,7 @@ static int tty_open(struct file_desc *d)
if (!tty_is_master(info))
return pty_open_unpaired_slave(d, info);
- if (info->type == TTY_TYPE_CONSOLE || info->type == TTY_TYPE_VT)
+ if (info->type == TTY_TYPE_CONSOLE || info->type == TTY_TYPE_VT || info->type == TTY_TYPE_CTTY)
return open_simple_tty(info);
return pty_open_ptmx(info);
@@ -1087,12 +1110,16 @@ int tty_setup_slavery(void)
list_for_each_entry(info, &all_ttys, list) {
if (tty_find_restoring_task(info))
return -1;
- if (info->type == TTY_TYPE_CONSOLE || info->type == TTY_TYPE_VT)
+ if (info->type == TTY_TYPE_CONSOLE ||
+ info->type == TTY_TYPE_VT ||
+ info->type == TTY_TYPE_CTTY)
continue;
peer = info;
list_for_each_entry_safe_continue(peer, m, &all_ttys, list) {
- if (peer->type == TTY_TYPE_CONSOLE || info->type == TTY_TYPE_VT)
+ if (peer->type == TTY_TYPE_CONSOLE ||
+ peer->type == TTY_TYPE_VT ||
+ peer->type == TTY_TYPE_CTTY)
continue;
if (peer->tie->pty->index != info->tie->pty->index)
continue;
@@ -1143,6 +1170,7 @@ static int verify_info(struct tty_info *info)
if (info->type != TTY_TYPE_PTM &&
info->type != TTY_TYPE_PTS &&
info->type != TTY_TYPE_CONSOLE &&
+ info->type != TTY_TYPE_CTTY &&
info->type != TTY_TYPE_VT) {
pr_err("Unknown type %d master peer %x\n",
info->type, info->tfe->id);
@@ -1201,6 +1229,7 @@ static int collect_one_tty_info_entry(void *obj, ProtobufCMessage *msg)
}
break;
case TTY_TYPE__CONSOLE:
+ case TTY_TYPE__CTTY:
case TTY_TYPE__VT:
if (info->tie->pty) {
pr_err("PTY data found (id %x), corrupted image?\n",
@@ -1402,6 +1431,9 @@ static int dump_tty_info(int lfd, u32 id, const struct fd_parms *p, int type, in
case TTY_TYPE_VT:
info.type = TTY_TYPE__VT;
break;
+ case TTY_TYPE_CTTY:
+ info.type = TTY_TYPE__CTTY;
+ break;
default:
BUG();
}
More information about the CRIU
mailing list