]> git.proxmox.com Git - mirror_lxc.git/log
mirror_lxc.git
11 years agomake lxc_af_unix_open() safely return error on long pathnames
Dwight Engen [Mon, 22 Apr 2013 15:16:57 +0000 (11:16 -0400)]
make lxc_af_unix_open() safely return error on long pathnames

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Fix get_ips and nesting with lxcpath
Stéphane Graber [Sun, 21 Apr 2013 20:42:06 +0000 (22:42 +0200)]
python: Fix get_ips and nesting with lxcpath

When using -P (lxcpath), the parameter path needs to be forwarded
to the various commands being run but not used by the nested lxc-ls
as it's relatively unlikely that both the host and the nested containers
use a custom path.

This isn't ideal but short of having a way to provide the container path
for every single of the nesting (with potential unlimited depth), it's
the best we can do.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoubuntu: Various fixes
Stéphane Graber [Sun, 21 Apr 2013 18:09:24 +0000 (20:09 +0200)]
ubuntu: Various fixes

 - Drop disabled entries from allowed devices list
 - Improve generated config layout a bit
 - Drop redundant uname call
 - Re-generate the SSH host keys on container creation

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoUse "uname -m" instead of "arch"
Christian Bühler [Sat, 20 Apr 2013 13:50:13 +0000 (15:50 +0200)]
Use "uname -m" instead of "arch"

According to "arch"'s manpage, it's identical to "uname -m".

Some distros ship uname but don't ship arch, however all distros ship uname,
therefore it makes sense to use "uname -m" whenever possible.

Signed-off-by: Christian Bühler <christian@cbuehler.de>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agopython: Various fixes to the python scripts
Stéphane Graber [Thu, 18 Apr 2013 20:20:53 +0000 (22:20 +0200)]
python: Various fixes to the python scripts

This fixes a few issues uncovered by the recent C module fix.

In lxc-start-ephemeral, the hwaddr code wasn't actually working.
Replace by code that properly iterates through the network interfaces
and sets a new MAC address for each entry.

In the python overlay, catch the newly emitted KeyError when in
set_config_item (or setting any previously unset variable would fail).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Lots of fixes in C extension
Stéphane Graber [Fri, 12 Apr 2013 09:19:56 +0000 (11:19 +0200)]
python: Lots of fixes in C extension

Fixes a lot of issues found by a code review done by Barry Warsaw.

Those include:
 - Wrong signature for getters
 - Various memory leaks
 - Various optimizations
 - More consistent return values
 - Proper exception handling

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Reported-by: Barry Warsaw <barry@ubuntu.com>
Acked-by: Barry Warsaw <barry@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoutils: reimplement/fix mkdir_p() (v2)
Richard Weinberger [Wed, 17 Apr 2013 21:54:09 +0000 (23:54 +0200)]
utils: reimplement/fix mkdir_p() (v2)

Reimplement mkdir_p() such that it:
 ...handles relativ paths correctly. (currently it crashes)
 ...does not rely on dirname().
 ...is not recursive.
 ...is shorter. ;-)

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoRevert "start: Detect early failure of the new child"
Stéphane Graber [Thu, 18 Apr 2013 08:30:33 +0000 (10:30 +0200)]
Revert "start: Detect early failure of the new child"

This reverts commit 5a5c35c3a01afec515e688c8366e6f893985518d.

This commit was preventing startup of containers using lxc hooks and
shutdown of all other containers, requiring the use of a good old
kill -9 to get rid of lxc-start after a container shutdown.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoRevert "utils: reimplement/fix mkdir_p()"
Stéphane Graber [Thu, 18 Apr 2013 08:29:44 +0000 (10:29 +0200)]
Revert "utils: reimplement/fix mkdir_p()"

This reverts commit 8de4140644f01180f2fdab55b0ab0f13d1c761c6.

This commit was preventing container startup on my machine, making them
all fail with various "No such file or directory" errors.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoutils: reimplement/fix mkdir_p()
Richard Weinberger [Wed, 17 Apr 2013 15:13:40 +0000 (17:13 +0200)]
utils: reimplement/fix mkdir_p()

Reimplement mkdir_p() such that it:
 ...handles relativ paths correctly. (currently it crashes)
 ...does not rely on dirname().
 ...is not recursive.
 ...is shorter. ;-)

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agostart: Detect early failure of the new child
Richard Weinberger [Tue, 16 Apr 2013 21:42:23 +0000 (23:42 +0200)]
start: Detect early failure of the new child

If the process in the new namespace dies very early
we have currently no chance to detect this.
The parent process will just die due to SIGPIPE
if it write to the fd used for synchronisation and
nobody will notice the real cause of the problem.

Install a SIGCHLD handler to detect the death.
Later when the child does execve() to the init within
the new namespace the handler will be disabled automatically.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoinit: Fix whitespace damage
Richard Weinberger [Tue, 16 Apr 2013 21:48:16 +0000 (23:48 +0200)]
init: Fix whitespace damage

