Commit Graph

2861 Commits

Author SHA1 Message Date
Serge Hallyn
f6ac3b9eca Revert "cgroupfs: get rid of the redundant error info"
This reverts commit a8117b3361.
2014-01-23 13:02:15 -06:00
Serge Hallyn
fec822c4a0 Revert "cgroupfs: need the full path to setup cpuset"
This reverts commit 47f5ede0ec.
2014-01-23 13:02:08 -06:00
Stéphane Graber
ff5e275105 doc: Add manpage for lxc-config
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-23 12:51:47 -05:00
Qiang Huang
47f5ede0ec cgroupfs: need the full path to setup cpuset
Function file_exists() needs a absolute full path, but we are using
current_entire_path which is not. It will get the wrong result from
file_exists() and case Segmentation fault when we fopen a non-exist
file and try to fscanf from it.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-23 11:21:34 -06:00
Qiang Huang
a8117b3361 cgroupfs: get rid of the redundant error info
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-23 11:18:07 -06:00
KATOH Yasufumi
fb261f53fc doc: Add Japanese lxc.container.conf(5), lxc.system.conf(5) and update lxc.conf(5)
* update for commit 55fc19a104
* fix typo in English lxc.system.conf(5)

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.coM>
2014-01-23 10:53:06 -05:00
Qiang Huang
032e28b767 cgroup.c: clean up for handle_cgroup_settings
Clean up the nesting if, make the logic similar for memory
and cpuset, and the error message should sent from inside,
for better extendibility.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 21:25:35 -06:00
Stéphane Graber
55fc19a104 doc: Try to clear some confusion about lxc.conf
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 22:16:20 -05:00
Stéphane Graber
ffa0e610dc lxc-start-ephemeral: require root
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 22:15:20 -05:00
Serge Hallyn
bba1fbe695 lxc_init: don't fail on bad signals
Changelog: Jan 22: as Michael Warfield pointed out, we should only
ignore EINVAL, since EFAULT points to a more serious problem.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 21:55:09 -05:00
Stéphane Graber
86f0eb65a0 bionic: Replace rindex by strrchr
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 21:25:29 -05:00
Serge Hallyn
0a4d93787d cgroupfs: support older kernels without cgroup.clone_children
When creating a cgroup, detect whether cgroup.clone_children
exists.  If not, then manually copy the parent's cpuset.cpus
and cpuset.mems values.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 20:01:36 -05:00
KATOH Yasufumi
8c3a756ed4 plamo: Improve template
allow not to specify a variable that is related installed packages

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 19:57:53 -05:00
Qiang Huang
6eaac3034e daemon: fix the wrong pid in daemon model
When you start a container in daemon model, you have at least
3 processes:
 1. The command the user start (lxc-start -d)
 2. The backgrounded fork of that command after start() is done
 3. The container init process

In PID file, we need (2), but currently we are writing (1),
this is wrong because (1) exits as soon as the container is
started, it's complately useless.

So we write pid after daemonize, so that we'll always write
the right pid to PID file.

Reported-by: Stephane Graber <stgraber@ubuntu.com>
Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 19:53:22 -05:00
Qiang Huang
72cf75fa33 lxc-start: store PID file to lxc_container
So we can remove PID file untill lxc_container_free.

This also fix bug: https://github.com/lxc/lxc/issues/89

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 19:51:45 -05:00
Serge Hallyn
844f7a3874 api_start: don't get a container reference for the daemonized case
In the daemonized case we will fork, so the anonymous container memlock
will not be shared between parent and child.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 18:28:13 -06:00
Stéphane Graber
2eee1b96c6 Fix handling of empty config keys
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 19:24:47 -05:00
Serge Hallyn
87b86add6c cgmanager: cgm_set: return the length we found
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 15:19:59 -05:00
Dwight Engen
e0f2f5c764 lxc.spec: package bash completion, lxc-monitord move
Signed-off-by: Dwight Engen <dwight.engen@oracle.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 15:19:59 -05:00
Serge Hallyn
358afd840d lxcapi_get_interfaces and lxcapi_get_ips: stricter read check
Coverity warns of the danger of a short read otherwise.

