anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

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

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