Commit Graph

6329 Commits

Author SHA1 Message Date
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
LiFeng
3c4915534d confile:add lxc.init.cwd
Signed-off-by: LiFeng <lifeng68@huawei.com>
2017-12-05 04:18:07 -05:00
Christian Brauner
4fe9a9b710
Merge pull request #2000 from hallyn/2017-12-04/execargs
lxc_execute: properly figure out number of needed arguments
2017-12-05 05:50:47 +01:00
Serge Hallyn
858faf70ab lxc_execute: properly figure out number of needed arguments
The lxc_log args have noghing to do with lxc.rootfs.path, and
we need room for a NULL at end of arguments.

How this bug was hidden for so long I don't know - I can only
trigger it on certain systems under certain conditions, but it's
definately wrong as is.

Signed-off-by: Serge Hallyn <shallyn@cisco.com>
2017-12-04 22:30:26 -06:00
Christian Brauner
98db3207f6
test: reenable Coverity integration
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-05 02:13:22 +01:00
Christian Brauner
134284c3ff
attach: do not fail on non-existing namespaces
Closes #1993.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-04 12:26:55 +01:00
Christian Brauner
68eeee2f47
Merge pull request #1979 from marcosps/issue_494
lxc_unshare: Add uid_mapping when creating userns
2017-12-04 12:10:22 +01:00
Stéphane Graber
7ded3c1878
Merge pull request #1988 from abbasally5/feature-improve-bash-completion-1236
Add bash completion to list backing store types for lxc-create -B
2017-12-03 23:57:43 -08:00
Stéphane Graber
152c980061
Merge pull request #1989 from p-l-/fix-lxc-checkconfig
Fix lxc-checkconfig output
2017-12-03 23:57:19 -08:00
Stéphane Graber
331ae3a2a3
Merge pull request #1981 from brauner/2017-12-01/fix_android_sethostname
utils: declare sethostname() static inline
2017-12-03 23:56:07 -08:00
Christian Brauner
223e30c169
criu: silence static analysis
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-04 01:48:46 +01:00
Christian Brauner
1ca0ee1129
confile: remove dead assignment
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-04 01:44:45 +01:00
Christian Brauner
113ebd5729
criu: initialize status
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-04 01:41:49 +01:00
Christian Brauner
f39bcb70cf
confile_legacy: prevent null pointer deref
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-04 01:38:01 +01:00
Christian Brauner
0103eb53de
conf: prevent null pointer dereference
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-04 01:34:50 +01:00
Pierre LALET
edf3320cad Insert missing "echo" after "is_enabled"
Signed-off-by: Pierre LALET <pierre.lalet@cea.fr>
2017-12-03 12:33:19 +01:00
Pierre LALET
6f39c2a8a7 Fix SETCOLOR_FAILURE evaluation
Signed-off-by: Pierre LALET <pierre.lalet@cea.fr>
2017-12-03 11:32:12 +01:00
Abbas Ally
caba109477 Add bash completion to list backing store types for lxc-create -B
- Backing Store types are hard-coded (Not sure how to get programmatically)
- Closes #1236

Signed-off-by: Abbas Ally <abbasally5@yahoo.com>
2017-12-03 05:51:44 +00:00
Christian Brauner
810c42ac64
Merge pull request #1984 from CC-Hsu/patch-1
Add new dependency to Slackware template
2017-12-02 13:00:36 +01:00
CC-Hsu
824d600fc1
Add new dependency to Slackware template
I followed the [changelog of Slackware-current]<http://www.slackware.com/changelog/>,
and found that Slackware-current split hostname utility from util-linux package in Nov 17 2017.
So I add the new package to the template.

Signed-off-by: Chia-Chun Hsu <a12321aabb@gmail.com>
2017-12-02 19:27:34 +08:00
Christian Brauner
2dcc34f3a4
Merge pull request #1983 from iDarkTemplar/update_template
Update gentoo.moresecure.conf.
2017-12-02 09:10:56 +01:00
i.Dark_Templar
23002e923e
Update gentoo.moresecure.conf.
Closes https://github.com/lxc/lxc/issues/1928

Signed-off-by: i.Dark_Templar <darktemplar@dark-templar-archives.net>
2017-12-02 10:33:51 +03:00
Marcos Paulo de Souza
344c9d813c lxc_unshare: Add uid_mapping when creating userns
Change conf.c to export function write_id_mapping, which will now be
called inside main function of lxc_unshare.c.

This is required because setuid syscalls only permits a new userns to
set a new uid if the uid of parameter is mapped inside the ns using
uid_map file[1]. So, just after the clone invocation, map the uid passed as
parameter into the newly created user namespace, and put the current uid
as the ID-outside-ns. After the mapping is done, setuid call succeeds.

Closes: #494

[1] https://elixir.free-electrons.com/linux/latest/source/kernel/user_namespace.c#L286

Signed-off-by: Marcos Paulo de Souza <marcos.souza.org@gmail.com>
2017-12-01 20:28:55 -02:00
Christian Brauner
2650fb4d5e
utils: declare sethostname() static inline
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2017-12-01 23:18:09 +01:00
Serge Hallyn
33349a049f
Merge pull request #1980 from flx42/lxc-oci-layer-caching
OCI layer caching + misc fixes
2017-12-01 13:50:11 -06:00
Felix Abecassis
52e31c07c8 lxc-oci: support skopeo layer caching
This requires skopeo version 0.1.25

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-12-01 11:04:34 -08:00
Felix Abecassis
0fd2b67972 lxc-oci: support index files with multiple manifests
Previously, the output would contain "null" strings in this case.

Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-11-30 22:51:57 -08:00
Felix Abecassis
ca1280fea4 lxc-oci: rely on jq instead of sed to transform values
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-11-30 22:51:53 -08:00
Felix Abecassis
4b42266dc6 lxc-oci: remove unhelpful comment
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
2017-11-30 22:51:47 -08:00