Commit Graph

6412 Commits

Author SHA1 Message Date
Christian Brauner
6c049d3a26
Merge pull request #2055 from marcosps/cgfsng_debug
cgfsng: Add new macro to print errors
2017-12-20 14:19:57 +01:00
Christian Brauner
d1de8ddad1
Merge pull request #2013 from 3XX0/oci-dhcp-improvements
Improve the dhclient hook for OCI compat
2017-12-20 02:48:04 +01:00
Marcos Paulo de Souza
65d78313f2 cgfsng: Add new macro to print errors
At this point, macros such DEBUG or ERROR does not take effect because
this code is called from cgroup_ops_init(cgroup.c), which runs with
__attribute__((constructor)), before any log level is set form any tool
like lxc-start, so these messages are lost.

For now on, use the same LXC_DEBUG_CGFSNG environment variable to
control these messages.

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
2017-12-19 23:43:47 -02:00
Jonathan Calmels
9a962dc622 lxc-oci: add DHCP option leveraging dhclient hooks
Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
2017-12-19 15:18:28 -08:00
Jonathan Calmels
1689c7cf90 lxc-oci: read configuration from oci.common.conf if available
Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
2017-12-19 15:18:28 -08:00
Jonathan Calmels
bbb8e190f1 lxc-net: add LXC_DHCP_PING boolean option
Excerpt from dnsmasq(8):
By default, the DHCP server will attempt to ensure that an address in not
in use before allocating it to a host. It does this by sending an ICMP echo
request (aka "ping") to the address in question. If it gets a reply, then the
address must already be in use, and another is tried. This flag disables this check.

This is useful if one expects all the containers to get an IP address
from the LXC authoritative DHCP server and wants to speed up the process
of getting a lease.

Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
2017-12-19 15:18:28 -08:00
Jonathan Calmels
84bf5645ed hooks: dhclient hook improvements
- Merge dhclient-start and dhclient-stop into a single hook.
- Wait for a lease before returning from the hook.
- Generate a logfile when LXC log level is either DEBUG or TRACE.
- Rely on namespace file descriptors for the stop hook.
- Use settings from /<sysconf>/lxc/dhclient.conf if available.
- Attempt to cleanup if dhclient fails to shutdown properly.

Signed-off-by: Jonathan Calmels <jcalmels@nvidia.com>
2017-12-19 15:18:28 -08:00
Christian Brauner
90f20db15f
Merge pull request #2048 from duguhaotian/master
[monitor] wrong statement of break
2017-12-19 15:09:41 +01:00
Christian Brauner
0720664d93
Merge pull request #2015 from flx42/nvidia-mount-hook
hooks: add mount hook to configure access to NVIDIA GPUs
2017-12-19 15:06:20 +01:00
Christian Brauner
92b17705d0
Merge pull request #2050 from tanyifeng/small_fix
conf.c: small fix for args of mount_entry
2017-12-19 14:24:40 +01:00
Christian Brauner
5305675314
Merge pull request #2053 from tenforward/japanese
Update Japanese lxc.container.conf(5)
2017-12-19 12:07:09 +01:00
KATOH Yasufumi
a0a4f759b2 doc: Add relative option for lxc.mount.entry to Japanese lxc.container.conf(5)
and:
* remove empty paragraph in English man
* untabify in Japanese man

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-19 20:02:46 +09:00
KATOH Yasufumi
b6feb9db85 doc: Translate the hook of network into Japanese in lxc.container.conf(5)
Update for commit 14a7b0f

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-19 20:02:37 +09:00
KATOH Yasufumi
efcbd1a05a doc: Add the description of new style hook to Japanese lxc.containers.conf(5)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-19 20:02:14 +09:00
KATOH Yasufumi
4eeecbdb08 doc: Add proc section to Japanese lxc.container.conf(5)
Update for commit 61d7a73

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-19 20:02:02 +09:00
KATOH Yasufumi
b45e48f097 doc: Add sysctl section to Japanese lxc.container.conf(5)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-19 20:01:41 +09:00
Christian Brauner
4aaf9b81e9
btrfs: fix unprivileged snapshot creation
We already fixed privileged btrfs snapshot creation in:

