Daniel Lezcano [Thu, 22 Oct 2009 13:33:40 +0000 (15:33 +0200)]
use config.h to define the lxcpath and co
Instead of passing the LXCPATH definition in the compiler
command line, use configure.ac to define the value in the config.h
file and include this file where it is needed.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Thu, 22 Oct 2009 13:33:40 +0000 (15:33 +0200)]
remove test directory
These tests are not relevant now. It would be better to write
some real test cases with some script using the lxc cli in order
to check non regression.
I remove these annoying tests I have to port each time a function
prototype is changed.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Wed, 7 Oct 2009 14:06:09 +0000 (16:06 +0200)]
make container to die when parent dies
When the parent of the first process dies, the container stays there
making very difficuly to track it and to kill. We have to use the
lxc-ps --lxc and kill the processes, hoping we kill the init process
of the container. That's not a big deal until we have thousand of
processes in the container :)
We want to keep the parent of the container init always there, this
process is responsible to manage the container, provide tty, notify
the container changing states and ensure self exclusion (eg. avoid
to launch several containers with the same name).
If this process dies, we consider that as a fatal error and we make
the child process to die too. This patch will just add the prctl to
to send a SIGKILL to the container init process when its parent exits
For the point of view of the pid namespace, when the init process dies
all the processes of the namespace are killed too.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Wed, 7 Oct 2009 14:06:09 +0000 (16:06 +0200)]
Simplify the mainloop
The number of fds passed to epoll is just a hint for the kernel.
In our case, we know this is often 2, let's remove this parameter
from lxc_mainloop_open and cleanup the code around the caller of
this function.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Wed, 7 Oct 2009 14:06:09 +0000 (16:06 +0200)]
returns a specific info when we have ECONNREFUSED
When a command can not be send because the connection is refused,
that means the container is stopped. Let's report this specific
case instead of raising an error.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Michel Normand <normand@fr.ibm.com>
Daniel Lezcano [Wed, 7 Oct 2009 14:06:08 +0000 (16:06 +0200)]
handle the stop command
Handle the stop command. The stop command waits for the peer to
disconnect, that means the peer has exited, so it is safe to
return to the user control. By this way, we ensure a stop command
followed by a start or a destroy won't fail with a race condition
because the start command is not yet finised.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com> Signed-off-by: Michel Normand <normand@fr.ibm.com>
Michel Normand [Wed, 7 Oct 2009 14:06:08 +0000 (16:06 +0200)]
local struct name changed in mainloop.c
Two files have each their own structure definition with the same
name. The types name don't conflict but in the name of sanity, let's
rename these structures.
not critical isn't it :)
Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michel Normand [Wed, 7 Oct 2009 08:05:39 +0000 (10:05 +0200)]
keep rcfile for lxc-execute as already done for lxc-create
The code previously added in lxc-create with
commit d7efa8fcbf0911f93c83dc06a708e7d73833dce3
is also required in lxc-execute.
So make this code common for the two callers.
Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Jiri Slaby [Tue, 18 Aug 2009 21:28:42 +0000 (23:28 +0200)]
lxc build fix for Suse
Hi,
I have to use the attached patch to allow lxc building in the SUSE build
system. It uses as-needed flag and build thus fails, since -lutil is not
at the appropriate place on the command line.
js
suse labs
Signed-off-by: Jiri Slaby <jslaby@suse.cz> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Ship the manpages in the source tarball made by 'make dist', and clean
them up only during the 'make maintainer-clean' step. This allows
distributions not to depend on docbook at lxc build time, because the
manpages are already there.
Also update the configure warning message to sound less scary.
Signed-off-by: Guido Trotter <ultrotter@quaqua.net> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Mon, 20 Jul 2009 15:57:31 +0000 (17:57 +0200)]
fix closed fd when they are inherited
This patch fix a problem with the commit d983b93c3ad860fa22ef760ae27a944d6000e35a
When the lxc daemonize, it closes fd 0, 1 and 2. But these ones are coming from
inherited fd and they are already in the inherited list of fd. When lxc creates
some file descriptors, they have the number of the previous inherited file
descriptor, so they are closed when we close all the inherited file descriptors.
In order to fix that, the lxc_close_inherited_fd function has been implemented
to close an inherited fd and remove it from the list.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Thu, 16 Jul 2009 14:38:15 +0000 (16:38 +0200)]
Remove the a previous cgroup
As a previous run may have created a cgroup but died unexpectedly,
the cgroup can be still there when we try to launch the container
again with the same name. This patch removes the directory if it is
present, if this one is not owned by caller or it is in use (that should
not happen), the rmdir will fail with the corresponding errno.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michel Normand [Wed, 15 Jul 2009 21:48:22 +0000 (23:48 +0200)]
lxc-start should not hold inheritited fds
This patch makes the intermediate lxc processes to close the
inherited file descriptor. The child process will inherit these fd
in any case and that will be up to it to handle them.
Signed-off-by: Michel Normand <normand@fr.ibm.com>
Daniel Lezcano [Mon, 13 Jul 2009 21:12:10 +0000 (23:12 +0200)]
detect a cgroup named 'lxc'
This patch makes lxc to detect a specific cgroup dedicated to lxc
which is mounted with the lxc name. That allows to mount different
cgroup in different places with different options (aka subsystems)
and assign one to be used by lxc. If no such mount point is found,
the first cgroup mount point is used.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Michel Normand [Mon, 13 Jul 2009 21:12:09 +0000 (23:12 +0200)]
lxc-execute or lxc-start to fail if cgroup not mounted
Before this patch a container was able to be started
without mounted cgroup. (only a warning was logged)
But the lxc-ps is using the /proc/<pid>/cgroup to identify
the lxc container in which pid is running.
So to be consistent between all lxc command I force an error
if cgroup is not mounted at time of lxc-execute or lxc-start.
Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Daniel Lezcano [Fri, 10 Jul 2009 06:58:27 +0000 (08:58 +0200)]
create the lxc directory with lxc-setcap
There are several cases:
* we run the lxc-create as root, the @path@/var/lib/lxc will be created
* we run the lxc-create as non-root, the creation of the directory will
fail with "permission denied", so we should call lxc-setcap before
* we run lxc-setcap (always as root), we create the directory and set
the permission for everyone.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
I am trying to run LXC on the CentOS 5.3 and the Linux kernel 2.6.30.
I found a problem with running the rpmbuild command. The error message
is shown below:
Michel Normand [Thu, 25 Jun 2009 09:21:56 +0000 (11:21 +0200)]
lxc-execute to return exit code of its child not others
lxc-execute has to return the exit code of it's child not others
as today's code would return the exit code of the last child.
We need to track the first process we launched and store its
exit status when it exits. In order to avoid to detect the exit
of this pid several time if the pids number wrap, we put an extra
flag saying the process group is orhpan.
Signed-off-by: Michel Normand <normand@fr.ibm.com> Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Matty [Wed, 24 Jun 2009 11:13:18 +0000 (13:13 +0200)]
lxc-fedora fixes
Howdy,
I was playing around with LXC containers this past weekend, and
noticed a couple of issues with the lxc-fedora script:
#1: Line 96 should be ${ROOTFS}/etc/sysconfig/network instead of
${ROOTFS}/sysconfig/network
#2 Line 249 contains a reference to $PKG, which isn't used in the
program. I adjusted the variable to point to the correct package, and
use this in the calls to yumdownloader:
Daniel Lezcano [Fri, 12 Jun 2009 14:02:14 +0000 (16:02 +0200)]
unshare the utsname in all the cases
The current code implies we have to define a utsname in order
to unshare it. This problematic in case of system container because
we want them to set their hostname. As the utsname namespace is
a COW, we can safely unshare it in all the cases.
Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>