Commit Graph

2861 Commits

Author SHA1 Message Date
S.Çağlar Onur
d380c7ff55 free previously allocated memory if realloc fails in src/lxc/lsm/apparmor.c
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2013-11-18 10:47:45 -05:00
KATOH Yasufumi
6127da6b3f Improve Japanese man pages
Improve the consistency of expression

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-18 10:45:20 -05:00
Nikola Kotur
c1c2297ba4 lxc-lua: LFS library is not being used
Signed-off-by: Nikola Kotur <kotnick@gmail.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2013-11-18 10:44:33 -05:00
S.Çağlar Onur
9992b49cde fix memory leaks reported by cppcheck in src/lxc/lxc_monitor.c. Since this is a cli tool it doesn't really matter but might silence some warnings for debugging
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-18 09:32:14 -06:00
S.Çağlar Onur
c6a9b0d797 add missing paranthesis (v2)
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-18 09:29:27 -06:00
S.Çağlar Onur
9529609a81 fix memory leaks reported by cppcheck in src/lxc/bdev.c
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-18 09:28:43 -06:00
Stéphane Graber
dceb6c8018
change version to 1.0.0.alpha3 in configure.ac
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-15 16:08:17 -05:00
Stéphane Graber
5444216b7e lxc-info: Rework based on mailinglist thread
So this implements the changes we discussed yesterday:
 - Only one container may be queried at the time
 - -n is now required once again
 - -H + a single filter only returns the value
 - -t/--is-state is now removed

Note that -S is considered as more than a single filter, so -H in that
case only affects the formatting of the values.

For the same reason, I haven't yet implemented the -H + multiple filters
case which we said should return a simple "key: value" output as it
wasn't trivial to re-arrange the stats code to print a different format
(for the other options, it's just a two lines change in the print
functions).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Dwight Engen <dwight.engen@oracle.com>
2013-11-15 16:06:49 -05:00
Serge Hallyn
4df7f012b9 lxc-start: if we pass in a config file, then don't use any loaded config
To do this, add a c->clear_config() helper to the api.