commit 1c7222c084
Author: Christian Brauner <christian.brauner@ubuntu.com>
Date:   Tue Nov 28 13:51:03 2017 +0100

    btrfs: fix btrfs_snapshot()

    Closes #1956.

    Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
    Signed-off-by: Adrian Reber <areber@redhat.com>

but missed unprivileged btrfs snapshot creation. Fix it too.

Follow-up to #1956.
Closes #2051.

Reported-by: Oleg Freedhom overlayfs@gmail.com
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-19 11:59:52 +01:00
Yifeng Tan
d6bec4ab7b conf.c: small fix for args of mount_entry
Signed-off-by: Yifeng Tan <tanyifeng1@huawei.com>
2017-12-19 17:35:01 +08:00
独孤昊天
94bc08e9ed [monitor] wrong statement of break
if lxc_abstract_unix_connect fail and return -1,  this code never goto retry.

Signed-off-by: liuhao <liuhao27@huawei.com>
2017-12-19 16:51:35 +08:00
Felix Abecassis
58e29e9bf1 hooks: add mount hook to configure access to NVIDIA GPUs
This hook requires the nvidia-container-cli tool provided by libnvidia-container:
https://github.com/nvidia/libnvidia-container

For containers that do not have CUDA_VERSION or NVIDIA_VISIBLE_DEVICES
set in the environment, the hook will be a no-op.

To enable in the configuration file:
lxc.hook.mount = /usr/local/share/lxc/hooks/nvidia

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-12-18 16:17:23 -08:00
Serge Hallyn
9668d2cd15
Merge pull request #2049 from brauner/2017-12-18/start_reap_attacher_process
start: reap intermediate process
2017-12-18 10:49:50 -06:00
Christian Brauner
4e23246652
start: reap intermediate process
When we inherit namespaces we need to reap the attaching process.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-18 14:08:54 +01:00
Christian Brauner
9aff2c83e4
Merge pull request #2031 from tanyifeng/mask_and_readonly_path
conf.c: add relative option for lxc.mount.entry
2017-12-18 12:12:59 +01:00
Yifeng Tan
181437fd53 conf.c: add relative option for lxc.mount.entry
Signed-off-by: Yifeng Tan <tanyifeng1@huawei.com>
2017-12-19 01:07:46 +08:00
Christian Brauner
72c94ff968
tools: add UNPRIVILEGED field in fancy output mode
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-16 13:10:47 +01:00
Serge Hallyn
e44465303c
Merge pull request #2040 from brauner/2017-12-14/bugfixes
lxc_init: fix cgroup parsing
2017-12-14 20:10:39 -06:00
Serge Hallyn
f76d0ecb47
Merge pull request #2034 from brauner/2017-12-14/use_clone_in_run_command
utils: use lxc_raw_clone() in run_command()
2017-12-14 16:29:04 -06:00
Christian Brauner
1933b53f59
lxc_init: fix cgroup parsing
coverity: #1426132
coverity: #1426133

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 23:28:53 +01:00
Christian Brauner
f4bdebfd8e
tools: add missing break to lxc-execute
coverity: #1426131

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 23:28:44 +01:00
Serge Hallyn
389c46753b
Merge pull request #2039 from brauner/2017-12-14/fix_command_socket_race
commands: fix race when open()/close() cmd socket
2017-12-14 15:56:24 -06:00
Christian Brauner
2d728b2fd6
utils: use lxc_raw_clone() in run_command()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 22:18:28 +01:00
Christian Brauner
8ab93249a0
namespace: add lxc_raw_clone()
This is based on raw_clone in systemd but adapted to our needs. The main reason
is that we need an implementation of fork()/clone() that does guarantee us that
no pthread_atfork() handlers are run. While clone() in glibc currently doesn't
run pthread_atfork() handlers we should be fine but there's no guarantee that
this won't be the case in the future. So let's do the syscall directly - or as
direct as we can. An additional nice feature is that we get fork() behavior,
i.e. lxc_raw_clone() returns 0 in the child and the child pid in the parent.

