Commit Graph

6045 Commits

Author SHA1 Message Date
Felix Abecassis
e86dcc912f lxc-oci: add basic handling of numerical uid/gid
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-12-08 19:36:40 -08:00
Serge Hallyn
f6812e7f2e
Merge pull request #2011 from brauner/generic/coverity
coverity: bugfixes
2017-12-07 14:46:09 -06:00
Christian Brauner
2d7bf7442c
coverity: #1425888
check return value of getifaddrs()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:24:28 +01:00
Christian Brauner
2a7de7ea85
coverity: #1425889
do not call close on bad file descriptor

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:21:57 +01:00
Christian Brauner
fd41e9b7bf
coverity: #1425890
silence complaint about unchecked return value from library function

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:18:35 +01:00
Christian Brauner
dcbc861eda
coverity: #1425895
free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:17:11 +01:00
Christian Brauner
f4e1fa60b2
coverity: #1425921
free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:14:37 +01:00
Christian Brauner
8e0c662051
coverity: #1425922
free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:11:16 +01:00
Christian Brauner
9d6514f222
coverity: #1425923
avoid NULL-pointer dereference

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:09:46 +01:00
Christian Brauner
94f0035bf6
coverity: #1425924
remove logically dead condition

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:07:26 +01:00
Christian Brauner
3ee9e4fb38
coverity: #1425928
Avoid NULL-pointer dereference. Apparently monitor.{c,h} calls
lxc_check_inherited() with NULL passed for the config. This isn't really a big
issue since monitor.{c,h} is effectively dead for all liblxc versions that have
the state client patch. Also, the patch that introduces the relevant lines into
lxc_check_inherited() is only in master and yet unreleased.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 15:01:51 +01:00
Christian Brauner
e1e7642342
coverity: #1425929
free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-07 14:59:55 +01:00
Stéphane Graber
fb398f0786
Merge pull request #2007 from brauner/2017-12-06/bugfixes
coverity: bugfixes
2017-12-06 17:32:22 -05:00
Serge Hallyn
49be8a144a
Merge pull request #1934 from brauner/2017-11-21/implement_do_lxc_reboot_correctly
commands: improve and simplify locking + lxccontainer: add reboot2() API extension
2017-12-06 16:31:50 -06:00
Christian Brauner
070a05af28
coverity: #1425743
remove logically dead code

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 23:13:20 +01:00
Christian Brauner
adcdf4e4a7
coverity: #1425742
fix error condition check

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 23:13:20 +01:00
Christian Brauner
3a29fb5546
coverity: #1425740
free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 23:13:20 +01:00
Christian Brauner
cf22313188
coverity: #1425739
check snprintf() return value

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 23:13:20 +01:00
Christian Brauner
5384511cea
coverity: #1425737
free allocated memory

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 23:13:20 +01:00
Christian Brauner
97ebced3e5
coverity: #1425735
use correct inequality comparison

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 23:13:15 +01:00
Christian Brauner
6b9be52337
coverity: #1425734
free memory on error

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 22:32:51 +01:00
Christian Brauner
77f76f316a
tests: expand tests for shortlived init processes
This adds additional test for app containers.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 21:47:15 +01:00
Christian Brauner
6dcd0821c8
Merge pull request #2006 from Ricardo-Yoshi-LXC/master
Move lxc_init up to lxc/src and add argument parser
2017-12-06 18:43:09 +01:00
RicardoSanchezA
d51dde8ae7 lxc_init: changed minor details
Signed-off-by: RicardoSanchezA <ricardo.sanchez@utexas.edu>
2017-12-06 11:01:04 -06:00
RicardoSanchezA
5ee606bc8e lxc_init: add custom argument parser
lxc_init.c should not depend on tools/arguments.{c,h}, thus it needs its own custom argument parser

Signed-off-by: RicardoSanchezA <ricardo.sanchez@utexas.edu>
2017-12-06 09:30:44 -06:00
RicardoSanchezA
a729880178 lxc_init: move up to src/lxc
lxc_init.c is actually not a tool, thus it doesn't belong to the tools/ subfolder

