[lxc-devel] ignore lxc.rootfs when using lxc-execute

Stéphane Graber stgraber at ubuntu.com
Mon Dec 17 20:46:30 UTC 2012


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.engen at 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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 899 bytes
Desc: OpenPGP digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20121217/a6506db6/attachment.pgp>


More information about the lxc-devel mailing list