While we are here, fix the whitespace damage.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoinit: unnest interrupt_handler
Richard Weinberger [Tue, 16 Apr 2013 21:48:15 +0000 (23:48 +0200)]
init: unnest interrupt_handler

There is no need to use nested functions voodoo.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoquiet gcc 4.4.7 warning about saveptr use before initialization
Dwight Engen [Tue, 16 Apr 2013 15:47:29 +0000 (11:47 -0400)]
quiet gcc 4.4.7 warning about saveptr use before initialization

The recent change to use strtok_r causes a build warning with this older
gcc version, so initialize saveptr to NULL to quiet the compiler and
unbreak the build. There was no warning with gcc 4.7.2 that I
originally tested with.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix spacing
Serge Hallyn [Tue, 16 Apr 2013 12:41:17 +0000 (07:41 -0500)]
fix spacing

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agomkdir_p: account for '//foo/bar'
Serge Hallyn [Tue, 16 Apr 2013 12:35:05 +0000 (07:35 -0500)]
mkdir_p: account for '//foo/bar'

As Richard reported, dirname('//') returns //.  But mkdir_p only stops
when called with '/', resulting in infinite recursion when given a
pathname '//foo/bar'.

Reported-by: richard -rw- weinberger <richard.weinberger@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-template: enable chroot + chpasswd functionality for Busybox hosts
Bogdan Purcareata [Thu, 11 Apr 2013 13:29:44 +0000 (16:29 +0300)]
lxc-template: enable chroot + chpasswd functionality for Busybox hosts

This patch supports the scenario where a user wants to install a
busybox container on a busybox host.

When running the template, in order to change the root password,
the template needs to do the chroot. On busybox-powered hosts, chroot
is not part of the coreutils package - it's part of busybox. And the
busybox implementation or chroot only works if it has /lib in the new
root populated with the right binaries (or at least that's the
solution I found to make it work).

The temporarily bind-mounts /lib in the NEWROOT, chroots there,
changes the password, goes back and unmounts. This set of operations
is contained in a new MOUNT namespace, using the lxc-unshare call.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofix checking hook script exit code
Dwight Engen [Mon, 15 Apr 2013 17:43:14 +0000 (13:43 -0400)]
fix checking hook script exit code

pclose returns the exit status from wait, we need to check that to see if
the script itself failed or not. Tested a script that returned 0, 1, and
also one that did a sleep and then was killed by a signal.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofortify: use reentrant safe strtok_r
Dwight Engen [Mon, 15 Apr 2013 19:28:07 +0000 (15:28 -0400)]
fortify: use reentrant safe strtok_r

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofortify: minor cleanups for unused variables, stricter types
Dwight Engen [Mon, 15 Apr 2013 19:59:12 +0000 (15:59 -0400)]
fortify: minor cleanups for unused variables, stricter types

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofortify: check the value returned from write(2)
Dwight Engen [Mon, 15 Apr 2013 19:40:53 +0000 (15:40 -0400)]
fortify: check the value returned from write(2)

Also check that we wrote the amount we expected to. The write on the pty
is blocking but we could still get a short write on EINTR, so we should
SYSERROR it.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofix lxc-attach usage
Dwight Engen [Mon, 15 Apr 2013 20:05:36 +0000 (16:05 -0400)]
fix lxc-attach usage

This makes it match the manpage and be consistent with lxc-execute

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofix coverity-found errors.
Serge Hallyn [Mon, 15 Apr 2013 03:57:46 +0000 (22:57 -0500)]
fix coverity-found errors.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocoverity resource leak fixes
Serge Hallyn [Mon, 15 Apr 2013 03:44:09 +0000 (22:44 -0500)]
coverity resource leak fixes

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix coverity-found resource leaks on error paths.
Serge Hallyn [Mon, 15 Apr 2013 03:22:10 +0000 (22:22 -0500)]
fix coverity-found resource leaks on error paths.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix coverity-found resource leaks in config_network_ipv6
Serge Hallyn [Mon, 15 Apr 2013 03:16:26 +0000 (22:16 -0500)]
fix coverity-found resource leaks in config_network_ipv6

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix free of alloca()d buffer (found by coverity)
Serge Hallyn [Mon, 15 Apr 2013 03:02:03 +0000 (22:02 -0500)]
fix free of alloca()d buffer (found by coverity)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix resource leak of netdev on error path found by coverity
Serge Hallyn [Mon, 15 Apr 2013 02:59:02 +0000 (21:59 -0500)]
fix resource leak of netdev on error path found by coverity

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix resource leak of utsname in error path found by coverity
Serge Hallyn [Mon, 15 Apr 2013 02:56:51 +0000 (21:56 -0500)]
fix resource leak of utsname in error path found by coverity

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agogenl.c: fix a resource leak found by coverity
Serge Hallyn [Mon, 15 Apr 2013 02:48:49 +0000 (21:48 -0500)]
genl.c: fix a resource leak found by coverity

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxcapi_create: fix leak of tpath when a container already exists
Serge Hallyn [Mon, 15 Apr 2013 02:45:00 +0000 (21:45 -0500)]
lxcapi_create: fix leak of tpath when a container already exists

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc_monitor: make sure msg.name is null terminated (bug found by coverity)
Serge Hallyn [Mon, 15 Apr 2013 02:39:34 +0000 (21:39 -0500)]
lxc_monitor: make sure msg.name is null terminated (bug found by coverity)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoifdef out skipped startone test code
Serge Hallyn [Mon, 15 Apr 2013 02:18:53 +0000 (21:18 -0500)]
ifdef out skipped startone test code

