[CRIU] [PATCH 1/2] tty: add vt support, v2

Ruslan Kuprieiev kupruser at gmail.com
Fri Dec 19 08:31:04 PST 2014



19.12.2014 18:05, Pavel Emelyanov пишет:
>
>> diff --git a/tty.c b/tty.c
>> index b076f06..7b184c7 100644
>> --- a/tty.c
>> +++ b/tty.c
>> @@ -118,6 +118,7 @@ static LIST_HEAD(all_ttys);
>>   #define MAX_TTYS	1024
>>   #define MAX_PTY_INDEX	1000
>>   #define CONSOLE_INDEX	1002
>> +#define VT_INDEX	1004
>
> 1004? Why not 1003 or 1005?

Because we need an even number here to check for active
pairs(console and vts have no active pairs, unlike ptys).

>
>>
>>   static DECLARE_BITMAP(tty_bitmap, (MAX_TTYS << 1));
>>   static DECLARE_BITMAP(tty_active_pairs, (MAX_TTYS << 1));
>> @@ -534,13 +547,21 @@ static char *tty_name(int type)
>>   		return "pts";
>>   	case TTY_TYPE_CONSOLE:
>>   		return "console";
>> +	case TTY_TYPE_VT:
>> +		return "tty";
>>   	}
>>   	return "unknown";
>>   }
>>
>>   static bool tty_is_master(struct tty_info *info)
>>   {
>> -	return 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)
>
> Why is !opts.shell_job here?

Because of the way we dump ttys. We dump all of them, write
everything to images and only then checking if we have a session
leader dumped.

When we dump, we are using tty_is_master() as a marker that we need
to create tty on restore. But vt is a master only when we have a
session leader dumped, but we are checking that only after dumping
everything. So, if we don't have a session leader and no --shell-job,
dump will fail as usual. But if we don't have a session leader and have
--shell-job, then we should not create tty on restore.

>
>> +		return true;
>> +
>> +	return false;
>>   }
>>
>>   static bool tty_is_hung(struct tty_info *info)
>


More information about the CRIU mailing list