]> git.ipfire.org Git - thirdparty/lxc.git/log
thirdparty/lxc.git
11 years agoCosmetic: shorten the options summary in documentation 92/head
Marek Majkowski [Wed, 13 Nov 2013 15:04:27 +0000 (07:04 -0800)] 
Cosmetic: shorten the options summary in documentation

11 years agoMake it possible to share UTS namespace
Marek Majkowski [Wed, 13 Nov 2013 13:20:26 +0000 (05:20 -0800)] 
Make it possible to share UTS namespace

11 years agoRefactoring - make the option parsing code generic
Marek Majkowski [Tue, 12 Nov 2013 16:19:55 +0000 (08:19 -0800)] 
Refactoring - make the option parsing code generic

11 years agoFix memory leak in pid_from_lxcname and use ns_proc_name in open_ns.
Marek Majkowski [Tue, 12 Nov 2013 15:06:23 +0000 (07:06 -0800)] 
Fix memory leak in pid_from_lxcname and use ns_proc_name in open_ns.

11 years agoMerge remote-tracking branch 'lxc/master' into share-namespaces
Marek Majkowski [Tue, 12 Nov 2013 14:13:37 +0000 (06:13 -0800)] 
Merge remote-tracking branch 'lxc/master' into share-namespaces

11 years agoCreate --share-ipc option
Marek Majkowski [Tue, 12 Nov 2013 13:14:25 +0000 (05:14 -0800)] 
Create --share-ipc option

11 years agoCosmetic.
Marek Majkowski [Tue, 12 Nov 2013 13:13:53 +0000 (05:13 -0800)] 
Cosmetic.

11 years agoDescribe --share-net in the lxc-start manual
Marek Majkowski [Tue, 12 Nov 2013 13:13:33 +0000 (05:13 -0800)] 
Describe --share-net in the lxc-start manual

11 years agoCosmetic - clean up error message
Marek Majkowski [Tue, 12 Nov 2013 11:50:26 +0000 (03:50 -0800)] 
Cosmetic - clean up error message

11 years agolxc_abstract_unix_connect: accomodate containers started before Oct 28
Serge Hallyn [Mon, 11 Nov 2013 18:32:14 +0000 (12:32 -0600)] 
lxc_abstract_unix_connect: accomodate containers started before Oct 28

commit aae93dd3dd20dd12c6b8f9f0490e2fb877ee3f09 fixed the command socket
name to use the right pathlen instead of always passing in the max
socket namelen.  However, this breaks lxc-info/lxc-list/etc for
containers started before that commit.  So if the correct command
sock name doesn't work, try the preexising one.

Note we can probably undo this "after awhile".  Maybe in august 2014.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAllow specifying a container by name or pid in --share-net option.
Marek Majkowski [Mon, 11 Nov 2013 13:19:29 +0000 (05:19 -0800)] 
Allow specifying a container by name or pid in --share-net option.

11 years agoadd modes argument to lxc-test-concurrent
Dwight Engen [Fri, 8 Nov 2013 19:00:40 +0000 (14:00 -0500)] 
add modes argument to lxc-test-concurrent

- This allows testing independently the modes with/without threading

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agowait_on_damonized-start: wait only on the pid we want
Serge Hallyn [Fri, 8 Nov 2013 17:41:16 +0000 (17:41 +0000)] 
wait_on_damonized-start: wait only on the pid we want

Otherwise we can reap another thread's forked pid.

Changelog: Per Dwight's suggestion, use pid_t for argument.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: S.Çağlar Onur <caglar@10ur.org>
11 years agoapi_start: refuse to run undaemonized if multithreaded
Serge Hallyn [Fri, 8 Nov 2013 04:20:33 +0000 (22:20 -0600)] 
api_start: refuse to run undaemonized if multithreaded