Unfortunately installing a working lxc-init is somewhat hairy and
distro-dependent.  So we skipped it before, but Coverity didn't
like that, so just ifdef it out.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxccontaienr: fix missing va_end in error case.
Serge Hallyn [Mon, 15 Apr 2013 02:17:09 +0000 (21:17 -0500)]
lxccontaienr: fix missing va_end in error case.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxcccontainer: add missing va_end found by coverity
Serge Hallyn [Mon, 15 Apr 2013 02:12:58 +0000 (21:12 -0500)]
lxcccontainer: add missing va_end found by coverity

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoaf_unix.c: fix coverity-found bug: pass addr size
Serge Hallyn [Fri, 12 Apr 2013 20:15:22 +0000 (15:15 -0500)]
af_unix.c: fix coverity-found bug: pass addr size

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxclock: fix coverity-found leak
Serge Hallyn [Fri, 12 Apr 2013 20:11:29 +0000 (15:11 -0500)]
lxclock: fix coverity-found leak

if sem_init fails, free what we mallocd.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxclock: indentation
Serge Hallyn [Fri, 12 Apr 2013 20:11:11 +0000 (15:11 -0500)]
lxclock: indentation

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix up struct lxc_container locking
Serge Hallyn [Thu, 11 Apr 2013 16:43:31 +0000 (11:43 -0500)]
Fix up struct lxc_container locking

1. in container_free, set c->privlock to NULL before calling
sem_destroy, to prevent a window where another thread could call
sem_wait(c->privlock) while c->privlock is not NULL but is already
destroyed.

2. in container_get, check for numthreads < 0 before calling lxclock.
Once numthreads is 0, it never goes back up.

Following is a comment added to lxccontainer.c:

/*
 * Consider the following case:
freer                         |    racing get()er
==================================================================
lxc_container_put()           |   lxc_container_get()
\ lxclock(c->privlock)        |   c->numthreads < 1? (no)
\ c->numthreads = 0           |   \ lxclock(c->privlock) -> waits
\ lxcunlock()                 |   \
\ lxc_container_free()        |   \ lxclock() returns
                              |   \ c->numthreads < 1 -> return 0
\ \ (free stuff)              |
\ \ sem_destroy(privlock)     |

 * When the get()er checks numthreads the first time, one of the following
 * is true:
 * 1. freer has set numthreads = 0.  get() returns 0
 * 2. freer is between lxclock and setting numthreads to 0.  get()er will
 *    sem_wait on privlock, get lxclock after freer() drops it, then see
 *    numthreads is 0 and exit without touching lxclock again..
 * 3. freer has not yet locked privlock.  If get()er runs first, then put()er
 *    will see --numthreads = 1 and not call lxc_container_free().
*/

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Seth Arnold <seth.arnold@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agopython: Fix memory management
Stéphane Graber [Thu, 11 Apr 2013 12:15:21 +0000 (14:15 +0200)]
python: Fix memory management

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoubuntu template: fix installation when LANG=C
Dwight Engen [Wed, 3 Apr 2013 18:43:15 +0000 (14:43 -0400)]
ubuntu template: fix installation when LANG=C

The ubuntu template will silently fail (because it is set -e) on
the locale-gen command when LANG=C

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: install additional user specified pkgs
Dwight Engen [Wed, 3 Apr 2013 16:31:46 +0000 (12:31 -0400)]
oracle template: install additional user specified pkgs

Fix lxc-create to not word split template arguments. This makes
lxc-create -n ol -t oracle -- -r "at cronie wget" work since the argument
to -r will be passed as one arg instead of three.

Fix oracle template -u option to shift the correct amount.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-start-ephemeral: fixed bug with wrong ssh option (-k instead of -i)
Wojciech Izykowski [Sat, 6 Apr 2013 14:33:00 +0000 (16:33 +0200)]
lxc-start-ephemeral: fixed bug with wrong ssh option (-k instead of -i)

Corrected ssh option for custom key (from -k to -i). Just see ssh
manpage for justification.

Signed-off-by: Wojciech Izykowski <wizykowski@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodebian template: set arch when dpkg doesn't exist on host
Dwight Engen [Wed, 3 Apr 2013 21:08:32 +0000 (17:08 -0400)]
debian template: set arch when dpkg doesn't exist on host

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agofix wait status in pid reuse case
Dwight Engen [Mon, 8 Apr 2013 16:45:23 +0000 (12:45 -0400)]
fix wait status in pid reuse case

