Skip to content

Implement setfont --quiet#152

Closed
stanislav-brabec wants to merge 1 commit intolegionus:masterfrom
stanislav-brabec:systemd-vconsole-setup-quiet
Closed

Implement setfont --quiet#152
stanislav-brabec wants to merge 1 commit intolegionus:masterfrom
stanislav-brabec:systemd-vconsole-setup-quiet

Conversation

@stanislav-brabec
Copy link

Current systemd-vconsole-setup implementation uses try and fail approach while calling setfont. Starting with 1e15af4, it sometimes causes ugly syslog messages:

/usr/bin/setfont failed with exit status 71.
setfont: ERROR kdfontop.c:183 put_font_kdfontop: Unable to load such font with such kernel version Setting fonts failed with a "system error", ignoring.

It seems that systemd upstream already tried to address this problem, but at that time they haven't found a good way.

The setfont --quiet is specifically intended for systemd-vconsole-setup, and it will allow to suppress the error in systemd, but keep it in other cases.

Reference: https://bugzilla.opensuse.org/show_bug.cgi?id=1212970

Current systemd-vconsole-setup implementation uses try and fail approach
while calling setfont. Starting with 1e15af4, it sometimes causes ugly
syslog messages:

/usr/bin/setfont failed with exit status 71.
setfont: ERROR kdfontop.c:183 put_font_kdfontop: Unable to load such font with such kernel version
Setting fonts failed with a "system error", ignoring.

It seems that systemd upstream already tried to address this problem, but
at that time they haven't found a good way.

The setfont --quiet is specifically intended for systemd-vconsole-setup,
and it will allow to suppress the error in systemd, but keep it in other
cases.

Reference: https://bugzilla.opensuse.org/show_bug.cgi?id=1212970
Signed-off-by: Stanislav Brabec <[email protected]>
@legionus
Copy link
Owner

legionus commented Mar 5, 2026

If systemd doesn't care whether the font was loaded or not (which is very odd) then why not just redirect setfont stderr to /dev/null ?

/usr/bin/setfont failed with exit status 71.
setfont: ERROR kdfontop.c:183 put_font_kdfontop: Unable to load such font with such kernel version Setting fonts failed with a "system error", ignoring.

But the error did happen. What is the point of quietly ignoring it? Wouldn't it be easier not to run setfont at all in this case?

\fB\-R\fR, \fB\-\-reset\fR
Reset the screen font, size, and Unicode mapping to the bootup defaults.
.TP
\fB\-v\fR, \fB\-\-quiet\fR
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The short option should be -q, not -v.

.TP
\fB\-v\fR, \fB\-\-quiet\fR
If kernel cannot load font, do not log error. This prevents ugly errors
with systemd try-and-fail detection of a fully initialized console.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you remove this mention of systemd from the option description? The documentation should describe what the option does, not where the option can be used.

This option decreases the amount of information.

But actually, this utility does not do what is written here. See below.


struct kfont_context {
const char *progname;
int quiet;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need a new flag and function to display it. All you need to do is kfont_set_logger(ctx, NULL) to stop displaying all errors.

@stanislav-brabec
Copy link
Author

Redirecting stderr to /dev/null would suppress all errors, which is not wanted. It specifically needs to handle this error.

systemd does care that the font is not loaded. It just currently have no good way to determine whether the terminal is ready to accept setfont. That it why it blindly calls it, and if it fails, then it tries again later.

It worked perfectly until 1e15af4, when you found an improperly handled error in setfont. Now it still works perfectly, but it sometimes reports this error into the syslog. System works well, but people complain that the syslog contains error. systemd people tried to address it, but they did not found a better way (see https://bugzilla.opensuse.org/show_bug.cgi?id=1212970#c4 and systemd/systemd@93c9a9d).

Maybe a dedicated return code would help even more. I'll ask. When I get a reply, I will update the patch.

@legionus
Copy link
Owner

legionus commented Mar 9, 2026

Redirecting stderr to /dev/null would suppress all errors, which is not wanted. It specifically needs to handle this error.

This contradicts what is written in your PR:

"if kernel cannot load font, do not log error."

systemd does care that the font is not loaded.

Then they should be interested in this error too. Because this error describes a real problem. This error is no different from other errors.

It just currently have no good way to determine whether the terminal is ready to accept setfont. That it why it blindly calls it, and if it fails, then it tries again later.

I did not participate in the discussion.

Now it still works perfectly, but it sometimes reports this error into the syslog.

No, it's not. What you're doing now is brute force. syslog highlights the fallacy of this approach. But instead of solving the problem, you just want to hide it.

Maybe a dedicated return code would help even more. I'll ask. When I get a reply, I will update the patch.

No need to update this PR. You're solving the wrong problem. You need to not hide the problem, but create a way/tool to understand whether the console is initialized or not. This could be a separate function in libkfont, or a check in setfont, or a separate utility.

I think I know how to do that. I just need to reproduce your problem locally to test the solution.

@legionus
Copy link
Owner

Done. I added the kfont_is_font_console function, which checks whether the console is ready to load a font into the kernel. Since I don’t believe systemd will ever use libkfont directly, I added a new option setfont -c which uses this new function to check if the console is ready for use without displaying any error messages.

@legionus legionus closed this Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants