mirror of
https://github.com/systemd/systemd
synced 2024-07-21 10:17:21 +00:00
core: relax dependency on RootImage= storage from Requires= to Wants=
If a unit is running in an image and wants to survive a soft-reboot, then it can't be deactivated by the storage of the image going away. Relax the dependency to a Wants=. Access to the image is not needed when the unit is running anyway, so downgrade to Wants=.
This commit is contained in:
parent
ae7482b994
commit
ebc7510380
|
@ -1289,13 +1289,13 @@ int unit_add_exec_dependencies(Unit *u, ExecContext *c) {
|
|||
}
|
||||
|
||||
if (c->root_directory) {
|
||||
r = unit_add_mounts_for(u, c->root_directory, UNIT_DEPENDENCY_FILE, UNIT_MOUNT_REQUIRES);
|
||||
r = unit_add_mounts_for(u, c->root_directory, UNIT_DEPENDENCY_FILE, UNIT_MOUNT_WANTS);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
||||
if (c->root_image) {
|
||||
r = unit_add_mounts_for(u, c->root_image, UNIT_DEPENDENCY_FILE, UNIT_MOUNT_REQUIRES);
|
||||
r = unit_add_mounts_for(u, c->root_image, UNIT_DEPENDENCY_FILE, UNIT_MOUNT_WANTS);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
|
|
@ -7,8 +7,21 @@ TEST_DESCRIPTION="Test Soft-Rebooting"
|
|||
IGNORE_MISSING_COVERAGE=yes
|
||||
# Prevent shutdown in test suite, the expect script does that manually.
|
||||
TEST_SKIP_SHUTDOWN=yes
|
||||
IMAGE_NAME="softreboot"
|
||||
TEST_NO_NSPAWN=1
|
||||
TEST_INSTALL_VERITY_MINIMAL=1
|
||||
|
||||
# shellcheck source=test/test-functions
|
||||
. "$TEST_BASE_DIR/test-functions"
|
||||
|
||||
test_require_bin mksquashfs veritysetup sfdisk
|
||||
|
||||
test_append_files() {
|
||||
instmods squashfs =squashfs
|
||||
instmods dm_verity =md
|
||||
install_dmevent
|
||||
generate_module_dependencies
|
||||
install_verity_minimal
|
||||
}
|
||||
|
||||
do_test "$@"
|
||||
|
|
|
@ -181,6 +181,11 @@ EOF
|
|||
systemd-run --collect --service-type=notify -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive-sigterm.service "$survive_sigterm"
|
||||
systemd-run --collect --service-type=exec -p DefaultDependencies=no -p IgnoreOnIsolate=yes --unit=testsuite-82-nosurvive.service sleep infinity
|
||||
|
||||
# Ensure that the unit doesn't get deactivated by dependencies on the source file. Given it's a verity
|
||||
# image that is already open, even if the tmpfs with the image goes away, the file will be pinned by the
|
||||
# kernel and will keep working.
|
||||
cp /usr/share/minimal_0.* /tmp/
|
||||
|
||||
# Configure these transient units to survive the soft reboot - they will not conflict with shutdown.target
|
||||
# and it will be ignored on the isolate that happens in the next boot. The first will use argv[0][0] =
|
||||
# '@', and the second will use SurviveFinalKillSignal=yes. Both should survive.
|
||||
|
@ -193,6 +198,11 @@ EOF
|
|||
--property "Before=reboot.target kexec.target poweroff.target halt.target emergency.target rescue.target" \
|
||||
"$survive_argv"
|
||||
systemd-run --service-type=exec --unit=testsuite-82-survive.service \
|
||||
--property TemporaryFileSystem="/run /tmp /var" \
|
||||
--property RootImage=/tmp/minimal_0.raw \
|
||||
--property BindReadOnlyPaths=/dev/log \
|
||||
--property BindReadOnlyPaths=/run/systemd/journal/socket \
|
||||
--property BindReadOnlyPaths=/run/systemd/journal/stdout \
|
||||
--property SurviveFinalKillSignal=yes \
|
||||
--property IgnoreOnIsolate=yes \
|
||||
--property DefaultDependencies=no \
|
||||
|
|
Loading…
Reference in a new issue