hibernate-resume: always respect user-defined timeout

Follow-up for 6cfce71b50

Let's not override resumeflags=x-systemd.device-timeout=
specified by user, especially in the case of EFI if
the user actually wants to extend the timeout.
This commit is contained in:
Mike Yuan
2024-12-09 19:24:59 +01:00
parent 9a097eced6
commit a46f36de79
@@ -64,20 +64,21 @@ static int process_resume(const HibernateInfo *info) {
if (r < 0)
return log_error_errno(r, "Failed to generate device unit name from path '%s': %m", info->device);
/* If hibernate info is acquired from EFI variable, don't wait forever by default. Otherwise, if
* swap device is not present and HibernateLocation was not correctly cleared, we end up blocking
* the boot process infinitely. */
r = write_drop_in_format(arg_dest, device_unit, 40, "device-timeout",
"# Automatically generated by systemd-hibernate-resume-generator\n\n"
"[Unit]\n"
"JobTimeoutSec=%s\n",
info->cmdline ? "infinity" : "2min");
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m");
r = generator_write_device_timeout(arg_dest, info->device, arg_resume_options ?: arg_root_options, NULL);
if (r < 0)
log_warning_errno(r, "Failed to write device timeout drop-in, ignoring: %m");
if (r <= 0) {
/* No timeout explicitly defined? Wait infinitely if resume= is specified, 2min if from EFI
* HibernateLocation variable. In the latter case, we avoid blocking the boot process forever
* if a stale var is detected while the swap device is not present. */
r = write_drop_in_format(arg_dest, device_unit, 40, "device-timeout",
"# Automatically generated by systemd-hibernate-resume-generator\n\n"
"[Unit]\n"
"JobTimeoutSec=%s\n",
info->cmdline ? "infinity" : "2min");
if (r < 0)
log_warning_errno(r, "Failed to write fallback device timeout drop-in, ignoring: %m");
}
r = write_drop_in_format(arg_dest, SPECIAL_HIBERNATE_RESUME_SERVICE, 90, "device-dependency",
"# Automatically generated by systemd-hibernate-resume-generator\n\n"