Our implementation tries to make sure that we cover all cases according to
kernel sources. Note that we are not interested in any arguments that could be
passed after the stack.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 22:18:28 +01:00
Christian Brauner
ec09a5a2de
Merge pull request #2008 from tych0/share-ns-in-execute
add --share-$NS= support to lxc-execute
2017-12-14 21:37:41 +01:00
Christian Brauner
2e3890af0f
Merge pull request #2037 from hallyn/2017-12-14/dir_detect_eperm
dir_detect: warn on eperm
2017-12-14 21:07:22 +01:00
Christian Brauner
1240152866
Merge pull request #2035 from adrianreber/master
criu: add feature check capability
2017-12-14 21:06:17 +01:00
Christian Brauner
f893d89807
commands: fix race when open()/close() cmd socket
When we report STOPPED to a caller and then close the command socket it is
technically possible - and I've seen this happen on the test builders - that a
container start() right after a wait() will receive ECONNREFUSED because it
called open() before we close(). So for all new state clients simply close the
command socket. This will inform all state clients that the container is
STOPPED and also prevents a race between a open()/close() on the command socket
causing a new process to get ECONNREFUSED because we haven't yet closed the
command socket.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 20:57:15 +01:00
Adrian Reber
739ef90c82
criu: add a test case for the criu feature check support
This adds a simple test case which verifies that the new migrate() API
command 'MIGRATE_FEATURE_CHECK' works as expected.

If a feature does not exist on the currently running
architecture/kernel/criu combination it does not report an error as this
is a valid scenario.

Signed-off-by: Adrian Reber <areber@redhat.com>
2017-12-14 20:34:51 +01:00
Adrian Reber
b5b12b9e75
criu: add feature check capability
For migration optimization features like pre-copy or post-copy migration
the support cannot be determined by simply looking at the CRIU version.
Features like that depend on the architecture/kernel/criu combination
and CRIU offers a feature checking interface to query if it is
supported.

This adds a LXC interface to query CRIU for those feature via the
migrate() API call. For the recent pre-copy migration support in LXD
this can be used to automatically detect if pre-copy migration should be
used.

In addition to the existing migrate() API commands this adds a new
command: 'MIGRATE_FEATURE_CHECK'.

The migrate_opts{} structure is extended by the member features_to_check
which is a bitmask defining which CRIU features should be queried.

Currently only the querying of the features FEATURE_MEM_TRACK and
FEATURE_LAZY_PAGES is supported.

Signed-off-by: Adrian Reber <areber@redhat.com>
2017-12-14 20:34:51 +01:00
Serge Hallyn
3d8869c369 dir_detect: warn on eperm
if user has lxc.rootfs.path = /some/path/foo, but can't access
some piece of that path, then we'll get an unhelpful "failed to
mount" without any indication of the problem.

At least show that there is a permission problem.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2017-12-14 13:32:14 -06:00
Tycho Andersen
c379af4c03 the bike shed should be brilliant purple
Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2017-12-14 17:38:16 +00:00
Serge Hallyn
81b10e37c9
Merge pull request #2026 from brauner/2017-12-12/lxc_hook_version
confile: add lxc.hook.version
2017-12-14 09:27:46 -06:00
Christian Brauner
990b9ac345
network: pass name of peer veth device
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 14:41:35 +01:00
Christian Brauner
d08e57088e
conf: simplify run_script_argv()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 14:41:35 +01:00
Christian Brauner
14a7b0f98a
network: pass info in env if hook version is 1
Unblocks #2013.
Unblocks #2015.
Closes #1766.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 11:54:13 +01:00
Christian Brauner
18b3b9c17f
start: pass namespaces as environment variables
Unblocks #2013.
Unblocks #2015.
Closes #1766.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 11:52:09 +01:00
Christian Brauner
3f60c2f749
conf: execute hooks based on lxc.hooks.version
Unblocks #2013.
Unblocks #2015.
Closes #1766.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 11:52:07 +01:00
Christian Brauner
a2c09be066
start: set LXC_HOOK_VERSION
This can be used by scripts to detect what version of the hooks are used.

Unblocks #2013.
Unblocks #2015.
Closes #1766.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 11:47:36 +01:00
Christian Brauner
44ae0fb6ca
confile: add lxc.hook.version
Unblocks #2013.
Unblocks #2015.
Closes #1766.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-14 11:47:34 +01:00
Serge Hallyn
45acc1bd8c
Merge pull request #2030 from brauner/2017-12-13/fix_cgroup_namsepace_recording
start: fix cgroup namespace preservation
2017-12-14 00:45:52 -06:00
Tycho Andersen
eeeb5865f5 SHARE_NS options should be before OPT_USAGE
Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2017-12-14 00:57:48 +00:00