richardphibel / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
21255d
From 860749038f508617c8fc31b8292b4019b1e621ba Mon Sep 17 00:00:00 2001
21255d
From: Franck Bui <fbui@suse.com>
21255d
Date: Thu, 16 Jul 2020 21:22:37 +0200
21255d
Subject: [PATCH] vconsole-setup: downgrade log message when setting font fails
21255d
 on dummy console
21255d
21255d
Since commit 883eb9be985fd86d9cabe967eeeab91cdd396a81, vconsole-setup might be
21255d
called again to operate on dummy console where font operations are not
21255d
supported but where it's still important to have the correct keymap set [0][1].
21255d
21255d
vconsole-setup is mainly called by udev but can also be run via a dependency of
21255d
an early service. Both cases might end up calling vconsole-setup on the dummy
21255d
console.
21255d
21255d
The first case can happen during early boot even on systems that use (instead
21255d
of the dummy console) a "simple" video console driver supporting font
21255d
operations (such as vgacon) until a more specific driver (such as i915) takes
21255d
the console over. While this is happening vgacon is deactivated and temporarly
21255d
replaced by the dummy console [2].
21255d
21255d
There are also other cases where systemd-vconsole-setup might be called on
21255d
dummy console especially during (very) early boot. Indeed
21255d
systemd-vconsole-setup.service might be pulled in by early interactive services
21255d
such as 'dracut-cmdline-ask.service` which is run before udev.
21255d
21255d
If that happens on platforms with no grapical HWs (such as embedded ARM) or
21255d
with dummy console initially installed until a driver takes over (like Xen and
21255d
xen-fbfront) then setting font will fail.
21255d
21255d
Therefore this patch downgrades the log message emitted when setting font fails
21255d
to LOG_DEBUG and when font operations is not implemented like it's the case for
21255d
the dummy console.
21255d
21255d
Fixes: #16406.
21255d
21255d
[0] https://github.com/systemd/systemd/issues/10826
21255d
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1652473
21255d
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/vga/vgaarb.c?h=v5.7#n204
21255d
21255d
(cherry picked from commit 0ef1adf51274960358e852d3bc36ae6c288a70d9)
21255d
21255d
Resolves: #1889996
21255d
---
21255d
 src/vconsole/vconsole-setup.c | 18 ++++++++++++++----
21255d
 1 file changed, 14 insertions(+), 4 deletions(-)
21255d
21255d
diff --git a/src/vconsole/vconsole-setup.c b/src/vconsole/vconsole-setup.c
21255d
index f162d29220..1b406c0bc5 100644
21255d
--- a/src/vconsole/vconsole-setup.c
21255d
+++ b/src/vconsole/vconsole-setup.c
21255d
@@ -222,6 +222,7 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
21255d
         _cleanup_free_ struct unipair* unipairs = NULL;
21255d
         _cleanup_free_ void *fontbuf = NULL;
21255d
         unsigned i;
21255d
+        int log_level;
21255d
         int r;
21255d
 
21255d
         unipairs = new(struct unipair, USHRT_MAX);
21255d
@@ -230,11 +231,20 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
21255d
                 return;
21255d
         }
21255d
 
21255d
+        log_level = LOG_WARNING;
21255d
+
21255d
         /* get metadata of the current font (width, height, count) */
21255d
         r = ioctl(src_fd, KDFONTOP, &cfo;;
21255d
-        if (r < 0)
21255d
-                log_warning_errno(errno, "KD_FONT_OP_GET failed while trying to get the font metadata: %m");
21255d
-        else {
21255d
+        if (r < 0) {
21255d
+                /* We might be called to operate on the dummy console (to setup keymap
21255d
+                 * mainly) when fbcon deferred takeover is used for example. In such case,
21255d
+                 * setting font is not supported and is expected to fail. */
21255d
+                if (errno == ENOSYS)
21255d
+                        log_level = LOG_DEBUG;
21255d
+
21255d
+                log_full_errno(log_level, errno,
21255d
+                               "KD_FONT_OP_GET failed while trying to get the font metadata: %m");
21255d
+        } else {
21255d
                 /* verify parameter sanity first */
21255d
                 if (cfo.width > 32 || cfo.height > 32 || cfo.charcount > 512)
21255d
                         log_warning("Invalid font metadata - width: %u (max 32), height: %u (max 32), count: %u (max 512)",
21255d
@@ -269,7 +279,7 @@ static void setup_remaining_vcs(int src_fd, unsigned src_idx, bool utf8) {
21255d
         }
21255d
 
21255d
         if (cfo.op != KD_FONT_OP_SET)
21255d
-                log_warning("Fonts will not be copied to remaining consoles");
21255d
+                log_full(log_level, "Fonts will not be copied to remaining consoles");
21255d
 
21255d
         for (i = 1; i <= 63; i++) {
21255d
                 char ttyname[sizeof("/dev/tty63")];