lxc-start is not safe (and doesn't actually make sense) if the
task is nto single-threaded.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc_user_nic: remove duplicate code
Qiang Huang [Fri, 8 Nov 2013 02:54:18 +0000 (10:54 +0800)] 
lxc_user_nic: remove duplicate code

It's a duplicate of util.h.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoEnable network namespace sharing in lxc-start
Marek Majkowski [Wed, 6 Nov 2013 23:16:33 +0000 (15:16 -0800)] 
Enable network namespace sharing in lxc-start

Right now lxc-start always does one of two things: it creates
a new namespace or inherits it from the parent environment.
This patch adds a third option: share a namespace with another
container (actually: a process).

In some situations this is handy. For example by sharing a network
namespace it is possible to migrate services between containers
without (or with little) downtime.

This patch creates an infrastructure for inheriting any type
of namespace, but only the network namespace is supported for now.

11 years agocoverity 1126129: don't try to print c->name when c is NULL
Dwight Engen [Wed, 6 Nov 2013 15:32:02 +0000 (10:32 -0500)] 
coverity 1126129: don't try to print c->name when c is NULL

I accidentally introduced this with the change to lxc-info (commit
b9d957c3).

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-user-nic: rename nic inside container to desired name
Serge Hallyn [Fri, 25 Oct 2013 23:03:57 +0000 (18:03 -0500)] 
lxc-user-nic: rename nic inside container to desired name

To do so we do a quick setns into the container's netns.  This
(unexpectedly) turns out cleaner than trying to rename it from
lxc_setup(), because we don't know the original nic name in
the container until we created it which we do in the parent
after the init has been cloned.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agocreate_run_template: tell the template what caller's uid was mapped to
Serge Hallyn [Fri, 1 Nov 2013 20:27:49 +0000 (15:27 -0500)] 
create_run_template: tell the template what caller's uid was mapped to

conf.c/conf.h: have replaced bool hostid_is_mapped() with int mapped_hostid()
   which returns the mapped uid for the caller's uid on the host, or -1 if
   none

create_run_template: pass caller's uid into template.

lxc-ubuntu-cloud:
1. accept --mapped-uid argument
2. don't write to devices cgroup - not allowed.
3. if running in userns, use $HOME/.cache
4. chown cached files to the uid to which our caller was
   mapped
5. ignore /dev when extracting rootfs in a userns

Changelog: nov 5: remove debugging INFO line.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoadd statistics to lxc-info
Dwight Engen [Tue, 5 Nov 2013 18:17:07 +0000 (13:17 -0500)] 
add statistics to lxc-info

- allow lxc-info to show more than one container, using regex for the name

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofix leak in list_active_containers()
Dwight Engen [Tue, 5 Nov 2013 18:17:02 +0000 (13:17 -0500)] 
fix leak in list_active_containers()

Found by running the lxc-test-list test with valgrind. The names were
put into a local array, and never freed in the success case where the
caller didn't want the names returned and in the early out failure case.

Note we don't need to check the return from remove_from_array() because
we just successfully added the name above.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agotests list: refactor and add test for list_all_containers()
Dwight Engen [Tue, 5 Nov 2013 18:16:57 +0000 (13:16 -0500)] 
tests list: refactor and add test for list_all_containers()

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd list_all_containers(), returns defined and active containers
Dwight Engen [Tue, 5 Nov 2013 18:16:51 +0000 (13:16 -0500)] 
add list_all_containers(), returns defined and active containers

Changelog: [serge] remove unneeded explicity qsort call

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix tests on Android
Stéphane Graber [Wed, 6 Nov 2013 03:43:38 +0000 (22:43 -0500)] 
Fix tests on Android

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoOnly include execinfo.h if MUTEX_DEBUGGING is set
Stéphane Graber [Tue, 5 Nov 2013 19:30:30 +0000 (14:30 -0500)] 
Only include execinfo.h if MUTEX_DEBUGGING is set

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix leak when a veth.pair name is specified
Dwight Engen [Tue, 5 Nov 2013 17:26:34 +0000 (12:26 -0500)] 
fix leak when a veth.pair name is specified

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolua: add cmd_get_config_item to API
Dwight Engen [Mon, 4 Nov 2013 22:35:07 +0000 (17:35 -0500)] 
lua: add cmd_get_config_item to API

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoallow lxcapi_get_cgroup_item() on lxc-execute containers
Dwight Engen [Mon, 4 Nov 2013 22:35:15 +0000 (17:35 -0500)] 
allow lxcapi_get_cgroup_item() on lxc-execute containers

Containers started with lxc-execute may not have a conf, but
nothing in the implementation of lxcapi_get_cgroup_item()
actually needs/uses it, and it can be useful to get items out
of the containers' cgroup items.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-top: show kernel memory being used if available
Dwight Engen [Thu, 31 Oct 2013 20:38:36 +0000 (16:38 -0400)] 
lxc-top: show kernel memory being used if available

- Also removed duplicate stats_clear lua function

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolua: fix stats collection using get_cgroup_item
Dwight Engen [Thu, 31 Oct 2013 20:38:30 +0000 (16:38 -0400)] 
lua: fix stats collection using get_cgroup_item

Previously, the lua stats collection was building its own paths to the
cgroup files, which could be wrong depending on what --with-cgroup-pattern
was passed to configure. Fix it to use the get_cgroup_item api so it
always finds the files.

Remove cgroup_path_get since it is not used anymore.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd [gs]et_cgroup_item to lua api
Dwight Engen [Thu, 31 Oct 2013 20:38:22 +0000 (16:38 -0400)] 
add [gs]et_cgroup_item to lua api

fix up api test to run and add test for new [gs]et_cgroup_item

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoallow setting/getting lxc.loglevel and lxc.logfile via set_config_item/get_config_ite...
S.Çağlar Onur [Sat, 2 Nov 2013 04:43:55 +0000 (00:43 -0400)] 
allow setting/getting lxc.loglevel and lxc.logfile via set_config_item/get_config_item API calls

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agomake sure to check c->lxc_conf is not NULL before dereferencing it.
S.Çağlar Onur [Sat, 2 Nov 2013 21:15:36 +0000 (17:15 -0400)] 
make sure to check c->lxc_conf is not NULL before dereferencing it.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoignore tags files that can be created via make ctags target
S.Çağlar Onur [Fri, 1 Nov 2013 20:39:31 +0000 (16:39 -0400)] 
ignore tags files that can be created via make ctags target

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agovalgrind drd tool shows conflicting stores happening at lxc_global_config_value@src...
S.Çağlar Onur [Fri, 1 Nov 2013 20:16:10 +0000 (16:16 -0400)] 
valgrind drd tool shows conflicting stores happening at lxc_global_config_value@src/lxc/utils.c (v2)

Conflict occurs between following lines

[...]
269         if (values[i])
270                 return values[i];
[...]

and

[...]
309         /* could not find value, use default */
310         values[i] = (*ptr)[1];
[...]

fix it using a specific lock dedicated to that problem as Serge suggested.

Also introduce a new autoconf parameter (--enable-mutex-debugging) to convert mutexes to error reporting type and to provide a stacktrace when locking fails.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoalways remount / rslave before running creation template (if root)
Serge Hallyn [Fri, 1 Nov 2013 17:17:52 +0000 (12:17 -0500)] 
always remount / rslave before running creation template (if root)

If we're not root, our mounts in private userns won't get pushed
back anyway.  If we are root, we need to make sure that anything
the template does gets cleaned up.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoremove a few noisy, unhelpful INFOs in detect_shared_rootfs()
Serge Hallyn [Fri, 1 Nov 2013 14:11:18 +0000 (09:11 -0500)] 
remove a few noisy, unhelpful INFOs in detect_shared_rootfs()

They are a nuisance.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoremove left over debug getchar()
Dwight Engen [Wed, 30 Oct 2013 17:50:33 +0000 (13:50 -0400)] 
remove left over debug getchar()

I goofed and left in a getchar() that I was using to pause the test program
in a case that was failing for me. Remove it.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agodaemonize implies close_all_fds so set it in lxcapi_want_daemonize instead of setting...
S.Çağlar Onur [Wed, 30 Oct 2013 20:10:26 +0000 (16:10 -0400)] 
daemonize implies close_all_fds so set it in lxcapi_want_daemonize instead of setting in every cli or in every binding explicitly

Reported-by: Fatih Arslan <ftharsln@gmail.com>
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoapi_create: undo unneeded chunk in previous commit
Serge Hallyn [Wed, 30 Oct 2013 17:47:38 +0000 (12:47 -0500)] 
api_create: undo unneeded chunk in previous commit

lxc_conf exists after api_save_config

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoapi_create and do_bdev_create: a few more fixes
Serge Hallyn [Wed, 30 Oct 2013 15:57:45 +0000 (10:57 -0500)] 
api_create and do_bdev_create: a few more fixes

don't use lxcpath variable for rootfs_path, it's confusing.

if rootfs is passed in and tpath is passed in, return error
before we save a new config, and don't delete the container

make sure to check c->lxc_conf is not NULL before dereferencing it.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-create: fix conflict of rootfs.path and template default path
Sheng Yong [Sun, 27 Oct 2013 06:38:03 +0000 (14:38 +0800)] 
lxc-create: fix conflict of rootfs.path and template default path

1. rootfs.path set, -t not set: rootfs.path is rootfs path
2. rootfs.path set, -t set: change template default path to rootfs path
3. rootfs.path not set, -t set: template default path is rootfs path
4. rootfs.path not set, -t not set: error
5. rootfs.path set but cannot access: error

Signed-off-by: Sheng Yong <shyodx@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxcapi_create: don't delete if container rootfs already exists
Sheng Yong [Sun, 27 Oct 2013 06:37:46 +0000 (14:37 +0800)] 
lxcapi_create: don't delete if container rootfs already exists

If lxc.rootfs is specified, we believe rootfs is ready. lxc-start will
check this later. Return true, because the container is created.

Signed-off-by: Sheng Yong <shyodx@gmail.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocoverity 1097616: don't deref NULL when subsystem doesn't have a '.'
Dwight Engen [Tue, 29 Oct 2013 20:46:21 +0000 (16:46 -0400)] 
coverity 1097616: don't deref NULL when subsystem doesn't have a '.'

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix cgpath test
Dwight Engen [Tue, 29 Oct 2013 20:46:16 +0000 (16:46 -0400)] 
fix cgpath test

Commit 1ea59ad28 sets memory.use_hierarchy, which means that this test
cannot use memory.swappiness as its dummy cgroup item to set/unset since
writing to it with use_hierarchy set gets -EINVAL. Change test to use
memory.soft_limit_in_bytes instead.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agocoverity 1097618: check for NULL return from calloc before deref
Dwight Engen [Tue, 29 Oct 2013 18:49:16 +0000 (14:49 -0400)] 
coverity 1097618: check for NULL return from calloc before deref

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix free() of args to startl
Dwight Engen [Tue, 29 Oct 2013 18:38:00 +0000 (14:38 -0400)] 
fix free() of args to startl

Coverity 1076328 marked this as "Use after free", which it isn't really,
its actually just free()ing the wrong 2nd, 3rd, etc... pointers. Test by
passing two or more args to startl, without this change you get segfault
when free()ing the second pointer/arg.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agorpm spec: fix version numbering when building alpha, beta, rc
Serge Hallyn [Tue, 29 Oct 2013 17:48:46 +0000 (12:48 -0500)] 
rpm spec: fix version numbering when building alpha, beta, rc

We want to ensure smooth upgrades when doing rpm -U throughout the
release cycle so this change implements the scheme documented at:
http://fedoraproject.org/wiki/Packaging%3aNamingGuidelines#NonNumericRelease

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agocoverity: ifr_name buffer not NULL terminated
Dwight Engen [Tue, 29 Oct 2013 13:24:29 +0000 (09:24 -0400)] 
coverity: ifr_name buffer not NULL terminated

The kernel (net/core/dev_ioctl.c:dev_ioctl()) is going to NULL terminate
this name after the copy-in of the ifr, so even though this is a fixed
sized array the last byte isn't usable as part of the name. All the ioctls
we're using go through this code path.

Use the ifr name in the DEBUG message in case it was possibly truncated.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agofree getline allocated line variable to make valgrind happy
S.Çağlar Onur [Mon, 28 Oct 2013 19:39:12 +0000 (15:39 -0400)] 
free getline allocated line variable to make valgrind happy

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agounnamed semaphores should be destroyed not closed
S.Çağlar Onur [Mon, 28 Oct 2013 19:37:22 +0000 (15:37 -0400)] 
unnamed semaphores should be destroyed not closed

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agorpm spec: fix "warning: bogus date in %changelog"
Dwight Engen [Fri, 25 Oct 2013 23:01:54 +0000 (19:01 -0400)] 
rpm spec: fix "warning: bogus date in %changelog"

Mar 24 2009 was actually a Tuesday, maybe Daniel was still recovering
from Monday ;) Stranger still that RPM actually checks this!?

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoUse actual length of socket's name for abstract sockets (v3)
S.Çağlar Onur [Fri, 25 Oct 2013 22:04:52 +0000 (18:04 -0400)] 
Use actual length of socket's name for abstract sockets (v3)

