diff --git a/src/core/manager.c b/src/core/manager.c index 12c4e65e52..6d20cf9423 100644 --- a/src/core/manager.c +++ b/src/core/manager.c @@ -3871,6 +3871,9 @@ static void manager_notify_finished(Manager *m) { bus_manager_send_finished(m, firmware_usec, loader_usec, kernel_usec, initrd_usec, userspace_usec, total_usec); + if (MANAGER_IS_SYSTEM(m) && detect_container() <= 0) + watchdog_report_if_missing(); + log_taint_string(m); } diff --git a/src/shared/watchdog.c b/src/shared/watchdog.c index dc94125379..22c28f0c37 100644 --- a/src/shared/watchdog.c +++ b/src/shared/watchdog.c @@ -482,6 +482,23 @@ int watchdog_ping(void) { return watchdog_ping_now(); } +void watchdog_report_if_missing(void) { + /* If we failed to open the watchdog because the device doesn't exist, report why. If we successfully + * opened a device, or opening failed for a different reason, we logged then. But ENOENT failure may + * be transient, for example because modules being loaded or the hardware being detected. This + * function can be called to log after things have settled down. + * + * If a device was specified explicitly, raise level. */ + + if (watchdog_fd == -ENOENT) + log_full_errno(watchdog_device ? LOG_WARNING : LOG_NOTICE, + watchdog_fd, + "Failed to open %swatchdog device%s%s before the initial transaction completed: %m", + watchdog_device ? "" : "any ", + watchdog_device ? " " : "", + strempty(watchdog_device)); +} + void watchdog_close(bool disarm) { /* Once closed, pinging the device becomes a NOP and we request a new diff --git a/src/shared/watchdog.h b/src/shared/watchdog.h index bf9212a865..da63730a5c 100644 --- a/src/shared/watchdog.h +++ b/src/shared/watchdog.h @@ -13,6 +13,7 @@ int watchdog_setup(usec_t timeout); int watchdog_setup_pretimeout(usec_t usec); int watchdog_setup_pretimeout_governor(const char *governor); int watchdog_ping(void); +void watchdog_report_if_missing(void); void watchdog_close(bool disarm); usec_t watchdog_runtime_wait(void);