Commit Graph

758 Commits

Author SHA1 Message Date
Daniel Lezcano
81c75799cc lxc: enter / exec a command inside a container V2
This patch allows to execute a command or enter inside the container:
  * lxc-attach -n <name> [command]

If the <command is not specified>, the lxc-attach will retrieve your uid
and get your shell name and exec it in the container.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Daniel Lezcano
28a4b0e55c open the console later
Open the console at the setup time, otherwise the openeded
file descriptor will be considered as an inherited fd and the
startup will fail.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Cedric Le Goater
80090207de lxc: forbid open fds upon startup
This patch modifies the startup of a container to forbid opened
fds, unless these are stdios.

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Daniel Lezcano
7d9fb3e9d2 fix kill -1 process
In the process of rollbacking, the handler->pid is not set
we must not kill it. Otherwsise, kill(-1, SIGKILL), ouch ! ...

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-26 21:12:31 +01:00
Daniel Lezcano
d45fdd2707 add console.h to dist file
Add the console.h file in order to compile the dist file.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-26 21:12:31 +01:00
Daniel Lezcano
7fef7a06d8 fix network devices cleanup on error
Delete the network devices when an error occurs before they are moved
to the network namespace (network namespace destruction triggers the
network devices deletion). Otherwise they stay in the system.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-25 10:24:13 +01:00
Daniel Lezcano
c547a83527 fix function prototype implementation
Fix inconsistent function definition regarding the headers.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-25 10:24:13 +01:00
Daniel Lezcano
b9a5bb586c delete network devices by index
Add a function to delete the network device by its index.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-25 10:24:12 +01:00
Daniel Lezcano
6a3111b87e add missing cgroup include
Fix the warning:

start.c: In function ‘lxc_fini’:
start.c:250: warning: implicit declaration of function ‘lxc_unlink_nsgroup’
start.c: In function ‘lxc_spawn’:
start.c:380: warning: implicit declaration of function ‘lxc_rename_nsgroup’

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 16:24:55 +01:00
Silas Sewell
b4f8660eb2 Add missing stat.h include to start.c
The patch fixes a build error on the devel version of Fedora.

Signed-off-by: Silas Sewell <silas@sewell.ch>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 16:24:55 +01:00
Daniel Lezcano
c08556c6ec use lazy umount when umount returns EBUSY
When the umount fails, we force the umount and make the mount point
unaccessible by using a lazy umount.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
1560f6c9a7 fix no rootfs no console
When there is no rootfs, don't create a console.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
e0dc0de76e set terminal settings when console is a tty
As the console output can be a tty, we want to have the terminal to
be set as a specific manner to not echo and receive signals from the
keyboard.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
63376d7db3 allocate a console to be proxied
The actual behaviour of the console is messy as:
 * it relies on a heuristic (tty or not, rootfs or not, etc ...)
 * the container init stole the tty and we lose the control

The following patch:
 * allocates a tty
 * maps this tty to the container console
 * proxy the io from the console to the file specified in the configuration
 lxc.console=<file>

That allows to specify a file, a fifo, a $(tty), and can be extended with an
uri like file://mypath, net://1.2.3.4:1234, etc ...
That solves the problem with the heuristic and the container does no longer stole
our current tty.

Note by default, the console output will go to a blackhole if no configuration is
specified making the container showing nothing.

In order to access the console from the tty, use

 lxc-start -n foo -s lxc.console=$(tty)

I propose the make the container to daemonize by default now.

I tried the following:

 in a shell:
  touch /var/lib/lxc/foo/console
  tail --retry -f /var/lib/lxc/foo/console
 in another shell:
  lxc-start -n foo -s lxc.console=/var/lib/lxc/foo/console

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
246541036c rename network type enum
Use a prefixed enum to avoid conflict later.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
872e18998b Fix header inclusion
No need to include the lxc_conf structure definition, a forward
declaration is enough.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:43 +01:00
Daniel Lezcano
7ee5bb5583 use a mainloop for the console
Use the mainloop to manage io of the console.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:42 +01:00
Daniel Lezcano
6dae681515 factor-out-console code
Factor out the console code and encapsulate the code in
functions.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:42 +01:00
Daniel Lezcano
236087a6c8 fix empty network namespace
When there is an empty network namespace, we must not move the
network device.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:42 +01:00
Daniel Lezcano
90b59fd059 fix compilation warning
Add missing include

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:42 +01:00
Daniel Lezcano
ef184f8c54 fix cpuset configuration with smp only
Do not check CPUSET configuration when SMP is not enabled.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-02-24 10:57:42 +01:00
Daniel Lezcano
9eb09f8721 version 0.6.5
Increment to 0.6.5 version.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-22 11:45:11 +01:00
Daniel Lezcano
7df119eeae unmount failure is not fatal
There are several cases where the system can no longer access a mount
point or a mount point configuration makes the algorithm bogus.

For example, we mount something and then we chroot, the mount information
will give an unaccessible path and the container won't be able to start
because this mount point will be unaccessible. But if it's the case, then
we can just warn and continue running the container.