The addrlen parameter should be the actual length of socket's name for abstract sockets. Otherwise socket gets padded with NULLs.

cat /proc/net/unix | grep lxc
[...]
000000000000000000000003 00000000 00000000 0001 03 226548 @lxc/ad055575fe28ddd5//var/lib/lxc^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@
[...]

with this patch;

cat /proc/net/unix | grep lxc
[...]
000000000000000000000002 00000000 00010000 0001 01 109563 @lxc/ad055575fe28ddd5//var/lib/lxc
[...]

Changes since v1:
    * check the length of passed-in string
Changes since v2:
    * remove non-abstract socket code path to simplify functions
    * rename lxc_af_unix_* family to lxc_abstract_unix_*

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoEliminate duplicate entries from list_active_containers (v2)
S.Çağlar Onur [Thu, 24 Oct 2013 04:02:37 +0000 (00:02 -0400)] 
Eliminate duplicate entries from list_active_containers (v2)

list_active_containers parses /proc/net/unix which can contain multiple entries for the same container;

000000000000000000000002 00000000 00010000 0001 01 273672 @/var/lib/lxc/6/command
000000000000000000000002 00000000 00010000 0001 01 274395 @/var/lib/lxc/5/command
000000000000000000000002 00000000 00010000 0001 01 273890 @/var/lib/lxc/4/command
000000000000000000000002 00000000 00010000 0001 01 273141 @/var/lib/lxc/3/command
000000000000000000000002 00000000 00010000 0001 01 273915 @/var/lib/lxc/2/command
000000000000000000000002 00000000 00010000 0001 01 273683 @/var/lib/lxc/1/command
000000000000000000000002 00000000 00010000 0001 01 273074 @/var/lib/lxc/0/command
000000000000000000000002 00000000 00010000 0001 01 273931 @/var/lib/lxc/9/command
000000000000000000000002 00000000 00010000 0001 01 273110 @/var/lib/lxc/8/command
000000000000000000000002 00000000 00010000 0001 01 273390 @/var/lib/lxc/7/command
000000000000000000000003 00000000 00000000 0001 03 275903 @/var/lib/lxc/8/command
000000000000000000000003 00000000 00000000 0001 03 276043 @/var/lib/lxc/1/command
000000000000000000000003 00000000 00000000 0001 03 273301 @/var/lib/lxc/0/command
000000000000000000000003 00000000 00000000 0001 03 275650 @/var/lib/lxc/4/command

