Commit Graph

6355 Commits

Author SHA1 Message Date
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
Tycho Andersen
d76e3e1a5b init: don't kill(-1) if we aren't in a pid ns
...otherwise we'll kill everyone on the machine. Instead, let's explicitly
try to kill our children. Let's do a best effort against fork bombs by
disabling forking via the pids cgroup if it exists. This is best effort for
a number of reasons:

* the pids cgroup may not be available
* the container may have bind mounted /dev/null over pids.max, so the write
  doesn't do anything

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2017-12-14 00:26:02 +00:00
Stéphane Graber
941ee1fe2a
Merge pull request #2017 from brauner/generic/patch_testing
coverity: bugfixes
2017-12-13 13:26:32 -05:00
Stéphane Graber
352e79d458
Merge pull request #2025 from brauner/2017-12-12/fix_network_attach_and_detach
lxccontainer: only attach netns on netdev detach
2017-12-13 13:22:31 -05:00
Stéphane Graber
1370036089
Merge pull request #2024 from brauner/2017-11-12/fix_lxc_execute
tools: block using lxc-execute without config file
2017-12-13 13:03:42 -05:00
Stéphane Graber
d987c5da4d
Merge pull request #2022 from 3XX0/exec-run-script
conf: avoid spawning unnecessary subshells
2017-12-13 13:02:03 -05:00
Stéphane Graber
5875fa24a4
Merge pull request #2029 from brauner/2017-12-12/do_not_unconditionally_dup_stdfds_for_execute
start: do not unconditionally dup std{in,out,err}
2017-12-13 12:58:58 -05:00
Christian Brauner
547dfee335
Merge pull request #2010 from tanyifeng/set_oom_score_adj
confile: add lxc.proc.* to set proc filesystem
2017-12-13 11:24:47 +01:00