[CRIU] Re: [PATCH 5/5] tty: Add restoration of controlling terminal
v2
Pavel Emelyanov
xemul at parallels.com
Wed Sep 12 03:16:46 EDT 2012
On 09/12/2012 10:58 AM, Cyrill Gorcunov wrote:
>
> The idea behind is pretty simple -- once we find
> that there is a controlling terminal present we
> do call ioctl on appropriate /dev/pts/N.
>
> v2:
> - restore control terminals via service fd,
> still need to speedup service fd retrieval.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> ---
> cr-restore.c | 2 +-
> files.c | 27 ++++++++++++++++++-
> include/crtools.h | 1 +
> include/files.h | 2 +-
> include/pstree.h | 1 +
> include/tty.h | 1 +
> tty.c | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 7 files changed, 106 insertions(+), 3 deletions(-)
>
> @@ -517,6 +560,15 @@ static int tty_open(struct file_desc *d)
>
> }
>
> +int tty_restore_ctl_terminal(struct file_desc *d)
> +{
> + struct tty_info *info = container_of(d, struct tty_info, d);
> +
> + BUG_ON(!(pty_is_master(info)) || !info->tie->sid);
This equals to BUG_ON(!is_master && info->sid). Why non master must NOT have sids?
> +
> + return __tty_restore_ctl_terminal(info);
> +}
> +
> static int tty_transport(FdinfoEntry *fe, struct file_desc *d)
> {
> struct tty_info *info = container_of(d, struct tty_info, d);
> @@ -387,6 +400,12 @@ static int open_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
> return -1;
> }
>
> + if (fle->fe->fd == get_service_fd(CTL_TTY_OFF)) {
> + tty_restore_ctl_terminal(d);
> + close(fle->fe->fd);
> + continue;
> + }
> +
> fcntl(fle->fe->fd, F_SETFD, fle->fe->flags);
>
> continue;
> @@ -424,6 +443,12 @@ static int receive_fd(int pid, FdinfoEntry *fe, struct file_desc *d)
> if (reopen_fd_as(fe->fd, tmp) < 0)
> return -1;
>
> + if (fe->fd == get_service_fd(CTL_TTY_OFF)) {
> + tty_restore_ctl_terminal(d);
> + close(fle->fe->fd);
> + return 0;
> + }
> +
> fcntl(tmp, F_SETFD, fe->flags);
> return 0;
> }
Why not in post_open?
> @@ -131,7 +131,7 @@ static int prepare_shared(void)
> if (ret < 0)
> break;
>
> - ret = prepare_fd_pid(pi->pid.virt, pi->rst);
> + ret = prepare_fd_pid(pi->pid.virt, pi->rst, pi->ctl_tty_id);
> if (ret < 0)
> break;
> }
Better introduce prepare_ctl_tty() call.
More information about the CRIU
mailing list