Another case is the path to a mount point is not accessible because there
is another mount point on top of it hiding the mount point. So the umount
will fail and the container won't start.

Easy to reproduce:

mkdir -p /tmp/dir1/dir2
mount -t tmpfs tmpfs /tmp/dir1/dir2
mount -t tmpfs tmpfs /tmp/dir1

So can we just ignore the error when unmounting and continue to the list again
and again until it shrinks.

At the end, we just display the list of the unmounted points.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-22 11:29:10 +01:00
Michel Normand
bd288c265a compilation warning in confile.c
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-22 11:21:46 +01:00
Michel Normand
b09094da2d Add some define to compile on rhel5u1
the last patch commit 81810dd120
make lxc to not compile anymore on rhel5u1

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-22 11:21:46 +01:00
Daniel Lezcano
1e11be345d fix tab vs space indentation
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 15:15:26 +01:00
Daniel Lezcano
81810dd120 drop capabilities
Hello everyone!

I've written a patch which adds a new config keyword
'lxc.cap.drop'. This keyword allows to specify capabilities which are
dropped before executing the container binary.

Example:

lxc.cap.drop = sys_chroot
lxc.cap.drop = mknod
lxc.cap.drop = sys_module

or specify in a single line:

lxc.cap.drop = sys_chroot mknod sys_module

Reworked-by: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michael Holzt <lxc@my.fqdn.org>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 15:06:42 +01:00
Daniel Lezcano
7674618ce4 add extra line in the busybox script
A mindless change.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 14:45:00 +01:00
Michel Normand
267d974e59 typo in restart and checkpoint
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 14:34:08 +01:00
Michel Normand
96819f4d77 lxc-create to run even if not in PATH
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 14:34:08 +01:00
Michel Normand
3bc15639eb avoid too long line in lxc-busybox.in
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 14:34:08 +01:00
Michel Normand
4357db9a06 add --define to restart V2
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-21 14:34:08 +01:00
Michel Normand
b75afd9089 lxc: typo in scripts/lxc-debian.in
warning with git am, white before tab correction

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-20 11:09:56 +01:00
Greg Kurz
b24319395b lxc: remove useless check
The handler argument to lxc_fini() is never null.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-20 11:09:56 +01:00
Greg Kurz
b79fcd8638 lxc: fix double-close in lxc_[re]spawn() abort path
sv[0] has already been closed when reaching out_abort label.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-20 11:09:56 +01:00
Michel Normand
8b7329af3f lxc: add capabilities for C/R
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-20 11:09:56 +01:00
Clement Calmels
c3e13372aa Remove useless lines
Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-20 11:09:56 +01:00
Greg Kurz
9d7f9e522b lxc: some goto clarification
It makes sense to use goto when there's some rollback work to be done.
And it's nice for code clarity to add an explicit suffix to goto labels.

Signed-off-by: Greg Kurz <gkurz@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-20 11:09:56 +01:00
Michel Normand
79e6830922 lxc: typo white space src/lxc/network.c
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-20 11:09:56 +01:00
Taisuke Yamada
84a24de235 Added -e to lxc-console to change command character (defaults to '^a')
I noticed lxc-console uses '^a' as command-mode prefix to
escape out of console session, so created a patch to make it
configurable. With this, you can do

  lxc-console -n foo -e ^t

and exit the session with 'Ctrl+t q'.

For emacs-binding addicts (like me), it's always nice to
let shell handle '^a' as 'beginning-of-line' command...

Signed-off-by: Taisuke Yamada <tai@rakugaki.org>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-18 23:08:12 +01:00
Clement Calmels
5fa5aa7c6a remove warning in parse.c:80
Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-18 23:08:12 +01:00
Clement Calmels
2382ecffdb use getline instead of fgets
The getline function allocate the needed memory. Fix buffer can lead
to 'hard to find' bug. I don't test the pivot_root part but the other
parts are ok.

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-18 23:08:12 +01:00
Clement Calmels
8eec72f75d free struct dirent **namelist
Correct the way the struct dirent **namelist structure is freed.

Signed-off-by: Clement Calmels <clement.calmels@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-18 23:08:12 +01:00
Daniel Lezcano
226a18d671 fix compilation warning
lxc_config_define_load should an int

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-14 07:43:18 +01:00
Cedric Le Goater
33ba4ad795 lxc: add --define to start
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-14 07:43:18 +01:00
Cedric Le Goater
a31b2048d9 add --define to restart
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-14 07:43:18 +01:00
Cedric Le Goater
201172806c add --define to execute
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-14 07:43:18 +01:00
Cedric Le Goater
62e4603548 add interface to assign configuration variable from the command line
lxc_config_define_add() and lxc_config_define_load() define
the interface to load a list of KEY=VAL buffers in the configuration

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-14 07:43:17 +01:00
Daniel Lezcano
222dcd5443 remove unused variable
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-13 18:51:16 +01:00
Cedric Le Goater
af5b01558c export lxc_config_readline()
lxc_config_readline() will be used to parse configuration variable
assigned from the command line with --define

Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-01-13 18:51:16 +01:00