Commit Graph

458 Commits

Author SHA1 Message Date
Christian Brauner
1452d3fe06
lxccontainer: push_arg()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:31 +01:00
Christian Brauner
6b0297e327
lxccontainer: am_single_threaded()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:30 +01:00
Christian Brauner
e202dfb821
lxccontainer: do_lxcapi_wait()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:29 +01:00
Christian Brauner
871ed23baa
lxccontainer: do_lxcapi_want_close_all_fds()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:27 +01:00
Christian Brauner
fb5999f65f
lxccontainer: do_lxcapi_want_daemonize()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:26 +01:00
Christian Brauner
d03ab308a7
lxccontainer: do_lxcapi_load_config()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:25 +01:00
Christian Brauner
e3246ab9c8
lxccontainer: load_config_locked()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:24 +01:00
Christian Brauner
49cfedb329
lxccontainer: lxcapi_console()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:23 +01:00
Christian Brauner
37dce81753
lxccontainer: do_lxcapi_console_getfd()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:22 +01:00
Christian Brauner
8e59e0bab2
lxccontainer: do_lxcapi_unfreeze()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:20 +01:00
Christian Brauner
8787b387db
lxccontainer: do_lxcapi_freeze()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:19 +01:00
Christian Brauner
1b61062fa7
lxccontainer: do_lxcapi_is_running()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:18 +01:00
Christian Brauner
5bddcb62d2
lxccontainer: is_stopped()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:17 +01:00
Christian Brauner
b547d79fb9
lxccontainer: do_lxcapi_state()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:14 +01:00
Christian Brauner
428ad142f2
lxccontainer: do_lxcapi_is_defined()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:13 +01:00
Christian Brauner
045552aabe
lxccontainer: lxc_container_{get,put}()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:11 +01:00
Christian Brauner
70849dc234
lxccontainer: lxc_container_free()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:10 +01:00
Christian Brauner
a3740e805a
lxccontainer: create_partial()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:09 +01:00
Christian Brauner
f5cd0252f7
lxccontainer: create_partial()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:07 +01:00
Christian Brauner
444249ea2f
lxccontainer: ongoing_create()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:06 +01:00
Christian Brauner
ef1ab8f10d
lxccontainer: config_file_exists()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:05 +01:00
Christian Brauner
238b3e5ea4
lxccontainer: move macros to utils.h
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:03 +01:00
Christian Brauner
0e1a60b0fb
lxccontainer: do_lxcapi_save_config()
If liblxc is used multi-threaded do_lxcapi_save_config() could be called from
threads that fork() which to not risk ending up with invalid locking states we
should avoid using functions like fopen() that internally allocate memory and
use locking. Let's replace it with the async-signal safe combination of
open() + write().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:38:02 +01:00
Christian Brauner
8d7b6c25af
lxccontainer: do_lxcapi_detach_interface()
thread-safety: s/exit()/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:52 +01:00
Christian Brauner
a7764ce792
lxccontainer: do_add_remove_node()
thread-safety: s/exit()/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:51 +01:00
Christian Brauner
d8480a31b4
lxccontainer: do_lxcapi_clone()
thread-safety: s/exit()/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:50 +01:00
Christian Brauner
fe1ce58c9a
lxccontainer: do_lxcapi_get_ips()
thread-safety: s/exit/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:49 +01:00
Christian Brauner
02c611b013
lxccontainer: do_lxcapi_get_interfaces()
thread-safety: s/exit()/_exit/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:47 +01:00
Christian Brauner
85aec4aca7
lxccontainer: do_lxcapi_create()
thread-safety: s/exit()/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:46 +01:00
Christian Brauner
47e558874c
lxccontainer: non-functional changes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:45 +01:00
Christian Brauner
7e34710e5d
lxccontainer: non-functional changes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:44 +01:00
Christian Brauner
eb70aaf0d6
lxccontainer: create_run_template()
thread_safety: s/exit()/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:42 +01:00
Christian Brauner
d608fbdadb
lxccontainer: do_lxcapi_start()
thread-safety: s/exit()/_exit()/g

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:41 +01:00
Christian Brauner
9994d1402c
confile: use mmap() to parse config file
Sigh, this is going to be fun. Essentially, dynamic memory allocation through
malloc() and friends is unsafe when fork()ing in threads. The locking state
that glibc maintains internally might get messed up when the process that
fork()ed calls malloc or calls functions that malloc() internally. Functions
that internally malloc() include fopen(). One solution here is to use open() +
mmap() instead of fopen() + getline().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-24 21:37:39 +01:00
Christian Brauner
01c1b11e45
lxccontainer: use wait_for_pid()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-18 21:43:46 +01:00
Christian Brauner
6fba98b524
tree-wide: remove legacy codepaths
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-11 23:56:56 +01:00
Christian Brauner
cb8ff4d033
lxccontainer: satisfy coverity
The container name can't be NULL so don't give coverity the impression that it
could be.

