On 12/17/2012 09:34 PM, Dwight Engen wrote:
> If you start a container with lxc-execute and you do specify a
> configuration with lxc.rootfs set, then lxc attempts to open a console
> for you and in so doing messes up the termio on /dev/tty. This leads to
> the characters being typed not being echoed, and the error message
> "lxc-execute: Input/output error - failed to read". For example:
> 
> lxc-execute -s lxc.rootfs=/ -n bashtest /bin/bash
> 
> The question is, is there a valid use case for lxc-execute + specifying
> a rootfs? It seems like this is not really an intended use, and if not
> I think the following patch should be considered. There is some
> discussion in the bug mentioned below.

Arkose, one of the software I'm upstream for uses lxc-execute with
lxc.rootfs all the time but with lxc.tty = 0 so I don't have the
corruption problem.

The use case is basically running a simple shell inside a container-like
rootfs. In the case of arkose, it basically sets up an overlayfs on top
of your running system, the uses lxc-execute with lxc-init to spawn a
shell or a command into that very minimal container environment.

> ---
> 
> Subject: [PATCH] ignore lxc.rootfs when using lxc-execute
> 
> If lxc.rootfs is specified, lxc_create_console() will create a console for
> the container and set its termio -echo expecting console_handler() to write
> the characters. In the lxc-execute case, these writes fail with EPERM
> (see https://bugs.launchpad.net/ubuntu/+source/lxc/+bug/986956).
> 
> This change implements the last part of (2) from comment 6 of that bug,
> namely to ignore the lxc.rootfs option when using lxc-execute. This makes it
> so that lxc will not attempt to open the console, and thus not change
> the termio of /dev/tty.
> 
> Signed-off-by: Dwight Engen <dwight.en...@oracle.com>
> ---
>  src/lxc/execute.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/src/lxc/execute.c b/src/lxc/execute.c
> index 99800d0..d84baae 100644
> --- a/src/lxc/execute.c
> +++ b/src/lxc/execute.c
> @@ -27,6 +27,7 @@
>  #include <unistd.h>
>  #include <stdlib.h>
>  
> +#include "conf.h"
>  #include "log.h"
>  #include "start.h"
>  
> @@ -137,5 +138,11 @@ int lxc_execute(const char *name, char *const argv[], 
> int quiet,
>       if (lxc_check_inherited(conf, -1))
>               return -1;
>  
> +     if (conf->rootfs.path) {
> +             WARN("rootfs not valid with lxc_execute, ignoring");
> +             free(conf->rootfs.path);
> +             conf->rootfs.path = NULL;
> +     }
> +
>       return __lxc_start(name, conf, &execute_start_ops, &args);
>  }
> 


-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com

Attachment: signature.asc
Description: OpenPGP digital signature

------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Lxc-devel mailing list
Lxc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/lxc-devel

Reply via email to