mirror of
https://github.com/systemd/systemd
synced 2025-10-06 00:13:24 +02:00
sd-boot: allow setting the log level through SMBIOS 11
Allow configuring the log level used by sd-boot by setting `io.systemd.boot.loglevel=<level>` as SMBIOS type 11 string. `info` is used if unset.
This commit is contained in:
@@ -80,10 +80,20 @@
|
||||
|
||||
<listitem><para>This allows inserting additional entries into the <command>systemd-boot</command>
|
||||
menu. For details see
|
||||
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry></para>
|
||||
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v258"/></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>io.systemd.boot.loglevel=</varname><replaceable>LEVEL</replaceable></term>
|
||||
|
||||
<listitem><para>This allows configuration of the log level, and is read by <command>systemd-boot</command>.
|
||||
For details see
|
||||
<citerefentry><refentrytitle>systemd-boot</refentrytitle><manvolnum>7</manvolnum></citerefentry>.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v259"/></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@@ -640,6 +640,16 @@ uki-url http://example.com/somedir/fooos.efi</programlisting>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v258"/></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term><varname>io.systemd.boot.loglevel</varname></term>
|
||||
<listitem><para>If set, the value of this string is used as log level. Valid values (from most to
|
||||
least critical) are <literal>emerg</literal>, <literal>alert</literal>, <literal>crit</literal>,
|
||||
<literal>err</literal>, <literal>warning</literal>, <literal>notice</literal>, <literal>info</literal>,
|
||||
and <literal>debug</literal>.</para>
|
||||
|
||||
<xi:include href="version-info.xml" xpointer="v259"/></listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
|
@@ -2991,6 +2991,9 @@ static EFI_STATUS run(EFI_HANDLE image) {
|
||||
uint64_t init_usec;
|
||||
bool menu = false;
|
||||
|
||||
/* set loglevel early to simplify debugging before loader.conf is loaded */
|
||||
log_set_max_level_from_smbios();
|
||||
|
||||
init_usec = time_usec();
|
||||
|
||||
err = BS->HandleProtocol(image, MAKE_GUID_PTR(EFI_LOADED_IMAGE_PROTOCOL), (void **) &loaded_image);
|
||||
|
@@ -3,7 +3,9 @@
|
||||
#include "efi-log.h"
|
||||
#include "efi-string-table.h"
|
||||
#include "proto/rng.h"
|
||||
#include "smbios.h"
|
||||
#include "util.h"
|
||||
#include "vmm.h"
|
||||
|
||||
static unsigned log_count = 0;
|
||||
static LogLevel log_max_level = LOG_INFO;
|
||||
@@ -57,6 +59,21 @@ int log_set_max_level_from_string(const char *e) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void log_set_max_level_from_smbios(void) {
|
||||
int r;
|
||||
|
||||
if (is_confidential_vm())
|
||||
return; /* Don't consume SMBIOS in Confidential Computing contexts */
|
||||
|
||||
const char *level_str = smbios_find_oem_string("io.systemd.boot.loglevel=", /* after= */ NULL);
|
||||
if (!level_str)
|
||||
return;
|
||||
|
||||
r = log_set_max_level_from_string(level_str);
|
||||
if (r < 0)
|
||||
log_warning("Failed to parse log level '%s', ignoring.", level_str);
|
||||
}
|
||||
|
||||
void freeze(void) {
|
||||
for (;;)
|
||||
BS->Stall(60 * 1000 * 1000);
|
||||
|
@@ -40,6 +40,7 @@ const char* log_level_to_string(LogLevel l) _const_;
|
||||
LogLevel log_get_max_level(void) _pure_;
|
||||
int log_set_max_level(LogLevel level);
|
||||
int log_set_max_level_from_string(const char *e);
|
||||
void log_set_max_level_from_smbios(void);
|
||||
|
||||
_noreturn_ void freeze(void);
|
||||
void log_wait(void);
|
||||
|
Reference in New Issue
Block a user