(Untested, but should be correct; Tossing over to you :)

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Cc: S.Çağlar Onur <caglar@10ur.org>
Acked-by: S.Çağlar Onur <caglar@10ur.org>
2014-01-22 13:57:00 -06:00
Stéphane Graber
b0f0932a94 lxc-download: Add interactive mode
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 14:52:34 -05:00
Serge Hallyn
c4e9c69f51 coverity: free gw when not used
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 13:04:42 -06:00
Serge Hallyn
452c91416b coverity: close userns file when done
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 13:02:42 -06:00
Serge Hallyn
32f4b9c77c coverity: close netns file when done
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 12:57:53 -06:00
Serge Hallyn
d966dd14f0 cgmanager: setup_limits: return true if there are no settings
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 12:39:45 -06:00
Stéphane Graber
2177dbc7e0 lxc-info: Limit information when not running
Don't try to print the PID, IP addresses or statistics for a container
that's not current running.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 13:38:50 -05:00
Stéphane Graber
7f12cae956 Remove lxc-version, lxc-ps and lxc-netstat
lxc-ps and lxc-netstat have an unfortunate tendency to break every so
often, produce mostly unreadable output and should be replaced by a
lxc-attach call in 99% of the cases.

In an effort to cleanup the lxc-* namespace, I think those two should
go, so this patch gets rid of them as well as any reference to them in
our documentation.

I also think that lxc-version should disappear as it's only a one line
shell script printing the version string, so having a whole command just
for that seems to be a bit of a waste.

Instead, this patch introduces a new --version common option which all
binaries will automatically inherit and that'll print LXC_VERSION on
stdout and exit 0.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 13:38:46 -05:00
Stéphane Graber
0306de4f28 Add bash auto completion
This adds a basic bash auto-completion profile.

It supports 3 things at this time:
 - Auto-complete of container name (-n or -o)
 - Auto-complete of template name (-t)
 - Auto-complete of state names (-s)

It's configured in a way to be as little disruptive as possible, any
argument that's not explicitly handled by the profile will fallack to
bash's default completion.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-22 12:23:08 -05:00
Stéphane Graber
21384986d2
Unset lxc.devttydir for userns CentOS
Without this, the container entirely fails to start.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-22 11:38:59 -05:00
Michael H. Warfield
1ecee40b7d Update Fedora and CentOS templates for common conf includes.
This updates the Fedora and CentOS templates to utilize a common
included config.  This is largely based on the changes in the Oracle
template with some exceptions.

Dropping of setpcap (present in the Oracle template) is commented out in
the Fedora template.  It seems to cause problems, such as large login
delays with Fedora 20 containers (but not Fedora 19 - strange).

The Fedora template is further modified to disable systemd-journald.service
as it is unnecessary in a container and causes serious problems when
running in a Fedora 20 container.

The Fedora template is also updated to default to Fedora 20 when running
on a non-Fedora host.

Regards,
Mike

Signed-off-by: Michael H. Warfield <mhw@WittsEnd.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-21 20:25:55 -05:00
S.Çağlar Onur
ae22a22064 make lxcapi_get_interfaces and lxcapi_get_ips unprivileged container aware
Based on Stéphane's suggestion, those two API methods now;

* fork a new process,
* switch to appropriate namespace(s),
* do what we want,
* return the data over a pipe to the parent which returns the result to the original caller.

For the whole thread please see;

 https://lists.linuxcontainers.org/pipermail/lxc-devel/2014-January/007362.html

This patch also makes lxc-ls and lxc-info call those functions.

I'm adding Stéphane as an author here since both the idea as well as
the initial setns code come from him.

Author: S.Çağlar Onur <caglar@10ur.org>
Author: Stéphane Graber <stgraber@ubuntu.com>
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-21 20:11:27 -05:00
KATOH Yasufumi
adf4b40833 plamo: Improve template
Allow to specify additional packages

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-21 09:51:25 -05:00
S.Çağlar Onur
c4b9dc3bdd remove no-longer neeeded check from lxcapi_attach_run_waitl
commit f436448445 introduced attach
functionality to unprivileged containers so remove this check like
the rest of the attach functions.

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 23:49:49 -05:00
Stéphane Graber
45e854dc86 Move lxc-user-nic and lxc-monitord to libexec
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-20 23:27:16 -05:00
Stéphane Graber
f407c5e4c1 utils: Drop trailing / in lxcpath
This fixes command line tools and functions which use
lxc_global_config_value o get lxcpath but don't strip the trailing /
leading to mismatching command path (as lxc_container_new does strip the
path).