On this system list_active_containers returns 14 containers while only 10 containers are running.

Following patch;

* Introduces array_contains function to do a binary search on given array,
* Starts to sort arrays inside the add_to_clist and add_to_names functions,
* Consumes array_contains in list_active_containers to eliminate duplicates,
* Replaces the linear search code in lxcapi_get_interfaces with the new function.

Changes since v1:
* Do not load containers if a if a container list is not passed in
* Fix possible memory leaks in lxcapi_get_ips and lxcapi_get_interfaces if realloc fails

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-alpine: enable 4 consoles by default
Natanael Copa [Thu, 24 Oct 2013 11:30:15 +0000 (13:30 +0200)] 
lxc-alpine: enable 4 consoles by default

We allow 4 consoles in the LXC config file so we can enable 4 in the
inittab as well.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-alpine: run bootmisc and syslog at boot runlevel
Natanael Copa [Thu, 24 Oct 2013 11:30:14 +0000 (13:30 +0200)] 
lxc-alpine: run bootmisc and syslog at boot runlevel

The bootmisc script is needed to clean up various temp dirs like /tmp
and migrate /var/run to /run if needed.

The syslog service is started in 'boot' runlevel when running on real
hardware so we do the same for containers.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocgroup: set memory.use_hierarchy
Serge Hallyn [Fri, 25 Oct 2013 05:16:17 +0000 (00:16 -0500)] 
cgroup: set memory.use_hierarchy

