[CRIU] Re: [PATCH 5/6] tty: Restore orphan slavery peers
Pavel Emelyanov
xemul at parallels.com
Fri Sep 14 08:14:49 EDT 2012
On 09/14/2012 03:48 PM, Cyrill Gorcunov wrote:
> On Fri, Sep 14, 2012 at 03:12:56PM +0400, Pavel Emelyanov wrote:
>> On 09/14/2012 02:38 PM, Cyrill Gorcunov wrote:
>>>
>>> In case if there is no master peer associated
>>> with a slave peer we have two cases
>>>
>>> - the master peer was closed before slave
>>> - we just have no master peer at all, but
>>> only slave one
>>
>> Remove the 2nd case from patch. It should be implemented with
>> Andrey's non-existing sids/pgids.
>
> Here is just first problem only addressed.
> @@ -144,6 +144,10 @@ static int prepare_shared(void)
> goto err;
>
> mark_pipe_master();
> + ret = tty_setup_orphan_slavery(&opts);
Why not call it from collect_tty()?
> + if (ret)
> + goto err;
> +
>
> ret = tty_prepare_shared();
> if (ret)
> @@ -80,6 +80,9 @@ struct tty_info {
>
> struct list_head sibling;
> int major;
> +
> + bool create;
> + bool noparams;
Unused.
> };
>
> static LIST_HEAD(all_tty_info_entries);
> @@ -674,11 +755,13 @@ static int verify_info(struct tty_info *info)
> pr_err("Corrupted slave peer %x\n", info->tfe->id);
> return -1;
> }
> - }
>
> - if (verify_termios(info->tfe->id, info->tie->termios_locked) ||
> - verify_termios(info->tfe->id, info->tie->termios))
> - return -1;
> + info->noparams = true;
> + } else {
> + if (verify_termios(info->tfe->id, info->tie->termios_locked) ||
> + verify_termios(info->tfe->id, info->tie->termios))
> + return -1;
> + }
What the heck is that?
>
> if (!pty_is_master(info)) {
> if (info->tie->sid || info->tie->pgrp)
> +int tty_setup_orphan_slavery(const struct cr_options *opts)
> +{
> + struct tty_info *info, *peer, *m;
> +
> + list_for_each_entry(info, &all_ttys, list) {
> + struct fdinfo_list_entry *a, *b;
> + bool has_leader = false;
> +
> + if (pty_is_master(info))
> + continue;
> +
> + a = file_master(&info->d);
> + m = info;
> +
> + list_for_each_entry(peer, &info->sibling, sibling) {
> + if (pty_is_master(peer)) {
> + has_leader = true;
> + break;
> + }
> +
> + b = file_master(&peer->d);
> + if (a->pid > b->pid ||
> + (a->pid == b->pid && a->fe->fd > b->fe->fd)) {
> + a = b;
> + m = peer;
> + }
> + }
> +
> + /* Here is new one */
> + if (!has_leader) {
> + m->create = true;
> + pr_debug("Found orphan slave fake leader (%#x)\n",
> + m->tfe->id);
> + }
> + }
> +
> + return 0;
Why not do it with tty_setup_slavery?
> +}
> +
More information about the CRIU
mailing list