[CRIU] Re: [PATCH 11/14] tty: Update tty verification procedure

Cyrill Gorcunov gorcunov at openvz.org
Mon Oct 15 17:22:18 EDT 2012


On Mon, Oct 15, 2012 at 08:03:38PM +0400, Pavel Emelyanov wrote:
> On 10/15/2012 06:54 PM, Cyrill Gorcunov wrote:
> > 
> > We need to make sure that the only one external tty
> > is present, since otherwise we have no idea on which
> > pts index to connect them on restore.
> > 
> > This patch extends tty_verify_active_pairs procedure to
> > count how many external tty is present in the dump image.
> > 
> > Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> > ---
> >  cr-dump.c     |    2 +-
> >  include/tty.h |    2 +-
> >  tty.c         |   23 +++++++++++++++++------
> >  3 files changed, 19 insertions(+), 8 deletions(-)
> > 
> 
> 
> > @@ -1630,7 +1630,7 @@ int cr_dump_tasks(pid_t pid, const struct cr_options *opts)
> >  	if (ret)
> >  		goto err;
> >  
> > -	ret = tty_verify_active_pairs();
> > +	ret = tty_verify_active_pairs(opts->shell_job);
> >  	if (ret)
> >  		goto err;
> >  
> 
> The opts() is _very_ good global variable. Don't scatter its misuse in cr_dump_tasks()
> over other code.

No, you miss the point here -- the tty_verify_active_pairs called in two stages
-- on dump, where we need opts->shell_job to know if external tty is allowed,
and on restore, where it's assumed that if in image we have external tty --
this means that we've been dumping with opts->shell_job.

Ie there are two calls as

	tty_verify_active_pairs(opts->shell_job);
	tty_verify_active_pairs(true)

which is done simply yto eliminate code duplication.


More information about the CRIU mailing list