But don't fail the container start if that fails.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-ls: Rewrite nesting code to use the attach API
Stéphane Graber [Thu, 24 Oct 2013 18:45:34 +0000 (14:45 -0400)] 
lxc-ls: Rewrite nesting code to use the attach API

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agostart: use lxc-user-nic if we are not root
Serge Hallyn [Wed, 23 Oct 2013 15:52:37 +0000 (10:52 -0500)] 
start: use lxc-user-nic if we are not root

Note this results in nics named things like 'lxcuser-0p'.  We'll
likely want to pass the requested name to lxc-user-nic, but let's
do that in a separate patch.

If we're not root, we can't create new network itnerfaces to pass
into the container.  Instead wait until the container is started,
and call lxc-user-nic to create and assign the nics.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-busybox: if in userns, don't try to mknod
Serge Hallyn [Wed, 23 Oct 2013 01:02:59 +0000 (01:02 +0000)] 
lxc-busybox: if in userns, don't try to mknod

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agofix chowning of tty and console uids
Serge Hallyn [Wed, 23 Oct 2013 01:02:58 +0000 (01:02 +0000)] 
fix chowning of tty and console uids

It needs to be done from the handler, not the container, since
the container may not have the rights.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Changelog:
    Jul 22: remove hardcoded path for /bin/chown
    Jul 22: use new lxc-usernsexec

Conflicts:
src/lxc/lxccontainer.c

11 years agocontainer creation: support unpriv container creation in user namespaces
Serge Hallyn [Wed, 23 Oct 2013 01:02:57 +0000 (01:02 +0000)] 
container creation: support unpriv container creation in user namespaces

1. lxcapi_create: don't try to unshare and mount for dir backed containers

It's unnecessary, and breaks unprivileged lxc-create (since unpriv users
cannot yet unshare(CLONE_NEWNS)).

2. api_create: chown rootfs

chown rootfs to the host uid to which container root will be mapped

3. create: run template in a mapped user ns

4. use (setuid-root) newxidmap to set id_map if we are not root

This is needed to be able to set userns mappings as an unprivileged
user, for unprivileged lxc-start.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agostrtoul: check errno
Serge Hallyn [Thu, 24 Oct 2013 16:35:55 +0000 (11:35 -0500)] 
strtoul: check errno

In a few places we checked for LONG_MIN or LONG_MAX as indication
that strtoul failed.  That's not reliable.  As suggested in the
manpage, switch to checking errno value.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoclang: Remaining changes
Stéphane Graber [Thu, 24 Oct 2013 01:50:43 +0000 (21:50 -0400)] 
clang: Remaining changes

Those are a bit less obvious than those I pushed directly to master.
All those changes were required to build LXC under clang here.

With this, gcc can be replaced by clang to build LXC so long as you're
not using the python3 binding (as python extensions can't be built under
clang at the moment).

For reference, the clang output for those is: http://paste.ubuntu.com/6292460/

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoFix build failure on sparc
Stéphane Graber [Thu, 24 Oct 2013 02:04:52 +0000 (22:04 -0400)] 
Fix build failure on sparc

Signed-off-by: Thomas Nemeth <thomas.nemeth@laposte.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoapparmor: cache the are-we-enabled decision
Serge Hallyn [Thu, 24 Oct 2013 01:54:13 +0000 (20:54 -0500)] 
apparmor: cache the are-we-enabled decision

Since we check /sys/kernel/security/ files when deciding whether
apparmor is enabled, and that might not be mounted in the container,
we cannot re-make the decision at apparmor_process_label_set() time.
Luckily we don't have to - just cache the decision made at
lsm_apparmor_drv_init().

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agooracle template: restrict writeability in /proc and /sys
Dwight Engen [Wed, 23 Oct 2013 21:03:40 +0000 (17:03 -0400)] 
oracle template: restrict writeability in /proc and /sys

Note that since we don't drop CAP_SYS_ADMIN, root in the container can
remount proc or sys however they want to, however this at least improves
the default situation.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agoclang: Fix some simple issues
Stéphane Graber [Thu, 24 Oct 2013 01:42:42 +0000 (21:42 -0400)] 
clang: Fix some simple issues

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-debian: Add hwaddr handling logic
Stéphane Graber [Wed, 23 Oct 2013 23:59:22 +0000 (19:59 -0400)] 
lxc-debian: Add hwaddr handling logic

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
11 years agodoc: Update Japanese lxc-create(1) for default thin pool name
KATOH Yasufumi [Tue, 22 Oct 2013 08:59:30 +0000 (17:59 +0900)] 
doc: Update Japanese lxc-create(1) for default thin pool name

Update for commit 055af165efb08f4dd54608896893bb6928fd472f

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agotemplate: Fix the container configuration issue in lxc-plamo
KATOH Yasufumi [Wed, 23 Oct 2013 10:21:52 +0000 (19:21 +0900)] 
template: Fix the container configuration issue in lxc-plamo

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix segfault on lxc-create when no template specified
KATOH Yasufumi [Wed, 23 Oct 2013 12:00:53 +0000 (21:00 +0900)] 
Fix segfault on lxc-create when no template specified

When no template file is specified on lxc-create, recieve segfault.
So change not to append header in config when no template is specified.

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agobdev.c: don't free right before exit
Serge Hallyn [Tue, 22 Oct 2013 22:12:01 +0000 (17:12 -0500)] 
bdev.c: don't free right before exit

Also log execlp error code if it returns.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoPass through all options with -Bbest.
Sidnei da Silva [Tue, 22 Oct 2013 21:52:30 +0000 (19:52 -0200)] 
Pass through all options with -Bbest.

Remove the union in bdev_specs and store all options if -Bbest is passed. Fixes issue #31.

Signed-off-by: Sidnei da Silva <sidnei.da.silva@canonical.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoinstall lua module 0644 instead of 0755
Dwight Engen [Tue, 22 Oct 2013 20:33:34 +0000 (16:33 -0400)] 
install lua module 0644 instead of 0755