(this fixes the bug https://bugs.launchpad.net/bugs/1251352)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-14 13:27:22 -06:00
S.Çağlar Onur
41f683579c gather all locking related code into src/lxc/lxclock.c
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-14 12:00:58 -06:00
Bogdan Purcareata
b466dc337c setup_netdev: re-read ifindex in LXC_NET_PHYS case
When moving an interface from the host netns to a container's,
the ifindex might not remain the same. This happens when the
index of the host interface is already assigned to another interface
in the new netns.

For veth/vlan/macvlan, virtual interfaces are first created on the host,
and then moved in the container. Since they are created after all other
interfaces are discovered, there is no chance for its assigned ifindex
to be already present in a freshly created netns, because it's a greater
number.

However, when moving a physical interface, there is a chance that its
ifindex in the host netns is not free in the new netns. The patch
forces ifindex re-read for the LXC_NET_PHYS case to update the
lxc_netdev structure.

Signed-off-by: Bogdan Purcareata <bogdan.purcareata@freescale.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-14 09:25:09 -06:00
Marek Majkowski
304dc8b3ff Cosmetic: shorten the options summary in documentation 2013-11-13 07:04:27 -08:00
S.Çağlar Onur
a9a0ed90dd introduce lxcapi_add_device_node and lxcapi_remove_device_node to API (v3)
Adding block/char devices to running container is a common operation so
provide a common implementation for users to consume.

changes since v2;
* lets the user set an alternate path inside the container as Stéphane suggested

changes since v1;
* removed duplicated code

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-13 10:00:29 -05:00
Marek Majkowski
6c544cb300 Make it possible to share UTS namespace 2013-11-13 05:20:26 -08:00
KATOH Yasufumi
28254e6380 doc: Update Japanese lxc-info(1) for printing statistics
Update for commit b9d957c316

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-12 16:05:13 -05:00
KATOH Yasufumi
56390ccb57 doc: Update Japanese lxc-top(1) for kernel memory accounting.
Update for commit 2752ecec32

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-12 16:04:57 -05:00
pc-wurm
41ace3de7a Update lxc_create.c corrected argument usage example for -t
I think '-t timeout' was mistakenly written, so I corrected it to '-t
template', since the -t argument is used for setting templates, not
timeout as far as I know.

Signed-off-by: pc-wurm <yordanov@pc-wurm.de>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-12 16:03:55 -05:00
Stéphane Graber
d59feca3be lxc-ubuntu*: Mark non-essential mounts optional
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-12 14:45:53 -06:00
Dwight Engen
68c9cf3668 add process_lock()/unlock() in save_config()
This is likely unnecessary, but is consistent with other uses of
fopen()/fclose() in lxc.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-12 14:43:43 -06:00
Dwight Engen
6c6892b5c5 fix multithreaded create()
We were calling save_config() twice within the create() flow, each
from a different process. Depending on order of scheduling, sometimes
the data from the first save_config() (which was just the stuff from
LXC_DEFAULT_CONFIG) would overwrite the config we wanted (the full
config), causing a truncated config file which would then cause lxc
to segfault once it read it back in because no rootfs.path was set.

This fixes it by only calling save_config() once in the create()
flow. A rejected alternative was to call fsync(fileno(fout)) before
the fclose in save_config.

Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2013-11-12 14:43:31 -06:00
Marek Majkowski
4692616518 Refactoring - make the option parsing code generic 2013-11-12 08:19:55 -08:00
Marek Majkowski
f805988068 Fix memory leak in pid_from_lxcname and use ns_proc_name in open_ns. 2013-11-12 07:06:23 -08:00
Marek Majkowski
3d67411d7f Merge remote-tracking branch 'lxc/master' into share-namespaces 2013-11-12 06:13:37 -08:00
Marek Majkowski
3c93577b43 Create --share-ipc option 2013-11-12 05:14:25 -08:00
Marek Majkowski
d4afa44076 Cosmetic. 2013-11-12 05:13:53 -08:00
Marek Majkowski
11373487a1 Describe --share-net in the lxc-start manual 2013-11-12 05:13:33 -08:00
Marek Majkowski
38521a3b5d Cosmetic - clean up error message 2013-11-12 03:50:26 -08:00
Serge Hallyn
bdb3f44147 lxc_abstract_unix_connect: accomodate containers started before Oct 28
commit aae93dd3dd 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>
2013-11-11 15:27:04 -06:00
Marek Majkowski
02b4f2e1d8 Allow specifying a container by name or pid in --share-net option. 2013-11-11 05:19:29 -08:00
Dwight Engen
293ec75883 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>
2013-11-08 15:07:34 -06:00
Serge Hallyn
03f064ff74 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>
2013-11-08 13:31:51 -06:00
Serge Hallyn
2d834aa807 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>
2013-11-08 10:04:21 -06:00
Qiang Huang
94d942c3d2 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>
2013-11-07 22:25:26 -06:00
Marek Majkowski
9f30a19089 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.
2013-11-06 15:16:33 -08:00
Dwight Engen
9beb9ce0ef 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>
2013-11-06 09:37:21 -06:00
Serge Hallyn
4119204eef 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>
2013-11-06 09:04:13 -06:00
Serge Hallyn
57d116ab50 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>
2013-11-06 09:04:06 -06:00
Dwight Engen
b9d957c316 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>
2013-11-06 08:15:13 -06:00
Dwight Engen
148a9d276c 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>
2013-11-06 08:11:21 -06:00
Dwight Engen
2c319dbfb5 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>
2013-11-06 08:11:20 -06:00
Dwight Engen
2871830a40 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>
2013-11-06 08:10:54 -06:00
Stéphane Graber
4012c89148
Fix tests on Android
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-05 22:43:38 -05:00
Stéphane Graber
3da0feef09
Only include execinfo.h if MUTEX_DEBUGGING is set
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2013-11-05 14:30:30 -05:00
Dwight Engen
c9bb9a85ef 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>
2013-11-05 12:31:59 -05:00
Dwight Engen
8585f20444 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>
2013-11-05 12:31:48 -05:00
Dwight Engen
6502006a44 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>
2013-11-05 12:31:40 -05:00
Dwight Engen
2752ecec32 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>
2013-11-04 06:37:11 -06:00
Dwight Engen
891f838ba8 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>
2013-11-04 06:37:10 -06:00
Dwight Engen
80ee22284b 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>
2013-11-04 06:37:08 -06:00
S.Çağlar Onur
b12e1cb533 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>
2013-11-04 06:24:16 -06:00