Re: [lxc-devel] lxc-start-ephemeral: passing a command

2015-09-21 Thread Serge Hallyn
Quoting Christian Brauner (christianvanbrau...@gmail.com):
> On Fri, Sep 18, 2015 at 06:08:30PM +0200, Christian Brauner wrote:
> > When using lxc-start-ephemeral with a command that is supposed to be run in 
> > the
> > container:
> > 
> > lxc-start-ephemeral -o aa /bin/sh
> > 
> > What is the expected behaviour:
> > 
> > 1) Start the container with its normal init process and then run the
> >command in the container?
> > 2) Start the container with just the command running in the 
> > container
> >i.e. similar to lxc-start -n aa -F /bin/sh?

Oh, when I first saw this I thought you were asking about lxc-start vs
lxc-execute, not fg vs bg.

> > I cannot test this since lxc-start-ephemeral does not work (don't know why 
> > yet)
> > on my system. I need to know to think of strategies how to implement this 
> > in C.
> > Option 1) seems kind of hard and I don't know how to smoothly implement 
> > this.
> > 
> > Christian
> 
> The best option seems to be to daemonize the container using
> 
> c->want_daemonize(c, true);
> 
> starting it
> 
> c->start(c, 0, NULL);
> 
> then calling
> 
> c->attach_run_wait(c, /* and so on */);
> 
> to run the command in the container.

Right, since we're making 'ephemeral' a direct property of the container, we
can distinguish the same way as we do for regular containers.  For both fg/bg
and use_init=0/1.

-serge
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel


Re: [lxc-devel] lxc-start-ephemeral: passing a command

2015-09-18 Thread Christian Brauner
On Fri, Sep 18, 2015 at 06:08:30PM +0200, Christian Brauner wrote:
> When using lxc-start-ephemeral with a command that is supposed to be run in 
> the
> container:
> 
> lxc-start-ephemeral -o aa /bin/sh
> 
> What is the expected behaviour:
> 
> 1) Start the container with its normal init process and then run the
>command in the container?
> 2) Start the container with just the command running in the container
>i.e. similar to lxc-start -n aa -F /bin/sh?
> 
> I cannot test this since lxc-start-ephemeral does not work (don't know why 
> yet)
> on my system. I need to know to think of strategies how to implement this in 
> C.
> Option 1) seems kind of hard and I don't know how to smoothly implement this.
> 
> Christian

The best option seems to be to daemonize the container using

c->want_daemonize(c, true);

starting it

c->start(c, 0, NULL);

then calling

c->attach_run_wait(c, /* and so on */);

to run the command in the container.


signature.asc
Description: PGP signature
___
lxc-devel mailing list
lxc-devel@lists.linuxcontainers.org
http://lists.linuxcontainers.org/listinfo/lxc-devel