Commit Graph

11413 Commits

Author SHA1 Message Date
Wolfgang Bumiller
53b2f3d5da use 2 sysfs instances for sys:mixed
In order to facilitate this, the default mount list's
'destination' may now be NULL to mean that the source should
be unmounted instead.

Here's what we need to do:

1) Ensure the first sysfs mount point is writable.
2) Mount a read-only sysfs on /sys
3) Bind devices/virtual/net *writably* into /sys

We use /proc/sys as a staging directory for the first sysfs
mount in read-write mode, then mount /sys r/o. Afterwards we
bind the r/w devices/virtual/net and unmount the staging
/proc/sys mount point.

The staging directory would not be required with the new
mount API, but this way we can support the old API and keep
the general workflow in the `default_mounts`.

Once we drop support for the old mount API, the
default_mounts table could just get a subdirectory field to
mount subdirectories directly.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-12-03 12:47:00 +01:00
Stéphane Graber
9873fb06d8
Revert "api: ->save_config() doesn't need to create container dir"
This reverts commit 2fde07c399.

We need to investigate this in more detail but this commit is breaking
LXD, causing startup to fail with:

lxc foo 20211130202833.906 INFO     conf - conf.c:run_script_argv:336 - Executing script "/bin/mount -t shiftfs -o passthrough=3 "/lxc-ci/build/tmp.WemmpzWGYz/go/src/github.com/lxc/lxd/test/tmp.Cli/0To/containers/foo/rootfs" "/lxc-ci/build/tmp.WemmpzWGYz/go/src/github.com/lxc/lxd/test/tmp.Cli/0To/containers/foo/rootfs"" for container "foo"
lxc foo 20211130202833.912 ERROR    conf - conf.c:run_buffer:321 - Script exited with status 32
lxc foo 20211130202833.912 ERROR    conf - conf.c:lxc_setup_rootfs_prepare_root:3947 - Failed to run pre-mount hooks
lxc foo 20211130202833.912 ERROR    conf - conf.c:lxc_setup:4317 - Failed to setup rootfs
lxc foo 20211130202833.912 ERROR    start - start.c:do_start:1275 - Failed to setup container "foo"

Not entirely sure why we're seeing things blow up as the directory
definitely exists (and contains a valid rootfs) but this was caused by
today's liblxc update.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-11-30 17:39:34 -05:00
Christian Brauner
030e1aaad5
Merge pull request #4039 from tych0/config-no-container-dir
api: ->save_config() doesn't need to create container dir
2021-11-29 17:26:06 +01:00
Christian Brauner
6a9cbecdaa
Merge pull request #4040 from tych0/fix-cgroup-warning
cgroups: fix compiler warning
2021-11-29 17:25:45 +01:00
Tycho Andersen
2fde07c399 api: ->save_config() doesn't need to create container dir
If we're saving the config file to somewhere that's *not* the container
dir, we don't need to create the container dir. Let's not do this and
thus not require its parent to exist, which can be confusing, especially in
light of the sparse logging through these functions.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
2021-11-29 08:55:31 -05:00
Tycho Andersen
2b113b55c7 cgroups: fix compiler warning
I get:

In file included from cgroups/cgfsng.c:42:
In function 'cpuset1_cpus_initialize',
    inlined from 'cpuset1_initialize' at cgroups/cgfsng.c:658:7,
    inlined from '__cgroup_tree_create.constprop' at cgroups/cgfsng.c:723:26:
