From: Mike Yuan Date: Sun, 8 Dec 2024 19:39:23 +0000 (+0100) Subject: hibernate-resume: always respect user-defined timeout X-Git-Tag: v258-rc1~1885^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a46f36de79a5191c619b6d66248c911f244241e7;p=thirdparty%2Fsystemd.git hibernate-resume: always respect user-defined timeout Follow-up for 6cfce71b5034eb304eea82a31c400ff511cfa69e 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. --- diff --git a/src/hibernate-resume/hibernate-resume-generator.c b/src/hibernate-resume/hibernate-resume-generator.c index b6495a25819..666cd52e477 100644 --- a/src/hibernate-resume/hibernate-resume-generator.c +++ b/src/hibernate-resume/hibernate-resume-generator.c @@ -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"