Commit 37c3dfc9 sets the wait status on only the child pid. It
intended to match the pid only once to protect against pid reuse but it
won't because the indicator was reset to 0 every time at the top of the
loop. If the child pid is reused, the wait status will be set again.
Fix by setting indicator outside the loop.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agominor documentation fixes / clarification
Dwight Engen [Tue, 9 Apr 2013 13:41:15 +0000 (09:41 -0400)]
minor documentation fixes / clarification

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoremove unused lxc_copy_file
Dwight Engen [Wed, 10 Apr 2013 14:49:51 +0000 (10:49 -0400)]
remove unused lxc_copy_file

Commit e3642c43 added lxc_copy_file for use in 64e1ae63. The use of it
was removed in commit 1bc60a65. Removing it reduces dead code and the
footprint of liblxc.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc.functions: don't let LXC_PATH= line end in failure
Serge Hallyn [Tue, 9 Apr 2013 21:23:05 +0000 (16:23 -0500)]
lxc.functions: don't let LXC_PATH= line end in failure

Otherwise if called from dash with set -e, dash will exit.  This
causes lxc-clone to fail.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-0.9.0
Daniel Lezcano [Fri, 5 Apr 2013 09:47:48 +0000 (11:47 +0200)]
lxc-0.9.0

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
11 years agoMerge git://github.com/lxc/lxc
Daniel Lezcano [Fri, 5 Apr 2013 09:45:22 +0000 (11:45 +0200)]
Merge git://github.com/lxc/lxc

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
11 years agogitignore doc/legacy/lxc-ls.1
Dwight Engen [Mon, 1 Apr 2013 18:19:36 +0000 (14:19 -0400)]
gitignore doc/legacy/lxc-ls.1

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAPI shouldn't be calling create for already defined containers or destroy for non...
Stéphane Graber [Mon, 1 Apr 2013 14:36:29 +0000 (10:36 -0400)]
API shouldn't be calling create for already defined containers or destroy for non defined ones

Currently it always calls create/destroy which might be confusing for the code
that checks the return value of those calls to determine whether operation
completed successfully or not.

>>> c = lxc.Container("r")
>>> c.create("ubuntu")
True
>>> c.create("ubuntu")
True
>>> c.create("ubuntu")
True
>>> c.create("ubuntu")
True
>>> c.create("ubuntu")
>>> c.destroy()
True
>>> c.destroy()
lxc-destroy: 'r' does not exist
False
>>> c.destroy()
lxc-destroy: 'r' does not exist
False

New behaviour

>>> c = lxc.Container("r")
>>> c.create('ubuntu')
True
>>> c.create('ubuntu')
False
>>> c.destroy()
True
>>> c.destroy()
False
>>>

Tested with following script;

import lxc
c = lxc.Container("abcdef")
print ("set", c.set_config_item("lxc.utsname", "abcdef"))
print ("save", c.save_config())
print ("create", c.create("ubuntu"))
print ("create", c.create("ubuntu"))
print ("destroy", c.destroy())
print ("destroy", c.destroy())
print ("set", c.set_config_item("lxc.utsname", "abcdef"))
print ("save", c.save_config())
print ("destroy", c.destroy())
print ("destroy", c.destroy())

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoMake lxc.functions return the default lxcpath if /etc/lxc/lxc.conf doesn't provide one
S.Çağlar Onur [Mon, 1 Apr 2013 03:37:09 +0000 (23:37 -0400)]
Make lxc.functions return the default lxcpath if /etc/lxc/lxc.conf doesn't provide one

Currently it returns the default path only if /etc/lxc/lxc.conf missing.
Since default lxc.conf doesn't contain lxcpath variable (this is at least the case in ubuntu) all tools fails if one doesn't give -P

caglar@qgq:~/Project/lxc/examples$ sudo /usr/bin/lxc-create -n test
lxc-create: no configuration path defined

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-create: require absolute path for non-standard templates
Serge Hallyn [Sun, 31 Mar 2013 22:00:10 +0000 (17:00 -0500)]
lxc-create: require absolute path for non-standard templates

Otherwise, as an example, if doing 'lxc-create -t debian' while
there is a 'debian' directory, lxc-create will fail to do the
right thing.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-attach: Implement --clear-env and --keep-env
Christian Seiler [Sat, 30 Mar 2013 14:45:39 +0000 (15:45 +0100)]
lxc-attach: Implement --clear-env and --keep-env

This patch introduces the --clear-env and --keep-env options for
lxc-attach, that allows the user to specify whether the environment
should be passed on inside the container or not.

This is to be expanded upon in later versions, this patch only
introduces the most basic functionality.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-shutdown: Make all processes exit before timeout if shutdown works
Christian Seiler [Sat, 30 Mar 2013 14:45:38 +0000 (15:45 +0100)]
lxc-shutdown: Make all processes exit before timeout if shutdown works

The following rationale is for using the -t option:

Currently, lxc-shutdown uses a subprocess for the timeout handling,
where a 'sleep $TIMEOUT' is executed, which will kill the main process
after the timeout has occurred, thus causing the main process to stop
the container hard with lxc-stop.