./log.h:376:9: error: '%s' directive argument is null [-Werror=format-overflow=]
  376 |         LXC_ERROR(&locinfo, format, ##__VA_ARGS__);                     \
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./log.h:457:17: note: in expansion of macro 'ERROR'
  457 |                 ERROR("%s - " format, ptr, ##__VA_ARGS__); \
      |                 ^~~~~
./log.h:491:17: note: in expansion of macro 'SYSERROR'
  491 |                 SYSERROR(format, ##__VA_ARGS__);              \
      |                 ^~~~~~~~
cgroups/cgfsng.c:585:24: note: in expansion of macro 'log_error_errno'
  585 |                 return log_error_errno(false, errno, "Failed to read file \"%s\"", fpath);
      |                        ^~~~~~~~~~~~~~~

it turns out here that fpath is not used, so let's get rid of it and just
render the dfd+pathname directly.

Signed-off-by: Tycho Andersen <tycho@tycho.pizza>
2021-11-29 08:40:30 -05:00
Christian Brauner
7cf6f28ed8
Merge pull request #4035 from Blub/revert-vfork
Revert "initutils: use vfork() in lxc_container_init()"
2021-11-13 23:24:12 +01:00
Wolfgang Bumiller
84cf067565 Revert "initutils: use vfork() in lxc_container_init()"
This reverts commit d65e5e492f.

With vfork the child process modifies the parent's memory,
so the calls to `signal`, `fprintf` and regular `exit` may
be dangerous and might cause conflicting states in the
parent.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2021-11-13 19:44:48 +01:00
Stéphane Graber
94e9dc283b
Merge pull request #4033 from brauner/2021-11-09.fixes
macro: ensure necessary io_uring flags are defined
2021-11-09 09:48:37 -05:00
Christian Brauner
54e21c7e90
macro: ensure necessary io_uring flags are defined
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-09 14:11:18 +01:00
Christian Brauner
d6bd3ab9ee
Merge pull request #4032 from joanbm/master
autotools: Avoid multiple liblxc.so with --enable-pam
2021-11-08 19:41:47 +01:00
Joan Bruguera
d19c1aa67d autotools: Avoid multiple liblxc.so with --enable-pam
When installing LXC with the default options, a single non-symlink liblxc.so*
(e.g. liblxc.so.1.7.0) file is created:

```
    $ ./autogen.sh && ./configure && make && \
    rm -rf "$HOME/lxci" && make DESTDIR="$HOME/lxci" install && \
    stat -c%N "$HOME/lxci/usr/local/lib/liblxc.so"*
    [...]
    '/home/someone/lxci/usr/local/lib/liblxc.so' -> 'liblxc.so.1'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1' -> 'liblxc.so.1.7.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1.7.0'
```

However, when automake>=1.16.5, and the `--enable-pam` option is used, two
non-symlink liblxc.so* (e.g. liblxc.so.1.0.0 and liblxc.so.1.7.0) are
erroneously created:

```
    $ ./autogen.sh && ./configure --enable-pam && make && \
    rm -rf "$HOME/lxci" && make DESTDIR="$HOME/lxci" install && \
    stat -c%N "$HOME/lxci/usr/local/lib/liblxc.so"*
    [...]
    '/home/someone/lxci/usr/local/lib/liblxc.so' -> 'liblxc.so.1.0.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1' -> 'liblxc.so.1.0.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1.0.0'
    '/home/someone/lxci/usr/local/lib/liblxc.so.1.7.0'
```

This is due to infighting between libtool's and LXC's versioning:
libtool creates liblxc.so.1.0.0, then LXC's `install-exec-local` hook in
`Makefile.am` moves it to liblxc.so.1.7.0. However, with `--enable-pam`, the
`install-libLTLIBRARIES` target is re-triggered after `install-pamLTLIBRARIES`,
which will create liblxc.so.1.0.0 again.

The bigger problem here is that the install for the pam_cgfs library is done on
the `data` phase of the automake install process instead of the `exec` phase
(https://www.gnu.org/software/automake/manual/html_node/The-Two-Parts-of-Install.html),
which gives `install-libLTLIBRARIES` a chance to run again after the
`install-exec-local` / `install-exec-hook` targets have already run.

To fix this, we add an "exec_" prefix to the pam_cgfs library to make it run
during the `exec` phase (see link above). We also consolidate the various hooks
in the `install-exec-hook` target, which runs after the whole install, avoiding
needing to manually specify the dependencies like in `install-exec-local`.

Signed-off-by: Joan Bruguera <joanbrugueram@gmail.com>
2021-11-07 17:40:35 +01:00
Stéphane Graber
2cac683cad
Merge pull request #4030 from brauner/2021-11-04.fixes
conf: lxc.proc.* and lxc.sysctl.* fixes and tests
2021-11-04 11:28:03 -04:00
Christian Brauner
5c9baf458d
build: refuse to compile with unsupported liburing version
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-04 15:48:54 +01:00
Christian Brauner
20acdbb8c2
tests: add lxc.proc.* test
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-04 15:17:02 +01:00
Christian Brauner
b8eb6ca709
tests: add lxc.sysctls.* test
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-04 15:17:02 +01:00
Christian Brauner
2c7c983bee
test: improve logging helpers
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-04 14:08:56 +01:00
Christian Brauner
4e29ef3cf0
conf: improve logging setting sysctl and /proc/<pid>/ parameters
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-04 14:08:56 +01:00
Christian Brauner
1d81fffe86
conf: apply /proc/sys and /proc/<pid>/ parameters
When porting to the new list type we added an accidental ! when checking
whether the list is empty.

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-04 11:26:43 +01:00
Stéphane Graber
b77a9f8353
Merge pull request #4028 from brauner/2021-11-02.fixes
start: fixes
2021-11-02 10:06:45 -04:00
Christian Brauner
e49c56d66e
tests: include config.h
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-02 11:14:59 +01:00
Christian Brauner
5bd35027d3
build: move _FILE_OFFSET_BITS to common option
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-02 11:14:58 +01:00
Christian Brauner
b0dec2ced0
start: log signal name and number
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-02 11:14:58 +01:00
Christian Brauner
ea0e384ff5
process_utils: add signal_name() helper
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-11-02 10:58:35 +01:00
Stéphane Graber
399ee880ac
Merge pull request #4025 from brauner/2021-10-30.fixes
build: fixes
2021-11-01 10:33:51 -04:00
Christian Brauner
752b64325e
build: improve liburing support detection
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-30 17:54:39 +02:00
Christian Brauner
e29412c07f
mainloop: make ifdefs easier to follow
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-30 17:38:37 +02:00
Stéphane Graber
43b1b87972
Merge pull request #4024 from simondeziel/no-which
Replace remaining occurences of 'which' with 'command -v'
2021-10-28 17:49:37 -04:00
Simon Deziel
af0ab1854c Replace last occurence of 'which' with 'command -v'
The later is builtin and POSIX compliant.

Signed-off-by: Simon Deziel <simon.deziel@canonical.com>
2021-10-28 17:10:05 -04:00
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
4449c5b25c
Merge pull request #4019 from diederikdehaas/replace-which-with-command-v
Replace 'which' with 'command -v'
2021-10-28 18:06:17 +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
747bc634c5
build: add io-uring-event-loop option
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-28 17:07:27 +02:00
Christian Brauner
860ab93303
build: add static libcap to output
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
2021-10-28 17:07:14 +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
Christian Brauner
8dff29c6c7
Merge pull request #4013 from stgraber/master
AUTHORS: Update to point to git history
2021-10-25 15:11:06 +02:00
Stéphane Graber
5d8c30856e
AUTHORS: Update to point to git history
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
2021-10-25 08:53:58 -04: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
d6818a3459
Merge pull request #4008 from tenforward/japanese
doc: Update Japanese lxc.container.conf(5) and common options
2021-10-23 10:29:06 +02:00
KATOH Yasufumi
9fe946bcc6 doc: fix typo in English lxc.container.conf(5)
Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2021-10-23 15:26:26 +09:00
KATOH Yasufumi
9093e17958 doc: Add lxc.sched.core to Japanese lxc.container.conf(5)
Update for commit 09996a4

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2021-10-23 15:18:00 +09:00
KATOH Yasufumi
cc6a34b9da doc: add way to specify broadcast address to Japanese lxc.container.conf(5)
Update for commit 5686798

Signed-off-by: KATOH Yasufumi <karma@jazz.email.ne.jp>
2021-10-23 14:53:58 +09:00