Signed-off-by: RicardoSanchezA <ricardo.sanchez@utexas.edu>
2017-12-06 09:28:19 -06:00
Christian Brauner
fa30091bb5
lxccontainer: handle execute containers correctly
It doesn't make sense to error out when an app container doesn't pass explicit
arguments through c->start{l}(). This is especially true since we implemented
lxc.execute.cmd. However, even before we could have always relied on
lxc.init.cmd and errored out after that.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:24 +01:00
Christian Brauner
8f98ac7b0f
execute: pass logfile to lxc-init
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:23 +01:00
Christian Brauner
6b7f85cbcd
commands: return -ECONNRESET to caller
Callers can then make a decision whether they want to consider the peer closing
the connection an error or not. For example, a c->wait(c, "STOPPED", -1) call
can then consider a ECONNRESET not an error but rather see it - correctly - as
a container exiting before being able to register a state client.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:23 +01:00
Christian Brauner
44552fb2b7
commands: tell mainloop to reap client fd on error
This is the proper way to handle errors.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:23 +01:00
Christian Brauner
f8bdb6dcc4
lxccontainer: restore non-blocking shutdown
If timeout is set to 0 don't block.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:23 +01:00
Christian Brauner
bc631984fc
commands: tweak locking
Take the lock on the list after we've done all necessary work and check state.
If we are in requested state, do cleanup and return without adding the state
client to the state client list.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:23 +01:00
Christian Brauner
fc788340f7
test: add state server tests
This checks whether multiple concurrent waiters all get notified by the state
server.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:23 +01:00
Christian Brauner
c02c49ee3d
test: add test for reboot2() API extension
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:22 +01:00
Christian Brauner
d39b10eba1
lxccontainer: add reboot2() API extension
This adds reboot2() as a new API extension. This function properly wait until a
reboot succeeded. It takes a timeout argument. When set to > 0 reboot2() will
block until the timeout is reached, if timeout is set to zero reboot2() will
not block, if set to -1 reboot2() will block indefinitly.

The struct state_client gets rename to lxc_state_client since it's more in line
with other declarations. It also gets moved from the lxc_handler to the
lxc_conf struct so that the state clients waiting for reboots don't get
deallocated on reboot since the handler is deallocated on reboot.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:22 +01:00
Christian Brauner
24b0bd9a80
commands: allow waiting for all states
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:22 +01:00
Christian Brauner
20144819c4
start: don't lock setting the state
- setting the handler->state value is atomic on any POSIX implementation since
  we're dealing with an integer (enum/lxc_state_t)
- while the state clients are served it is not possible for lxc_set_state() to
  transition to the next state anyway so there's no danger in moving to the
  next state with clients missing it
- we only care about the list being modified

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:22 +01:00
Christian Brauner
f3a2945e88
commands: don't lock the whole command
There are multiple reasons why this is not required:
- every command is transactional
- we only care about the list being modified not the memory allocation and
  other costly operations

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:22 +01:00
Christian Brauner
e533be71c8
commands: don't lock atomic operations
We're dealing with an integer (lxc_state_t which is an enum). Any POSIX
implementation makes those operations atomic so there's not need in locking
this.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:22 +01:00
Christian Brauner
b1ca434ae5
commands: don't traverse whole list
When we remove a state client fd there's not reason to walk the whole list. We
can simply break once we found and removed the fd.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 16:01:19 +01:00
Stéphane Graber
cfeeed1984
Merge pull request #1994 from brauner/2017-12-04/bugfixes
attach: do not fail on non-existing namespaces
2017-12-05 23:02:59 -08:00
Stéphane Graber
1048874c00
Merge pull request #1996 from brauner/2017-12-04/reenable_coverity_scan
test: Coverity scan integration
2017-12-05 23:01:11 -08:00
Stéphane Graber
a9c51a8267
Merge pull request #2004 from brauner/2017-12-06/fix_log_env_variable
start: set loglevel correctly
2017-12-05 22:59:38 -08:00
Christian Brauner
4a03ded4b2
start: set loglevel correctly
We want the loglevel that the user specified when starting the container
because it overrides the default one set in the config.

Closes #2003.

Reported-by: Felix Abecassis <fabecassis@nvidia.com>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-06 00:21:05 +01:00
RicardoSanchezA
a144d28830
arguments: move to tools/ subdirectory
The arguments.{c,h} file should not be a part of liblxc itself. It should only
be used for the lxc tools.

Signed-off-by: RicardoSanchezA <ricardo.sanchez@utexas.edu>
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-05 12:15:09 +01:00
Christian Brauner
b10fdf6b71
Merge pull request #2002 from tenforward/japanese
Add lxc.console.*, lxc.namespace.*, and lxc.init.cwd to Japanese lxc.container.conf(5)
2017-12-05 11:55:58 +01:00
KATOH Yasufumi
3f6b1110c9 doc: Add lxc.init.cwd to Japanese lxc.container.conf(5)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-05 17:23:29 +09:00
KATOH Yasufumi
615e68b2e5 doc: Add lxc.namespace.[namespace identifier] to Japanese lxc.container.conf(5)
and fix the description of namespace inheritance

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-05 17:08:52 +09:00
KATOH Yasufumi
4d94eb7d6b doc: Add lxc.console.buffer.* and lxc.console.rotate to Japanese lxc.container.conf(5)
and update the description of lxc.console.logfile

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2017-12-05 16:22:37 +09:00
Christian Brauner
2f216e7341
Merge pull request #1992 from lifeng68/add_init_cwd
confile:add lxc.init.cwd
2017-12-05 05:53:23 +01:00