1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-26 08:55:40 +03:00
This commit is contained in:
Paweł Zmarzły 2024-10-25 15:44:16 +01:00 committed by GitHub
commit f8885450be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 77 additions and 5 deletions

View File

@ -1922,6 +1922,22 @@ After=sys-subsystem-net-devices-ens1.device</programlisting>
--pivot-root=/ostree/deploy/$OS/deploy/$CHECKSUM:/sysroot \
--bind=+/sysroot/ostree/deploy/$OS/var:/var</programlisting>
</example>
<example>
<title>Run a container within a container</title>
<para>We're assuming that the outer container is in <filename index="false">./outer</filename> and
the inner container in <filename index="false">./outer/inner</filename>. The inner
<command>systemd-nspawn</command> will not be able to reach D-Bus, so we are passing flags to disable
some of its functionality.</para>
<programlisting># systemd-nspawn \
--directory outer --ephemeral --console interactive -- \
systemd-nspawn \
--directory inner --ephemeral --console interactive \
--register false --keep-unit --link-journal no -- \
echo OK</programlisting>
</example>
</refsect1>
<refsect1>

View File

@ -6,6 +6,7 @@ Dependencies=
exitrd
initrd
minimal-base
minimal-systemd
minimal-0
minimal-1
@ -48,6 +49,7 @@ ExtraTrees=
%O/minimal-1.root-%a-verity.raw:/usr/share/minimal_1.verity
%O/minimal-1.root-%a-verity-sig.raw:/usr/share/minimal_1.verity.sig
%O/minimal-base:/usr/share/TEST-13-NSPAWN-container-template
%O/minimal-systemd:/usr/share/TEST-13-NSPAWN-container-systemd-template
%O/exitrd:/exitrd
Initrds=%O/initrd

View File

@ -0,0 +1,27 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
[Config]
Dependencies=minimal-base
[Output]
Format=directory
[Content]
BaseTrees=%O/minimal-base
Bootable=no
VolatilePackages=
systemd
systemd-boot
systemd-container
systemd-devel
systemd-journal-remote
systemd-libs
systemd-networkd
systemd-networkd-defaults
systemd-oomd-defaults
systemd-pam
systemd-resolved
systemd-tests
systemd-udev
systemd-ukify

View File

@ -11,9 +11,8 @@ TEST_FORCE_NEWIMAGE=1
# shellcheck source=test/test-functions
. "${TEST_BASE_DIR:?}/test-functions"
test_append_files() {
local workspace="${1:?}"
local container="$workspace/usr/share/TEST-13-NSPAWN-container-template"
_install_base_container() {
local container="${1:?}"
# For virtual wlan interface.
instmods mac80211_hwsim
@ -55,4 +54,14 @@ EOF
chmod +x "$container/sbin/init"
}
test_append_files() {
local workspace="${1:?}"
local container="$workspace/usr/share/TEST-13-NSPAWN-container-template"
local container_systemd="$workspace/usr/share/TEST-13-NSPAWN-container-systemd-template"
_install_base_container "$container"
_install_base_container "$container_systemd"
initdir="$container_systemd" install_systemd
}
do_test "$@"

View File

@ -1214,4 +1214,21 @@ testcase_unpriv_fuse() {
bash -c 'cat <>/dev/fuse' 2>&1)" == *'cat: -: Operation not permitted' ]]
}
testcase_nested_nspawn() {
local root
root="$(mktemp -d /var/lib/machines/TEST-13-NSPAWN.nested_nspawn.XXX)"
create_dummy_container "$root" /usr/share/TEST-13-NSPAWN-container-systemd-template
mkdir "$root/inner"
create_dummy_container "$root/inner"
systemd-nspawn \
--directory="$root" --ephemeral --pipe -- \
systemd-nspawn \
--directory=/inner --ephemeral --pipe \
--register=false --keep-unit --link-journal=no -- \
echo OK
rm -fr "$root"
}
run_testcases

View File

@ -175,14 +175,15 @@ coverage_create_nspawn_dropin() {
create_dummy_container() {
local root="${1:?}"
local source="${2:-/usr/share/TEST-13-NSPAWN-container-template}"
if [[ ! -d /usr/share/TEST-13-NSPAWN-container-template ]]; then
if [[ ! -d "$source" ]]; then
echo >&2 "Missing container template, probably not running in TEST-13-NSPAWN?"
exit 1
fi
mkdir -p "$root"
cp -a /usr/share/TEST-13-NSPAWN-container-template/* "$root"
cp -a "$source"/* "$root"
coverage_create_nspawn_dropin "$root"
}