teknoraver / rpms / systemd

Forked from rpms/systemd 2 months ago
Clone

Blame SOURCES/0440-vconsole-setup-downgrade-log-message-when-setting-fo.patch

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