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>
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>
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>
api_create: undo unneeded chunk in previous commit

lxc_conf exists after api_save_config

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
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>
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>
remove a few noisy, unhelpful INFOs in detect_shared_rootfs()

They are a nuisance.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Only include execinfo.h if MUTEX_DEBUGGING is set

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Fix tests on Android

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