Fixes rpmlint error "script-without-shebang". Checked other lua modules
and none are installed with execute permission.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoupdate rpm .spec file
Dwight Engen [Tue, 22 Oct 2013 20:33:26 +0000 (16:33 -0400)] 
update rpm .spec file

The following changes were made to fix rpmlint warnings/errors
- use %global instead of %define
  http://fedoraproject.org/wiki/PackagingDrafts/global_preferred_over_define
- change Summary to match .deb
- update License
- do not mention the libcap dependency explicitly, rpm will fill it in
- fix Summary, Description for libs and devel packages
- pass -q to %setup
- add %post for libs to run ldconfig
- explicitly name lxc man paths so pkg doesn't "own" /usr/share/man
- mark /etc/lxc/default.conf as a config file

In addition, while I was here:
- split lua bits into seperate lxc-lua package
- change Description to match .deb
- remove "Version" in changelog entries to follow
  http://fedoraproject.org/wiki/Packaging:Guidelines#Changelogs

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-busybox: don't copy temp mounts into mtab
Serge Hallyn [Tue, 22 Oct 2013 16:34:46 +0000 (11:34 -0500)] 
lxc-busybox: don't copy temp mounts into mtab

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-alpine: allow /dev/full
Natanael Copa [Tue, 22 Oct 2013 11:23:31 +0000 (13:23 +0200)] 
lxc-alpine: allow /dev/full

The template creates /dev/full for the container but needs also give
permission to access it.

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoget rid of '${lxcpath}_anon' idea
Serge Hallyn [Mon, 21 Oct 2013 23:44:03 +0000 (18:44 -0500)] 
get rid of '${lxcpath}_anon' idea

The idea was simply misguided.

If you provide a custom configuration file, you still should be
putting the command sock into the real lxcpath, not an 'anon' one.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agodoc: Update Japanese lxc-create(1) for --thinpool option
tenforward [Sun, 20 Oct 2013 13:37:28 +0000 (22:37 +0900)] 
doc: Update Japanese lxc-create(1) for --thinpool option

Update for commit 62c70ee2c1b49e7ecd2bfe156a66cbcfc5ecb502

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoFallback lvs comparison to false.
Sidnei da Silva [Mon, 21 Oct 2013 22:16:32 +0000 (20:16 -0200)] 
Fallback lvs comparison to false.

If lvs invocation fails or doesn't return any output, then lv flags comparison to false.

Signed-off-by: Sidnei da Silva <sidnei.da.silva@canonical.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoStore fssize and fstype in the right struct.
Sidnei da Silva [Mon, 21 Oct 2013 21:22:58 +0000 (19:22 -0200)] 
Store fssize and fstype in the right struct.

When using the -Bloop option, fstype and fssize arguments were copied
into the lvm struct of bdev specs instead of the loop struct.

Signed-off-by: Sidnei da Silva <sidnei.da.silva@canonical.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoAssume a default thin pool named 'lxc'.
Sidnei da Silva [Mon, 21 Oct 2013 20:33:02 +0000 (18:33 -0200)] 
Assume a default thin pool named 'lxc'.

Will fallback to no thinpool if not present or if thin pool provided on the command line does not exist.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoUpdate maintainers and URLs
Stéphane Graber [Sun, 20 Oct 2013 04:48:48 +0000 (00:48 -0400)] 
Update maintainers and URLs

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix typos identified by lintian
Stéphane Graber [Sun, 20 Oct 2013 04:34:07 +0000 (00:34 -0400)] 
Fix typos identified by lintian

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoFix following compile error on ubuntu 12.10
S.Çağlar Onur [Sat, 19 Oct 2013 04:45:03 +0000 (00:45 -0400)] 
Fix following compile error on ubuntu 12.10

