Commit Graph

7746 Commits

Author SHA1 Message Date
Stéphane Graber
09a4a38d6e
Merge pull request #4021 from diederikdehaas/replace-which-in-tests-too
Replace 'which' with 'command -v' in tests too
2021-10-28 15:32:01 -04:00
Stéphane Graber
0344de5b47
Merge pull request #4023 from diederikdehaas/fix-SC2006
Replace backticks with $() construct
2021-10-28 15:31:53 -04:00
Diederik de Haas
ac46b35693
Replace deprecated backticks with $() construct
See https://github.com/koalaman/shellcheck/wiki/SC2006 for details.
Not only uses this the recommended construct, it also makes the code
more uniform as in many other places the $() construct was already used.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
2021-10-28 20:15:29 +02:00
Stéphane Graber
7f71fbfd76
Merge pull request #4020 from brauner/2021-10-28.fixes
build & mainloop: fixes
2021-10-28 14:01:46 -04:00
Stéphane Graber
6e8843d148
Merge pull request #4018 from brauner/2021-10-28.fixes.2
confile: don't use path_simplify() on lxc.{execute,init}.cmd
2021-10-28 13:07:49 -04:00
Diederik de Haas
4c69af0c37
Replace 'which' with 'command -v' in tests too
Forgot to modify and include the tests in previous PR, so do that now.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
2021-10-28 18:25:37 +02:00
Christian Brauner
a585382b97
start: check event loop type before closing fd
Since this is a union we might otherwise stomp on io_uring mmap()ed
memory.

Fixes: #4016
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-28 17:39:42 +02:00
Christian Brauner
aac3f106ff
mainloop: make sure that descr->ring is allocated
This is future proofing more than anything else.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-28 17:39:11 +02:00
Diederik de Haas
7a7671655a
Replace 'which' with 'command -v'
The 'which' command is deprecated on Debian Sid as it is not POSIX
compliant and it's behavior is therefor not consistent, so replace it
with 'command -v' which is POSIX compliant.
See https://stackoverflow.com/a/677212 for details.