Silences coverity #1426123.
Silences coverity #1426124.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-02-09 10:37:53 +01:00
Serge Hallyn
e0010464c7 Restore most cases of am_guest_unpriv
The only cases where we really need to be privileged with respect
to the host is when we are trying to mknod, and in some cases
to do with a physical network device.  This patch leaves the
detection of the network device cases as a TODO.

This should fix the currently broken case of starting a privileged
container with at least one veth nic, nested inside an unprivileged
container.

Cc: Tycho Andersen <tycho@tycho.ws>
Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2018-02-08 13:06:52 -06:00
Tycho Andersen
5384e99dee rename am_unpriv to am_host_unpriv
Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2018-01-26 22:11:50 +00:00
Tycho Andersen
cd5177e9e3 remember the exit code from the init process
error_num seems to be trying to remember the exit code of the init process,
except that nothing actually keeps track of it anywhere. So, let's add a
field to the handler, so that we can keep track of the process' exit
status, and the propagate it to error_num in struct lxc_container so that
people can use it.

Note that this is a slight behavior change, essentially instead of making
error_num always == the return code from start, now it contains slightly
more useful information (the actual exit status). But, there is only one
internal user of error_num which I'll fix in later in the series, so IMO
this is ok.

Signed-off-by: Tycho Andersen <tycho@tycho.ws>
2018-01-19 03:44:24 +00:00
LiFeng
ee2d7093f0 Add return check for 'lxc_cmd_get_name'
If 'lxc_cmd_get_name' failed and return with NULL, this would cause a segment fault.

Signed-off-by: LiFeng <lifeng68@huawei.com>
2018-01-08 14:26:00 -05:00
Christian Brauner
d393e64525
lxccontainer: revert set_running_config_item()
- As discussed we will have a proper API extension that will allow updating
  various parts of a running container. The prior approach wasn't a good idea.

- Revert this is not a problem since we haven't released any version with the
  set_running_config_item() API extension.

- I'm not simply reverting so that master users can still call into new
  liblxc's without crashing the container. This is achieved by keeping the
  commands callback struct member number identical.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2018-01-01 21:58:09 +01:00
Christian Brauner
0059379ff4
tree-wide: s/getpid()/lxc_raw_getpid()/g
This is to avoid bad surprises caused by older glibc's pid cache (up to 2.25)
when using clone().

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-21 23:01:03 +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
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
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
Stéphane Graber
941ee1fe2a
Merge pull request #2017 from brauner/generic/patch_testing
coverity: bugfixes
2017-12-13 13:26:32 -05:00
Christian Brauner
d5590c8c70
coverity: #1425860
remove logically dead code

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-12 11:55:55 +01:00
Christian Brauner
6a0019fa97
coverity: #1425863
remove logically dead code

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-12 11:55:54 +01:00
Christian Brauner
c7d76c0947
lxccontainer: cleanup {attach,detach}_interface()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-12 11:54:21 +01:00