[...]
make[3]: Entering directory `/home/caglar/Projects/lxc/src/tests'
depbase=`echo attach.o | sed 's|[^/]*$|.deps/&|;s|\.o$||'`;\
        gcc -DHAVE_CONFIG_H -I. -I../../src    -I../../src -DLXCROOTFSMOUNT=\"/usr/lib/x86_64-linux-gnu/lxc/rootfs\" -DLXCPATH=\"/var/lib/lxc\" -DLXC_GLOBAL_CONF=\"/etc/lxc/lxc.conf\" -DLXCINITDIR=\"/usr/libexec\" -DLXC_DEFAULT_CONFIG=\"/etc/lxc/default.conf\"   -g -O2 -Wall -Werror -MT attach.o -MD -MP -MF $depbase.Tpo -c -o attach.o attach.c &&\
        mv -f $depbase.Tpo $depbase.Po
attach.c: In function ‘main’:
attach.c:380:2: error: implicit declaration of function ‘test_lsm_detect’ [-Werror=implicit-function-declaration]
cc1: all warnings being treated as errors
make[3]: *** [attach.o] Error 1
[...]

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agouse snapshot_destroy in tests/snapshot.c and clean up containers after the test run
S.Çağlar Onur [Sat, 19 Oct 2013 04:51:21 +0000 (00:51 -0400)] 
use snapshot_destroy in tests/snapshot.c and clean up containers after the test run

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agointroduce snapshot_destroy
S.Çağlar Onur [Sat, 19 Oct 2013 04:49:20 +0000 (00:49 -0400)] 
introduce snapshot_destroy

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agocall lxc_container_put when needed in lxc_destroy.c
S.Çağlar Onur [Sat, 19 Oct 2013 04:48:08 +0000 (00:48 -0400)] 
call lxc_container_put when needed in lxc_destroy.c

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agochange version to 1.0.0.alpha2 in configure.ac lxc-1.0.0.alpha2
Stéphane Graber [Fri, 18 Oct 2013 22:11:53 +0000 (18:11 -0400)] 
change version to 1.0.0.alpha2 in configure.ac

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxccontainer.c: Replace rindex by strrchr (bionic)
Stéphane Graber [Fri, 18 Oct 2013 22:00:24 +0000 (18:00 -0400)] 
lxccontainer.c: Replace rindex by strrchr (bionic)

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolsm.h: Fix inline definition
Stéphane Graber [Fri, 18 Oct 2013 21:59:43 +0000 (17:59 -0400)] 
lsm.h: Fix inline definition

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agoAllocate cmd string with alloca instead of malloc, close popen handle if fgets fails.
Sidnei da Silva [Fri, 18 Oct 2013 19:35:55 +0000 (16:35 -0300)] 
Allocate cmd string with alloca instead of malloc, close popen handle if fgets fails.

11 years agoDocument the new --thinpool option
Sidnei da Silva [Fri, 18 Oct 2013 19:15:31 +0000 (16:15 -0300)] 
Document the new --thinpool option

11 years agoAdd a --thinpool argument to lxc-create, to use thin pool backed lvm when creating...
Sidnei da Silva [Mon, 19 Aug 2013 22:34:19 +0000 (19:34 -0300)] 
Add a --thinpool argument to lxc-create, to use thin pool backed lvm when creating the container. When cloning a container backed by a thin pool, the clone will default to the same thin pool.

11 years agouse proper config item depending on which lsm is enabled
Dwight Engen [Fri, 18 Oct 2013 18:31:53 +0000 (14:31 -0400)] 
use proper config item depending on which lsm is enabled

On a system with AppArmor enabled, if lxc.se_context is configured but
lxc.aa_profile is not (because the user just wants to use the default
AppArmor profile) lxc was passing the lxc.se_context to be set as the
new AppArmor profile. Determine which configuration item to use based
on which lsm is enabled.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agosupport setting lsm label at exec or immediately
Dwight Engen [Thu, 17 Oct 2013 17:02:49 +0000 (13:02 -0400)] 
support setting lsm label at exec or immediately

- Add attach test cases

- Moved setting of LSM label later to avoid failure of IPC between parent
  and child during attach

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agoadd lsm op for getting name of enabled lsm
Dwight Engen [Fri, 18 Oct 2013 17:44:56 +0000 (13:44 -0400)] 
add lsm op for getting name of enabled lsm

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
11 years agolxc-alpine: enable loopback interface by default
Natanael Copa [Wed, 16 Oct 2013 12:55:31 +0000 (14:55 +0200)] 
lxc-alpine: enable loopback interface by default

It was probably disabled by a mistake

Signed-off-by: Natanael Copa <ncopa@alpinelinux.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
11 years agolxc-start-ephemeral: Fix broken mount logic
Stéphane Graber [Fri, 18 Oct 2013 17:27:46 +0000 (13:27 -0400)] 
lxc-start-ephemeral: Fix broken mount logic

This reworks the mount logic for lxc-start-ephemeral to be as follow:
 - Any real (non-bind) entry gets copied to the target fstab
 - Any bind-mount from a virtual fs gets copied to the target fstab
 - Any remaining bind-mount if confirmed to be valid gets setup as an
   overlay.

Extra bind-mounts passed through the -b option are mounted by the
pre-mount script and don't need processing by the fstab generator.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>