[CRIU] [PATCH 5/5] tty: allocate a separate tty info id for each external tty

Cyrill Gorcunov gorcunov at gmail.com
Fri Sep 21 12:02:39 MSK 2018


On Thu, Sep 20, 2018 at 10:22:38PM +0000, Andrey Vagin wrote:
> Otherwise all external tty-s will share the same tty info,
> what is obviously wrong.
> 
> Cc: Cyrill Gorcunov <gorcunov at openvz.org>
> Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
> ---
>  criu/tty.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/criu/tty.c b/criu/tty.c
> index 214d97a8e..7fd4d86b1 100644
> --- a/criu/tty.c
> +++ b/criu/tty.c
> @@ -2005,6 +2005,7 @@ static int dump_one_tty(int lfd, u32 id, const struct fd_parms *p)
>  	TtyFileEntry e = TTY_FILE_ENTRY__INIT;
>  	int ret = 0, index = -1;
>  	struct tty_driver *driver;
> +	static int idx = 0;
>  
>  	pr_info("Dumping tty %d with id %#x\n", lfd, id);
>  
> @@ -2012,7 +2013,7 @@ static int dump_one_tty(int lfd, u32 id, const struct fd_parms *p)
>  	if (driver->fd_get_index)
>  		index = driver->fd_get_index(lfd, p);
>  	else
> -		index = driver->index;
> +		index = ++idx;
>  
>  	if (index == INDEX_ERR) {
>  		pr_info("Can't obtain index on tty %d id %#x\n", lfd, id);

I think there is an issue: the pty indices are going in pairs starting
from base 0, and here we can suddently overwrite it. Most likely we need
either provide fd_get_index for ext terminals with own numbering base
either simply skip carrying terminus info into image for such terminal
impliying that the caller already configured fd for us.


More information about the CRIU mailing list