All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg Kurz <gkurz-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org>
To: Sukadev Bhattiprolu
	<sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>,
	Dan Smith <danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>,
	Nathan Lynch <nathanl-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org>,
	Containers
	<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>
Subject: Re: C/R and stdio redirection
Date: Wed, 06 Oct 2010 15:43:27 +0200	[thread overview]
Message-ID: <4CAC7CFF.5060109@fr.ibm.com> (raw)
In-Reply-To: <20101006095835.GC30415-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>

  On 10/06/2010 11:58 AM, Louis Rilling wrote:
> On 05/10/10 22:50 -0700, Sukadev Bhattiprolu wrote:
>> Greg Kurz [gkurz-NmTC/0ZBporQT0dZR+AlfA@public.gmane.org] wrote:
>> | On Tue, 2010-09-07 at 13:03 -0700, Sukadev Bhattiprolu wrote:
>> |>  Suppose we create a container and redirect its stdout/stderr as follows:
>> |>
>> |>  	lxc-execute -name foo -- /path/to/app>  /tmp/xyz.out 2>&1
>> |>
>> |>  If we attempt to checkpoint the container 'foo', we fail bc one of the
>> |>  fds in the application refers to /tmp/xyz.out, which is also in use
>> |>  outside the container (specifically sys_checkpoint() fails due to the
>> |>  "alien mount ns" check in ckpt_fill_fname()).
>> |>
>> |>  It can be argued, 'foo' is not a strict container (since it shares the
>> |>  fd with another container).  For this reason, we currently need the
>> |>  CHECKPOINT_SUBTREE flag in lxc-checkpoint.
>> |>
>> |>  We initially thought that solving mount-namespaces will solve this, but
>> |>  realized that they are both separate problems. Mount-namespace C/R addresses
>> |>  preserving the mounts within the container and /tmp/xyz.out is outside
>> |>  the container.
>> |>
>> |>  So if an application container needs to redirect stdio as above, we should
>> |>  either
>> |>  	a) disable/ignore the alien-mount-ns check or
>> |>
>> |>  	b) try and start the application something like:
>> |>
>> |>  		$ cat /tmp/wrapper
>> |>  		/path/to/app>  /tmp/xyz.out 2>&1
>> |>
>> |>  		$ lxc-execute --name foo --  /tmp/wrapper
>> |>
>> |>  with the difference being /tmp/xyz.out is now inside the container's /tmp
>> |>  filesystem rather than in the parent container.
>> |>
>> |>  Maybe we can go with approach 'a' above only if CHECKPOINT_SUBTREE is also
>> |>  set - we had discussed this before and considered it hacky.
>> |>
>> |>  Or are there other solutions to this stdio redirection issue ?
>> |>
>> |
>> | To be more accurate, this issue is about fd leaking from a parent
>> | container to its descendants. The fd numbers may be anything else than
>> | 0,1 or 2 and the underlying files may be regular files, pipes,
>> | sockets... For example, in the HPC world, stdio are often sockets
>> | inheritated from a rshd like daemon.
>>
>> I agree that fd substitution is the right way to go.
>>
>> However, Matt Helsley and I were discussing this and wondered if we should
>> ignore the redirection and expect to user to specify it during restart.
>>
>> i.e if container was created like this:
>>
>> 	lxc-execute -name foo -- /path/to/app>  /tmp/xyz.out 2>&1
>>
>> and checkpointed, can we expect the user to restart it like this ?
>>
>> 	lxc-restart --name foo --statefile ckpt.img>>  /tmp/xyz.out
>>
>> i.e user has to redo the redirection or the output would go to stdout.
>>
>> Doing this would somehow seem to match a (bogus container) like:
>>
>> 	lxc-execute --name foo -- /path/to/app | sort
>>
>> If this container is checkpointed/restarted, we can't really redirect
>> the output of the app to 'sort' right ? So expecting the user to
>> redo the redirection on restart would treat both redirections ('>'
>> and '|') in a consistent way ?
>  From the fd substitution point of view, this means that lxc-restart would
> automatically request the substitution of its stdout to the checkpointed
> container init's stdout?
>

Yes, and this should apply to any inherited file descriptor (not only 
0,1 and 2).

> This sounds reasonable to me at least. Especially since the container is usually
> not supposed to know where the host is redirecting its stdout.
>
> Thanks,
>
> Louis
>
--
Greg

      parent reply	other threads:[~2010-10-06 13:43 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-07 20:03 C/R and stdio redirection Sukadev Bhattiprolu
     [not found] ` <20100907200326.GA22256-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-09-08  8:41   ` Louis Rilling
     [not found]     ` <20100908084152.GC4812-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>
2010-09-08 10:00       ` Greg Kurz
2010-09-08 10:21         ` Louis Rilling
2010-09-08  9:44   ` Greg Kurz
2010-10-06  5:50     ` Sukadev Bhattiprolu
     [not found]       ` <20101006055017.GA22969-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
2010-10-06  9:58         ` Louis Rilling
     [not found]           ` <20101006095835.GC30415-Hu8+6S1rdjywhHL9vcZdMVaTQe2KTcn/@public.gmane.org>
2010-10-06 13:43             ` Greg Kurz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CAC7CFF.5060109@fr.ibm.com \
    --to=gkurz-nmtc/0zbporqt0dzr+alfa@public.gmane.org \
    --cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
    --cc=danms-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org \
    --cc=nathanl-V7BBcbaFuwjMbYB6QlFGEg@public.gmane.org \
    --cc=sukadev-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.