On the other hand, if the timeout is not reached, the main process
kills the subprocess. The trouble now is that if you kill a shell that
is running in the background, the kill will only take effect as soon as
the program currently running in the shell exits.

This in turn means that the subprocess will never terminate before
reaching the timeout. In an interactive shell, this does not matter,
since people will just not notice the process and lxc-shutdown returns
immediately. In a non-interactive enironment, however, there may be
circumstances that cause the calling program to wait until even that
subprocess is terminated, which means that shutdown will always take as
long as the timeout, even if the container shuts down quite a bit
earlier.

This change makes sure that also all subprocesses of the background
process are killed from the main process. This will immediately
terminate the background process, thus ensuring the desired behaviour.

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agorcfile shouldn't be recorded in lxc_conf if the attempt to load a config file fails
Serge Hallyn [Thu, 28 Mar 2013 15:34:06 +0000 (10:34 -0500)]
rcfile shouldn't be recorded in lxc_conf if the attempt to load a config file fails

Though it's more subtle than that.  If the file doesn't exist or we
can't access it, then don't record it.  But if we have parse errors,
then do.

This is mainly to help out API users who try to read a container
configuration file before calling c->create().  If the file doesn't
exist, then without this patch the subsequent create() will not
use the default /etc/lxc/default.conf.  The API user could check
for the file ahead of time, but this check makes his life easier
without costing us anything.

Signed-off-by: S.Çağlar Onur" <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc.sgml.in: Fix typo in man page.
Matthias Brugger [Wed, 27 Mar 2013 21:21:28 +0000 (22:21 +0100)]
lxc.sgml.in: Fix typo in man page.

This patch fixes a small typo in the man page.

Signed-off-by: Matthias Brugger <matthias.bgg@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-clone: support 'permanent ephemeral' containers
Serge Hallyn [Wed, 27 Mar 2013 14:01:44 +0000 (09:01 -0500)]
lxc-clone: support 'permanent ephemeral' containers

All of this needs a rewrite/redesign, and that will be coming (details
below), but for now

You can start 'non-ephemeral ephemeral' containers using

lxc-start-ephemeral -o oldname -n newname --keep-data

When you shut that down, the container stick around and can be
restarted.  Now lxc-clone will recognize such a container by the
presence of the delta0/ which contains the read-write overlayfs
layer.  This means you can do incremental development of containers,
i.e.

lxc-create -t ubuntu -n r1
lxc-start-ephemeral --keep-data -o r1 -n r1-2
# make some changes, poweroff
lxc-clone -o r1-2 -n r1-3
# make some changes...
lxc-clone -o r1-3 -n r1-4
# etc...

Now, as for design changes...  from a higher level

1. lxc-clone should be re-written in c and exported through the
   api.
2. lxc-clone should support overlayfs and aufs
3. lxc-start-ephemeral should become a thin layer which clones a
   container, starts and stops and destroys it.

at a lower level,

1. the api should support container->setup_mounts
2. lxc-clone should be written as a set of backend classes which
   can copy mounts to each other.  So when you load a container
   which is lvm-backed, it creates a lvm backend class.  That
   class instance can be converted into a loopback or qemu-nbd
   or directory backed class.  A directory-backed class can be
   converted into a overlayfs or aufs backed class, which (a)
   uses the dirctory-backed class as the read-only base, and (b)
   pins the base container (so it can't be deleted until all
   snapshots are deleted).

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-start-ephemeral: Implement -n to match manpage
Stéphane Graber [Wed, 27 Mar 2013 13:27:43 +0000 (09:27 -0400)]
lxc-start-ephemeral: Implement -n to match manpage

The -n/--name option of lxc-start-ephemeral was never implemented
even though it was documented in the manpage.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoSet all mounts to MS_SLAVE when starting a container without a rootfs
David Ward [Wed, 27 Mar 2013 01:27:52 +0000 (21:27 -0400)]
Set all mounts to MS_SLAVE when starting a container without a rootfs

If the filesystem mounts on the host have the MS_SHARED or MS_SLAVE
flag set, and a container without a rootfs is started, then any new
mounts created inside the container are currently propagated into
the host. In addition to mounts placed in the configuration file of
the container or performed manually after startup, the automatic
mounting of /proc by lxc-execute will propagate back into the host,
effectively crippling the entire system. This can be prevented by
setting the MS_SLAVE flag on all mounts (inside the container's own
mount namespace) during startup if a rootfs is not configured.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoubuntu: Tweak architecture support
Stéphane Graber [Tue, 26 Mar 2013 21:18:54 +0000 (17:18 -0400)]
ubuntu: Tweak architecture support

This updates the various checks to match the grid below:

== lxc-ubuntu support per architecture ==
amd64: amd64, i386, armel, armhf, powerpc
i386: i386, armel, armhf, powerpc
armel: armel, armhf
armhf: armhf, armel
powerpc: powerpc

== lxc-ubuntu-cloud support per architecture ==
amd64: amd64, i386
i386: i386
armel: armel, armhf
armhf: armhf, armel