As lxcpath is typically a const and so can't easily be changed by the
caller, add the trick directly into lxc_global_config_value (having to
juggle a bit in there too to avoid trying to alter a const).

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-20 23:11:54 -05:00
Stéphane Graber
f436448445 attach: Support unprivileged containers
This change makes lxc-attach and the matching API functions work
properly with unprivileged containers.

The trick needed to make that possible was to always start with the
userns when attaching and also relocate the cgroup management code so
that the intermediate process is moved to the cgroup before attaching to
the container's namespace as doing so later would fail due to missing
permissions.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-20 23:10:24 -05:00
Stéphane Graber
dbfa71289d
Add missing doxygen tag
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 22:01:08 -05:00
Dimitri John Ledkov
4b954f1217 lxc-ubuntu-cloud: Default to trying released channel
This adds a fallback to the daily channel if an image couldn't be found
in the released one.

Signed-off-by: Dimitri John Ledkov <dimitri.ledkov@canonical.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 22:00:32 -05:00
Robert Vogelgesang
89addaa75d Don't forget network prefix information
Include the IPv4/IPv6 prefix if it's set.

Signed-off-by: Robert Vogelgesang <vogel@users.sourceforge.net>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 15:17:45 -05:00
S.Çağlar Onur
c868b261b2 handle unprivileged user calls more gracefully (v3)
Return an error if the function is not supposed to be called by an unprivileged user.
Otherwise those calls fail in the middle of their execution with different reasons.

changes since v2:
- am_unpriv is now a simple geteuid check,
- API functions are now providing error messages,
- lxc-info, lxc-attach are now checking geteuidi,
- lxc-ls is now calling get_ips only if the container is running

Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 15:14:44 -05:00
Serge Hallyn
9daf6f5d01 cgmanager: implement setting of cgroup limits
Also replace a wrong free of nih-allocated variable with nih_free.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 15:14:41 -05:00
KATOH Yasufumi
755d8d03b1 Add Japanese lxc-usernsexec(1) and fix typo English lxc-usernsexec(1)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 10:09:05 -05:00
KATOH Yasufumi
2bec0e1bc9 doc: Remove the description of lxc-kill in Japanese lxc-execute(1)
Update for commit 33ddfc2ade

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-20 10:09:03 -05:00
Stéphane Graber
05e5d7dc9b Revert "lxc-start: fix the container leak when daemonize"
This reverts commit c3f0f139e1.

Done as Serge Hallyn's request:
 Nacked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-19 12:31:57 -05:00
Serge Hallyn
ecc357ca08 cgmanager: &existed for remove+create now returns -1 on failure
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2014-01-19 11:17:22 -06:00
Qiang Huang
c3f0f139e1 lxc-start: fix the container leak when daemonize
When start container with daemon model, we'll have a new daemon
process in lxcapi_start, whose c->numthreads is 2, inherited
from his father. Even his father return to main(), the
lxc_container_put won't affect son's numthreads.

So when daemon stops, he should return to main and do
lxc_container_put again, rather than exit and leave the
container alone.

Signed-off-by: Qiang Huang <h.huangqiang@huawei.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-18 19:57:39 -05:00
KATOH Yasufumi
7a49a081dd plamo: Improve template
* make simple
* change default download site to http://ftp.ring.gr.jp

Signed-off-by: TAMUKI Shoichi <tamuki@linet.gr.jp>
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-18 10:17:33 -05:00
Stéphane Graber
33ddfc2ade Deprecate lxc-checkpoint, lxc-kill and lxc-restart
Checkpoint/restart isn't currently supported, so let's not carry those
binaries around until we have proper CRIU support in the API.

lxc-kill is redundant with lxc-stop -k and has been known to confuse user.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
2014-01-18 10:13:50 -05:00
Serge Hallyn
adade80c7e lxc-usernsexec: add a manpage
and fix the help output in the program

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-17 18:47:01 -05:00
KATOH Yasufumi
348cb247db doc: Update Japanese lxc-ls(1) for -f and -F option
Update for commit c5afb6e455

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
Acked-by: Stéphane Graber <stgraber@ubuntu.com>
2014-01-17 11:14:27 -05:00