Commit 5340807b authored by Cyrill Gorcunov's avatar Cyrill Gorcunov Committed by Pavel Emelyanov

Add separate list for slave tty fds on restore v2

When we will be restoring ttys we need that restore
procedure for master peers will be yielded earlier
than for slave peers due to ttys specifics. With this
commit we introduce @tty_slaves list which will allow
us to order tty file restore procesure.

Because we need to fetch which list to be used depending
on tty type this patch extend select_ps_list with fdinfo_list_entry
parameter.

v2 (by xemul@):
 - make sure the epoll list is still last
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent e3afdd0f
...@@ -147,7 +147,7 @@ int rst_file_params(int fd, FownEntry *fown, int flags) ...@@ -147,7 +147,7 @@ int rst_file_params(int fd, FownEntry *fown, int flags)
return 0; return 0;
} }
static struct list_head *select_ps_list(int type, struct rst_info *ri) static struct list_head *select_ps_list(int type, struct fdinfo_list_entry *le, struct rst_info *ri)
{ {
switch (type) { switch (type) {
case FD_TYPES__EVENTPOLL: case FD_TYPES__EVENTPOLL:
...@@ -186,7 +186,7 @@ static int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info) ...@@ -186,7 +186,7 @@ static int collect_fd(int pid, FdinfoEntry *e, struct rst_info *rst_info)
list_add_tail(&new_le->desc_list, &le->desc_list); list_add_tail(&new_le->desc_list, &le->desc_list);
new_le->desc = fdesc; new_le->desc = fdesc;
list_add_tail(&new_le->ps_list, select_ps_list(e->type, rst_info)); list_add_tail(&new_le->ps_list, select_ps_list(e->type, new_le, rst_info));
return 0; return 0;
} }
...@@ -197,6 +197,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info) ...@@ -197,6 +197,7 @@ int prepare_fd_pid(int pid, struct rst_info *rst_info)
INIT_LIST_HEAD(&rst_info->fds); INIT_LIST_HEAD(&rst_info->fds);
INIT_LIST_HEAD(&rst_info->eventpoll); INIT_LIST_HEAD(&rst_info->eventpoll);
INIT_LIST_HEAD(&rst_info->tty_slaves);
fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid); fdinfo_fd = open_image_ro(CR_FD_FDINFO, pid);
if (fdinfo_fd < 0) { if (fdinfo_fd < 0) {
...@@ -508,6 +509,14 @@ int prepare_fds(struct pstree_item *me) ...@@ -508,6 +509,14 @@ int prepare_fds(struct pstree_item *me)
if (ret) if (ret)
break; break;
/*
* Now handle TTYs. Slaves are delayed to be sure masters
* are already opened.
*/
ret = open_fdinfos(me->pid.virt, &me->rst->tty_slaves, state);
if (ret)
break;
/* /*
* The eventpoll descriptors require all the other ones * The eventpoll descriptors require all the other ones
* to be already restored, thus we store them in a separate * to be already restored, thus we store them in a separate
......
...@@ -199,6 +199,7 @@ struct vma_area { ...@@ -199,6 +199,7 @@ struct vma_area {
struct rst_info { struct rst_info {
struct list_head fds; struct list_head fds;
struct list_head eventpoll; struct list_head eventpoll;
struct list_head tty_slaves;
}; };
struct pid struct pid
......
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