Note that most of the foreign architectures on x86 are supported
through the use of qemu-user-static. This one however isn't yet
support for cloud images (I'll send a patch for 1.0).

Also, qemu-user-static is technically able to emulate amd64 on i386
but qemu-debootstrap doesn't appear to know that and fails quite miserably.

We may also want to add a test for amd64 kernel but i386 userspace, which
is a valid combination that allows running an amd64 container on an i386
host without requiring emulation, but that's for another patch.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix 'make clean'
Stéphane Graber [Tue, 26 Mar 2013 18:03:17 +0000 (14:03 -0400)]
Fix 'make clean'

This is mostly to make debuild happy as it doesn't tolerate any
leftover file when building twice in a row.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoEXTRA_DIST: Fix missing files with "make dist"
Stéphane Graber [Tue, 26 Mar 2013 16:38:47 +0000 (12:38 -0400)]
EXTRA_DIST: Fix missing files with "make dist"

I recently noticed that the generated tarballs with "make dist"
were incomplete unless the configure script was run on a machine
with all possible build dependencies.

That's wrong as you clearly don't need those dependencies to generate
the tarball. This change fixes that.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Fix runtime failure on armhf
Stéphane Graber [Tue, 26 Mar 2013 15:03:47 +0000 (11:03 -0400)]
python: Fix runtime failure on armhf

Recent testing on Ubuntu armhf showed that the python module was
failing to import. After some time tracking the issue down, the problem
was identified as being a non-terminated list of get/setters.

This commit fixes that issue as well as a few other potential ones that
were identified during debugging.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-attach: Clear environment and set container=lxc
David Ward [Wed, 20 Mar 2013 16:08:29 +0000 (12:08 -0400)]
lxc-attach: Clear environment and set container=lxc

The child process's environment should be manipulated the same way
by lxc-attach as it would be by lxc-start or lxc-execute.

Signed-off-by: David Ward <david.ward@ll.mit.edu>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoUse $localstatedir/log/lxc for default log path
Ryota Ozaki [Sun, 17 Mar 2013 14:21:31 +0000 (23:21 +0900)]
Use $localstatedir/log/lxc for default log path

When we install lxc by manual (configure; make; make install),
all files are installed under /usr/local/. Configuration files
and setting files of containers are stored under /usr/local/ too,
however, only log files are stored under /var/log/ not
/usr/local/var/log.

This patch changes the default log path to $localstatedir/log/lxc
(by default $localstatedir is /usr/local/var) where is an ordinary
directory, which is probably expected and unsurprising.

Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoProperly handle timeout case in lxc-shutdown
Christian Seiler [Mon, 18 Mar 2013 19:06:31 +0000 (20:06 +0100)]
Properly handle timeout case in lxc-shutdown

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix for ia64: Use __clone2 for ia64 in lxc/start.c
Dennis Schridde [Mon, 18 Mar 2013 16:55:16 +0000 (17:55 +0100)]
Fix for ia64: Use __clone2 for ia64 in lxc/start.c

Signed-off-by: Dennis Schridde <devurandom@gmx.net>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoProperly cleanup network devices if pinning root filesystem didn't work
Christian Seiler [Mon, 18 Mar 2013 19:06:30 +0000 (20:06 +0100)]
Properly cleanup network devices if pinning root filesystem didn't work

Signed-off-by: Christian Seiler <christian@iwakd.de>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoBuild fix for ia64: Declare __clone2 in lxc/namespace.h
Dennis Schridde [Mon, 18 Mar 2013 16:55:15 +0000 (17:55 +0100)]
Build fix for ia64: Declare __clone2 in lxc/namespace.h

Signed-off-by: Dennis Schridde <devurandom@gmx.net>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-0.9.0.rc1
Daniel Lezcano [Tue, 19 Mar 2013 10:20:16 +0000 (11:20 +0100)]
lxc-0.9.0.rc1

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
11 years agoChange author email address
Daniel Lezcano [Tue, 19 Mar 2013 10:19:06 +0000 (11:19 +0100)]
Change author email address

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
11 years agoMerge git://github.com/lxc/lxc
Daniel Lezcano [Mon, 18 Mar 2013 22:17:00 +0000 (23:17 +0100)]
Merge git://github.com/lxc/lxc

Signed-off-by: Daniel Lezcano <daniel.lezcano@free.fr>
11 years agoAdd missing config.h includes.
Stéphane Graber [Thu, 14 Mar 2013 03:21:15 +0000 (23:21 -0400)]
Add missing config.h includes.

conf.h and start.h weren't explicitly including config.h which meant that
depending on the ordering of the includes in whatever was including conf.h
or start.h, some pieces of the structs defined in those may be missing.

This led amongst other problems to the lxc_conf struct being wrong by 8 bytes
for functions from commands.c, leading to lxc-stop always failing.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agocommands.c: sanity check to not write too-long cgroup path name
Serge Hallyn [Thu, 14 Mar 2013 02:19:24 +0000 (21:19 -0500)]
commands.c: sanity check to not write too-long cgroup path name

This can't really happen due to current limits in cgroup.c but add it
in case those change in the future.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc_id_mapping: don't try to write mappings if there are none
Serge Hallyn [Wed, 13 Mar 2013 15:33:00 +0000 (10:33 -0500)]
lxc_id_mapping: don't try to write mappings if there are none

Otherwise containers fail to start even if they aren't trying to map
ids.

Also don't allocate buf unless we need to.

Reported-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoUpdate lxc-archlinux template default config to use new options
Alexander Vladimirov [Wed, 13 Mar 2013 14:24:02 +0000 (22:24 +0800)]
Update lxc-archlinux template default config to use new options

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodefault kmsg symlinking to on, and document lxc.kmsg
Serge Hallyn [Wed, 13 Mar 2013 13:55:11 +0000 (08:55 -0500)]
default kmsg symlinking to on, and document lxc.kmsg

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoMake /dev/kmsg symlinking optional, add lxc.kmsg option
Alexander Vladimirov [Mon, 11 Mar 2013 05:15:18 +0000 (13:15 +0800)]
Make /dev/kmsg symlinking optional, add lxc.kmsg option

Had this changeset hanging around for some time, maybe this would be useful
until some better solution come up.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroups: don't mount under init's cgroup
Serge Hallyn [Wed, 13 Mar 2013 02:34:26 +0000 (21:34 -0500)]
cgroups: don't mount under init's cgroup

1. deeper hierarchy has steep performance costs
2. init may be under /init, but containers should be under /lxc
3. in a nested container we like to bind-mount $cgroup_path/$c/$c.real
   into $cgroup_path - but task 1's cgroup is $c/$c.real, so a nested
   container would be in $c/$c.real/lxc, which would become
   /$c/$c.real/$c/$c.real/lxc when expanded
4. this pulls quite a bit of code (of mine) which is always nice

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: try to set clone_children
Serge Hallyn [Wed, 13 Mar 2013 01:21:42 +0000 (20:21 -0500)]
cgroup: try to set clone_children

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agouidmap: fix writing multiple ranges
Dwight Engen [Mon, 11 Mar 2013 20:36:25 +0000 (16:36 -0400)]
uidmap: fix writing multiple ranges

The kernel requires a single atomic write for setting the /proc
idmap files. We were calling write(2) more than once when multiple
ranges were configured so instead build a buffer to pass in one write(2)
call.

Change id types to unsigned long to handle large id mappings gracefully.

Fix max id in example comment.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAdd lxc.stopsignal config option
Alexander Vladimirov [Tue, 12 Mar 2013 09:14:11 +0000 (17:14 +0800)]
Add lxc.stopsignal config option

I remember discussion about implementing proper way to shutdown
guests using different signals, so here's a patch proposal.
It allows to use specific signal numbers to shutdown guests
gracefully, for example SIGRTMIN+4 starts poweroff.target in
systemd.

Signed-off-by: Alexander Vladimirov <alexander.idkfa.vladimirov@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agooracle template: fixes for older releases
Dwight Engen [Tue, 12 Mar 2013 17:04:35 +0000 (13:04 -0400)]
oracle template: fixes for older releases

This fixes some issues found by Oracle QA, including several cosmetic
errors seen during container bootup.

The rpm database needs moving on Debian hosts similar to on Ubuntu.

I took Serge's suggestions: Do the yum install in an unshared
mount namespace so the /proc mount done during OL4 install doesn't
pollute the host. No need to blacklist ipv6 modules.

Make the default release 6.3, unless the host is OL, then default
to the same version as the host (same as Ubuntu template does).

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agomake [ug]id map ordering consistent with /proc/<nr>/[ug]id_map
Dwight Engen [Mon, 11 Mar 2013 19:33:57 +0000 (15:33 -0400)]
make [ug]id map ordering consistent with /proc/<nr>/[ug]id_map

The id ordering and case of u,g is also consistent with uidmapshift,
reducing confusion.

doc: Moved example to the the EXAMPLES section, and used values
corresponding to the defaults in the pending shadow-utils subuid patch.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-lenny: Remove deprecated template
Stéphane Graber [Fri, 8 Mar 2013 20:20:19 +0000 (15:20 -0500)]
lxc-lenny: Remove deprecated template

Debian 5.0 Lenny turned out of support on the 6th of February 2012.

From now on, the only supported Debian template is lxc-debian.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Add get_version to binding
Stéphane Graber [Mon, 11 Mar 2013 15:57:52 +0000 (11:57 -0400)]
python: Add get_version to binding

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoAPI: export lxc_get_version()
Stéphane Graber [Mon, 11 Mar 2013 15:57:51 +0000 (11:57 -0400)]
API: export lxc_get_version()

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agopython: Don't hardcode LXCPATH in python module
Stéphane Graber [Mon, 11 Mar 2013 15:57:50 +0000 (11:57 -0400)]
python: Don't hardcode LXCPATH in python module

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agorootfs pin: fix two bugs
Serge Hallyn [Mon, 11 Mar 2013 03:42:40 +0000 (22:42 -0500)]
rootfs pin: fix two bugs

1. if there's no rootfs, return -2, not 0.
2. don't close pinfd unconditionally in do_start().

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: David Ward <david.ward@ll.mit.edu>
11 years agoinclude tests in make dist
Dwight Engen [Thu, 7 Mar 2013 15:45:00 +0000 (10:45 -0500)]
include tests in make dist

This should eventually make the source releases available on sourceforge
also contain the tests.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoattach: handle apparmor transitions in !NEWNS cases
Serge Hallyn [Wed, 6 Mar 2013 19:41:04 +0000 (13:41 -0600)]
attach: handle apparmor transitions in !NEWNS cases

If we're not attaching to the mount ns , then don't enter the
container's apparmor policy.  Since we're running binaries from the host
and not the container, that actually seems the sane thing to do (besides
also the lazier thing).

If we dont' do this patch, then we will need to move the apparmor attach
past the procfs remount, will need to also mount securityfs if available,
and for the !remount_proc_sys case we'll want to mount those just long
enough to do the apparmor transition.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoattach: free result before potentially strduping a second time.
Serge Hallyn [Wed, 6 Mar 2013 20:32:33 +0000 (14:32 -0600)]
attach: free result before potentially strduping a second time.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-attach: User namespaces: Use init's user & group id when attaching
Christian Seiler [Wed, 6 Mar 2013 19:43:52 +0000 (20:43 +0100)]
lxc-attach: User namespaces: Use init's user & group id when attaching

When attaching to a container with a user namespace, try to detect the
user and group ids of init via /proc and attach as that same user. Only
if that is unsuccessful, fall back to (0, 0).

Signed-off-by: Christian Seiler <christian@iwakd.de>
11 years agolxc-attach: Default to /bin/sh if shell cannot be determined or exec'd
Christian Seiler [Wed, 6 Mar 2013 19:41:54 +0000 (20:41 +0100)]
lxc-attach: Default to /bin/sh if shell cannot be determined or exec'd

If getpwuid() fails and also the fallback of spawning of a 'getent'
process, and the user specified no command to execute, default to
/bin/sh and only fail if even that is not available. This should ensure
that unless the container is *really* weird, no matter what, the user
should always end up with a shell when calling lxc-attach with no
further arguments.

Signed-off-by: Christian Seiler <christian@iwakd.de>
11 years agolxc-attach: Try really hard to determine login shell
Christian Seiler [Mon, 4 Mar 2013 22:38:25 +0000 (23:38 +0100)]
lxc-attach: Try really hard to determine login shell

If no command is specified, and using getpwuid() to determine the login
shell fails, try to spawn a process that executes the utility 'getent'.
getpwuid() may fail because of incompatibilities between the NSS
implementations on the host and in the container.

Signed-off-by: Christian Seiler <christian@iwakd.de>
11 years agolxc-destroy man page: document --lxcpath option
Serge Hallyn [Tue, 5 Mar 2013 01:54:12 +0000 (19:54 -0600)]
lxc-destroy man page: document --lxcpath option

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: improve support for multiple lxcpaths (v3)
Serge Hallyn [Fri, 1 Mar 2013 20:53:20 +0000 (14:53 -0600)]
cgroup: improve support for multiple lxcpaths (v3)

Add a monitor command to get the cgroup for a running container.  This
allows container r1 started from /var/lib/lxc and container r1 started
from /home/ubuntu/lxcbase to pick unique cgroup directories (which
will be /sys/fs/cgroup/$subsys/lxc/r1 and .../r1-1), and all the lxc-*
tools to get that path over the monitor at lxcpath.

Rework the cgroup code.  Before, if /sys/fs/cgroup/$subsys/lxc/r1
already existed, it would be moved to 'deadXXXXX', and a new r1 created.
Instead, if r1 exists, use r1-1, r1-2, etc.

I ended up removing both the use of cgroup.clone_children and support
for ns cgroup.  Presumably we'll want to put support for ns cgroup
back in for older kernels.  Instead of guessing whether or not we
have clone_children support, just always explicitly do the only thing
that feature buys us - set cpuset.{cpus,mems} for newly created cgroups.

Note that upstream kernel is working toward strict hierarchical
limit enforcements, which will be good for us.

NOTE - I am changing the lxc_answer struct size.  This means that
upgrades to this version while containers are running will result
in lxc_* commands on pre-running containers will fail.

Changelog: (v3)
   implement cgroup attach
   fix a subtle bug arising when we lxc_get_cgpath() returned
     STOPPED rather than -1 (STOPPED is 0, and 0 meant success).
   Rename some functions and add detailed comments above most.
   Drop all my lxc_attach changes in favor of those by Christian
     Seiler (which are mostly the same, but improved).

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoc api: send lxcpath to destroy command
Serge Hallyn [Mon, 4 Mar 2013 20:11:36 +0000 (14:11 -0600)]
c api: send lxcpath to destroy command

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>