Also replaced a use of backticks (`) as that is deprecated as well.
See https://github.com/koalaman/shellcheck/wiki/SC2006 for details.

Signed-off-by: Diederik de Haas <didi.debian@cknow.org>
2021-10-28 17:27:08 +02:00
Christian Brauner
51d40b684c
confile: don't use path_simplify() on lxc.{execute,init}.cmd
Fixes: #4015
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-28 16:53:14 +02:00
Stéphane Graber
16210a56b6
Merge pull request #4010 from brauner/2021-10-23.fixes
conf: handle kernels without or not using SMT
2021-10-24 01:41:36 -04:00
Christian Brauner
f3d90fca4a
conf: handle kernels without or not using SMT
On kernel not enabling or not using SMT core scheduling will return with
ENODEV. Handle such kernels.

Link: https://github.com/lxc/lxd/issues/9419
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-23 19:23:06 +02:00
Christian Brauner
41687b4d08
Merge pull request #4006 from coledishington/master
Make number of rx and tx queues configurable for veths
2021-10-22 19:30:05 +02:00
Cole Dishington
be538b8b27 Make number of rx and tx queues configurable for veths
Distribute traffic over cpu cores of container by configuring more
than 1 tx/rx queue.

Signed-off-by: Cole Dishington <Cole.Dishington@alliedtelesis.co.nz>
2021-10-22 15:23:38 +13:00
Christian Brauner
d90d30072c
conf: add cgroup2, cgroup2:ro, cgroup2:force, cgroup2:ro:force options
We keep running into situations where we want to pre-mount a pure
cgroup2 layout regardless of the layout of the host.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-21 16:40:16 +02:00
Christian Brauner
62054cf35e
conf: make it more obvious how auto-mount flags are defined
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-21 15:52:15 +02:00
Christian Brauner
0109a13d53
criu: support restoring containers with pre-created veth devices
We did th CRIU and kernel work but for some reason we never did push the
LXC work.

Link: cdb0d42702
      commit cdb0d427020f ("net: allow restoring of precreated veth devices")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-20 14:52:18 +02:00
Stéphane Graber
2db3d91eea
Merge pull request #4003 from brauner/2021-10-19.fixes
conf: verify that rootfs is stable after setting up mounts
2021-10-19 11:24:26 -04:00
Christian Brauner
4f2af104b8
conf: verify that rootfs is stable after setting up mounts
Apparently some users changed their rootfs via their lxc.mount.entry
entries. Let's not allow that as that can cause confusion during
container setup. So lets verify that the rootfs is stable after setup.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-19 16:59:41 +02:00
Heinrich Schuchardt
07459c88d5 Add riscv64 to --arch parameter values
lxc-attach uses an --arch parameter. 'riscv64' should be a usable value.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2021-10-19 13:18:02 +02:00
Christian Brauner
5c6eb4169a
conf: don't fail umount2()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-18 12:07:37 +02:00
Christian Brauner
65d832931b
conf: fix coding style
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-18 11:46:16 +02:00
Christian Brauner
a031a4e14f
caps: ensure \0-termination
Fixes: Coverity 1492865
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-15 11:29:27 +02:00
Christian Brauner
bf2af3e72a
attach: improve error logging
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-15 10:06:48 +02:00
Christian Brauner
d8487b3081
af_unix: replace log_error_errno()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-15 09:59:28 +02:00
Tycho Andersen
bdb8aeda72 criu: fix error message
as of 59d8a539d1 ("criu: massage exec_criu()") I see:

In file included from criu.c:22:
criu.c: In function 'exec_criu':
log.h:376:2: error: '%s' directive argument is null [-Werror=format-overflow=]
  376 |  LXC_ERROR(&locinfo, format, ##__VA_ARGS__);   \
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
log.h:457:3: note: in expansion of macro 'ERROR'
  457 |   ERROR("%s - " format, ptr, ##__VA_ARGS__); \
      |   ^~~~~
log.h:491:3: note: in expansion of macro 'SYSERROR'
  491 |   SYSERROR(format, ##__VA_ARGS__);              \
      |   ^~~~~~~~
criu.c:325:11: note: in expansion of macro 'log_error_errno'
  325 |    return log_error_errno(-ENOMEM, ENOMEM, "Failed to remove extraneous slashes from \"%s\"", tmp);
      |           ^~~~~~~~~~~~~~~

it looks like we should be logging the string that failed, vs. tmp here.

(my log was taken from stable-4.0, but the same issue exists on master it
seems.)

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
2021-10-14 10:41:36 -06:00
Christian Brauner
8a0de7e7cc
test: fix nested capability tests
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-14 14:03:49 +02:00
Christian Brauner
401b1364b3
attach: improve error logging for drop_capabilities()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-14 13:26:15 +02:00
Christian Brauner
09f2a3ef8a
tests: expand capability tests
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-14 11:17:15 +02:00
Christian Brauner
7418b27f12
tree-wide: use __u32 for capabilities
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-14 11:04:06 +02:00
Christian Brauner
c5e7fbcadb
cgroups: use __u32 for cpumasks
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-13 18:30:00 +02:00
Christian Brauner
623f47b00c
conf: improve capability handling
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-13 13:38:14 +02:00
Christian Brauner
634b43e1f2
tests: add test for lxc.cap.keep
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-13 13:08:01 +02:00
Christian Brauner
cafcd2a751
conf: fix lxc.cap.keep behavior
Fixes: ##3993
Fixes: 20ab75789e ("conf: simplify and port caps to new list type")
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-12 16:33:14 +02:00
Christian Brauner
0cf017f071
terminal: log at warning message
The lxc_devpts_terminal() helper is called in contexts where it can fail
due to various reasons but where we safely fallback to allocating
terminal devices on the host. Logging error messages irritates users so
just log warning messages.

Link: https://discuss.linuxcontainers.org/t/lxc-attach-error-failed-to-open-terminal-multiplexer-device
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-11 15:22:52 +02:00
Christian Brauner
316b8d0589
log: improve %m handling on musl
Fixes: #3961
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-04 11:24:19 +02:00
Christian Brauner
ffd98e8c2e
start: make failure to apply core scheduling fatal
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-01 15:35:03 +02:00
Christian Brauner
f18a595926
start: use core scheduling error helper
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-01 10:14:08 +02:00
Christian Brauner
565b6e92d3
start: don't fail when core scheduling isn't supported
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-01 10:12:43 +02:00
Christian Brauner
47bfecf510
syscall_wrappers: fix core scheduling creation helper naming
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-01 10:12:17 +02:00
Christian Brauner
2e9aa14628
tree-wide: cast to core scheduling cookie to llu
Link: https://launchpadlibrarian.net/561086365/buildlog_ubuntu-focal-ppc64el.lxc_1%3A4.0.10+master~20210930-1812-0ubuntu1~focal_BUILDING.txt.gz
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-30 22:48:29 +02:00
Stéphane Graber
187560436a
Merge pull request #3984 from brauner/2021-09-29.core_scheduling
lxc: core scheduling support
2021-09-30 13:56:25 -04:00
Christian Brauner
c958a332d2
attach: handle core scheduling
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-30 17:43:22 +02:00
Christian Brauner
09996a4821
lxc: add lxc.sched.core
Core scheduling defines if the container payload is marked as being
schedulable on the same core. Doing so will cause the kernel scheduler
to ensure that tasks that are not in the same group never run
simultaneously on a core. This can serve as an extra security measure to
prevent the container payload from using cross hyper thread attacks.

The only allowed values are 0 and 1. Set this to 1 to create a core
scheduling domain for the container or 0 to not create one. If not set
explicitly no core scheduling domain will be created for the container.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-29 14:07:41 +02:00
Christian Brauner
b371ad51bb
initutils: add missing prctl include
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-29 13:16:05 +02:00
Christian Brauner
ae13cb3b1b
build: compiler attribute improvements
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-29 10:17:33 +02:00
Christian Brauner
5c26176d58
build: check whether compiler supports nonnull and returns_nonnull attributes
Fixes: #3980
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-28 11:49:26 +02:00
Christian Brauner
34498deaa3
tree-wide: fix HAVE_* checks
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-27 12:19:23 +02:00
Christian Brauner
afdad1798e
cmds: fix includes
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-27 12:09:17 +02:00
Christian Brauner
98775a4cc9
cmds: fix integer conversions
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-09-27 12:07:51 +02:00