Commit Graph

582 Commits

Author SHA1 Message Date
Michel Normand
becc0400fc man update lxc-create lxc-destroy
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
94b81f611f man update lxc-execute and lxc-start (V2)
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
a941cc0bf6 man update lxc
update lxc man page to better explain:
* the notions of persistent and volatil container.
* the difference between lxc-execute and lxc-start commands

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
d72d3d7b16 lxc: add usage and help to lxc-netstat (V2)
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
b89885d896 lxc: lxc-unshare to remove its /cgroup/<pid> (V3)
this is required to avoid to fill /cgroup
with pid number each time lxc-unshare is called.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
dcb7e5d5d2 remove unused _config_console function
it's usage was removed by patch
28a4b0e55c
"open the console later"

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
26b2d15268 get_init_pid moved to lxc/commands.c
as will be used later on in other patches.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
501cbc717f report error if statefd parm is not a digit
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
883a816820 add --statefd option to lxc-checkpoint/restart
This new option is to have user to pass a fd
in place of statefile name.

Simple usage with file open in bash:
===
$rm -f *.log; lxc-execute -n foo -- pi1  44444
$rm -rf /tmp/sf; lxc-checkpoint -n foo -k --statefd 3 3>/tmp/sf && lxc-restart -n bar --statefd 4 4</tmp/sf
===

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:59 +02:00
Michel Normand
affaa6da9d close fd 0 and 1 where not required
the fd 0,1 and 2 are still inherited
and we only need the fd 2 (stderr) after
the start/restart of the application.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:58 +02:00
Michel Normand
698287d8cf avoid compile warning lxc_init.c
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-29 10:03:58 +02:00
Daniel Lezcano
305bc646f5 Fail gracefully with attach
Fail when we try to attach to an non existing container

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
2b30b86157 change to the same directory when attaching
This patch will try to change the default "/" directory to the
directory we were before attaching. In order to work correctly,
the path has to exist in the container, that makes sense with a
shared file system without rootfs.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
7adff31cbb fork/exec after attach
The command to attach has to be fork/exec.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
91480a0f0a restart the container at reboot
When the reboot is detected, reboot the container.
That needs to set all file descriptor opened by lxc-start
to be flagged with the close-on-exec flag, otherwise when
re-execing ourself, we inherit our own fd.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
563f2f2ccd shutdown the container when powering off the container
This patch allows to shutdown the container when the system
is powered off in the container.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
3bdf52d753 Store the container name in the handler
Store the container in the handler, so it is accessible
everywhere.

Signed-off-by: Daniel Lezcano <dlezcan@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
e0f888d910 count the number of tasks in the container
This patch adds a function to count the number of tasks in the
container. The result is not reliable as it may change with a fork
or an exit, but in some cases, for example, there is only one task, or
the container is frozen, the result is accurate.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-08 09:44:23 +02:00
Daniel Lezcano
f78a1f32f4 fix when console is not specified
When no console is specified, do not try to setup the console.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-02 23:37:42 +02:00
Michel Normand
9b8e796c37 lxc: add --statefile opt to lxc-checkpoint/restart
based on patch from: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>

but also:
* remove the deprecated --directory one.
* change liblxc api of checkpoint/restart to use fd and not string.
* explicitely report error messages for the checkpoint/restart stub functions.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-04-02 18:49:11 +02:00
Daniel Lezcano
9ea8066aa6 fix lxc-setcap script for lxc-attach
Fix type and missing capability.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Michel Normand
341553f769 do not use logfile in lxc_init (V2)
The log file in lxc-init is quite useless as the code is trivial.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Cedric Le Goater <clg@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Michel Normand
adc1e6c25d typo in error message
Wrong variable.

Signed-off-by: Michel Normand <normand@fr.ibm.com>
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
2010-03-22 11:08:34 +01:00
Daniel Lezcano
0a3ec35014 fix lxc-attach returned error
When we try to attach to a container belonging to another user than us,
the command fails as expected but the return code is wrong, so we have
an "unknown error" instead of "permission denied".

The culprit is:

-                     strerror(command.answer.ret));
+                     strerror(-command.answer.ret));

The rest of the code is indentation without code impact.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: Michel Normand <normand@fr.ibm.com>
2010-03-22 11:08:34 +01:00
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