1
0
mirror of https://github.com/systemd/systemd.git synced 2025-02-28 05:57:33 +03:00
Lennart Poettering 2025-01-03 09:34:50 +01:00 committed by GitHub
commit 36d2096b84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 45 additions and 29 deletions

@ -56,7 +56,7 @@
<command>mask</command> command. This is useful to boot with certain units removed from the initial <command>mask</command> command. This is useful to boot with certain units removed from the initial
boot transaction for debugging system startup. May be specified more than once. The option prefixed boot transaction for debugging system startup. May be specified more than once. The option prefixed
with <literal>rd.</literal> is honored only in the initrd, while the one without prefix is only with <literal>rd.</literal> is honored only in the initrd, while the one without prefix is only
honored in the main system.</para> honored on the host.</para>
<xi:include href="version-info.xml" xpointer="v215"/></listitem> <xi:include href="version-info.xml" xpointer="v215"/></listitem>
</varlistentry> </varlistentry>
@ -68,7 +68,7 @@
<listitem><para>These options take a unit name as argument. A start job for this unit is added to the <listitem><para>These options take a unit name as argument. A start job for this unit is added to the
initial transaction. This is useful to start one or more additional units at boot. May be specified initial transaction. This is useful to start one or more additional units at boot. May be specified
more than once. The option prefixed with <literal>rd.</literal> is honored only in the initrd, while more than once. The option prefixed with <literal>rd.</literal> is honored only in the initrd, while
the one that is not prefixed only in the main system.</para> the one that is not prefixed only on the host.</para>
<xi:include href="version-info.xml" xpointer="v215"/></listitem> <xi:include href="version-info.xml" xpointer="v215"/></listitem>
</varlistentry> </varlistentry>
@ -89,7 +89,7 @@
shell may also be turned on persistently by enabling it with shell may also be turned on persistently by enabling it with
<citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s <citerefentry><refentrytitle>systemctl</refentrytitle><manvolnum>1</manvolnum></citerefentry>'s
<command>enable</command> command. The options prefixed with <literal>rd.</literal> are honored only <command>enable</command> command. The options prefixed with <literal>rd.</literal> are honored only
in the initrd, while the ones without prefix are only honored in the main system.</para> in the initrd, while the ones without prefix are only honored on the host.</para>
<xi:include href="version-info.xml" xpointer="v215"/></listitem> <xi:include href="version-info.xml" xpointer="v215"/></listitem>
</varlistentry> </varlistentry>
@ -103,8 +103,8 @@
<literal>rd.</literal> option). It also accepts multiple values separated by comma <literal>rd.</literal> option). It also accepts multiple values separated by comma
(<literal>,</literal>). These options allow to pause the boot process at a certain point and spawn a (<literal>,</literal>). These options allow to pause the boot process at a certain point and spawn a
debug shell. After exiting this shell, the system will resume booting. The option prefixed with debug shell. After exiting this shell, the system will resume booting. The option prefixed with
<literal>rd.</literal> is honored only in the initrd, while the one without prefix is only honored in <literal>rd.</literal> is honored only in the initrd, while the one without prefix is only honored on
the main system.</para> the host.</para>
<table> <table>
<title>Available breakpoints</title> <title>Available breakpoints</title>
@ -113,13 +113,13 @@
<colspec colname='breakpoint' /> <colspec colname='breakpoint' />
<colspec colname='description' /> <colspec colname='description' />
<colspec colname='initrd' /> <colspec colname='initrd' />
<colspec colname='main' /> <colspec colname='host' />
<thead> <thead>
<row> <row>
<entry>Breakpoints</entry> <entry>Breakpoints</entry>
<entry>Description</entry> <entry>Description</entry>
<entry>Can be used in the initrd</entry> <entry>Can be used in the initrd</entry>
<entry>Can be used in the main system</entry> <entry>Can be used on the host</entry>
</row> </row>
</thead> </thead>
<tbody> <tbody>

@ -66,10 +66,23 @@ static const struct BreakpointInfo breakpoint_info_table[_BREAKPOINT_TYPE_MAX] =
{ BREAKPOINT_PRE_SWITCH_ROOT, "pre-switch-root", "breakpoint-pre-switch-root.service", BREAKPOINT_IN_INITRD | BREAKPOINT_DEFAULT }, { BREAKPOINT_PRE_SWITCH_ROOT, "pre-switch-root", "breakpoint-pre-switch-root.service", BREAKPOINT_IN_INITRD | BREAKPOINT_DEFAULT },
}; };
static bool breakpoint_applies(const BreakpointInfo *info, int log_level) {
assert(info);
if (in_initrd() && !FLAGS_SET(info->validity, BREAKPOINT_IN_INITRD))
log_full(log_level, "Breakpoint '%s' not valid in the initrd, ignoring.", info->name);
else if (!in_initrd() && !FLAGS_SET(info->validity, BREAKPOINT_ON_HOST))
log_full(log_level, "Breakpoint '%s' not valid on the host, ignoring.", info->name);
else
return true;
return false;
}
static BreakpointType parse_breakpoint_from_string_one(const char *s) { static BreakpointType parse_breakpoint_from_string_one(const char *s) {
assert(s); assert(s);
FOREACH_ARRAY(i, breakpoint_info_table, ELEMENTSOF(breakpoint_info_table)) FOREACH_ELEMENT(i, breakpoint_info_table)
if (streq(i->name, s)) if (streq(i->name, s))
return i->type; return i->type;
@ -84,14 +97,18 @@ static int parse_breakpoint_from_string(const char *s, uint32_t *ret_breakpoints
/* Empty value? set default breakpoint */ /* Empty value? set default breakpoint */
if (isempty(s)) { if (isempty(s)) {
if (in_initrd()) { bool found_default = false;
FOREACH_ARRAY(i, breakpoint_info_table, ELEMENTSOF(breakpoint_info_table))
if (i->validity & BREAKPOINT_DEFAULT) { FOREACH_ELEMENT(i, breakpoint_info_table)
breakpoints |= 1 << i->type; if (FLAGS_SET(i->validity, BREAKPOINT_DEFAULT) && breakpoint_applies(i, INT_MAX)) {
break; breakpoints |= 1 << i->type;
} found_default = true;
} else break;
log_warning("No default breakpoint defined on the host, ignoring breakpoint request from kernel command line."); }
if (!found_default)
log_warning("No default breakpoint defined %s, ignoring.",
in_initrd() ? "in the initrd" : "on the host");
} else } else
for (;;) { for (;;) {
_cleanup_free_ char *t = NULL; _cleanup_free_ char *t = NULL;
@ -109,11 +126,7 @@ static int parse_breakpoint_from_string(const char *s, uint32_t *ret_breakpoints
continue; continue;
} }
if (in_initrd() && !FLAGS_SET(breakpoint_info_table[tt].validity, BREAKPOINT_IN_INITRD)) if (breakpoint_applies(&breakpoint_info_table[tt], LOG_WARNING))
log_warning("Breakpoint '%s' not valid in the initrd, ignoring.", t);
else if (!in_initrd() && !FLAGS_SET(breakpoint_info_table[tt].validity, BREAKPOINT_ON_HOST))
log_warning("Breakpoint '%s' not valid on the host, ignoring.", t);
else
breakpoints |= 1 << tt; breakpoints |= 1 << tt;
} }

@ -8,12 +8,13 @@
# (at your option) any later version. # (at your option) any later version.
[Unit] [Unit]
Description=Breakpoint Before Basic System Description=Breakpoint Before basic.target
Documentation=man:systemd-debug-generator(8) Documentation=man:systemd-debug-generator(8)
DefaultDependencies=no DefaultDependencies=no
RefuseManualStart=yes
Conflicts=shutdown.target emergency.target Conflicts=shutdown.target emergency.target
After=sysinit.target sockets.target paths.target slices.target tmp.mount systemd-vconsole-setup.service After=sysinit.target sockets.target paths.target slices.target tmp.mount systemd-vconsole-setup.service
Before=basic.target Before=basic.target initrd-root-fs.target sysroot.mount shutdown.target emergency.target
[Service] [Service]
Environment=SHELL_PROMPT_PREFIX="pre-basic " Environment=SHELL_PROMPT_PREFIX="pre-basic "

@ -8,13 +8,14 @@
# (at your option) any later version. # (at your option) any later version.
[Unit] [Unit]
Description=Breakpoint Before Mounting the Root Filesystem on /sysroot Description=Breakpoint Before Mounting the Root Filesystem on /sysroot/
Documentation=man:systemd-debug-generator(8) Documentation=man:systemd-debug-generator(8)
AssertPathExists=/etc/initrd-release AssertPathExists=/etc/initrd-release
DefaultDependencies=no DefaultDependencies=no
RefuseManualStart=yes
Conflicts=shutdown.target emergency.target Conflicts=shutdown.target emergency.target
After=basic.target systemd-vconsole-setup.service After=basic.target systemd-vconsole-setup.service
Before=initrd-root-fs.target sysroot.mount systemd-fsck-root.service Before=initrd-root-fs.target sysroot.mount systemd-fsck-root.service shutdown.target emergency.target
[Service] [Service]
Environment=SHELL_PROMPT_PREFIX="pre-mount " Environment=SHELL_PROMPT_PREFIX="pre-mount "

@ -12,10 +12,10 @@ Description=Breakpoint Before Switching Root
Documentation=man:systemd-debug-generator(8) Documentation=man:systemd-debug-generator(8)
AssertPathExists=/etc/initrd-release AssertPathExists=/etc/initrd-release
DefaultDependencies=no DefaultDependencies=no
RefuseManualStart=yes
Conflicts=shutdown.target emergency.target Conflicts=shutdown.target emergency.target
Wants=remote-fs.target After=initrd.target initrd-parse-etc.service remote-fs.target systemd-vconsole-setup.service
After=initrd.target initrd-parse-etc.service sysroot.mount remote-fs.target systemd-vconsole-setup.service Before=initrd-cleanup.service shutdown.target emergency.target
Before=initrd-cleanup.service
[Service] [Service]
Environment=SHELL_PROMPT_PREFIX="pre-switch-root " Environment=SHELL_PROMPT_PREFIX="pre-switch-root "

@ -11,10 +11,11 @@
Description=Breakpoint Before Starting to Process Kernel uevents Description=Breakpoint Before Starting to Process Kernel uevents
Documentation=man:systemd-debug-generator(8) Documentation=man:systemd-debug-generator(8)
DefaultDependencies=no DefaultDependencies=no
RefuseManualStart=yes
Conflicts=shutdown.target emergency.target Conflicts=shutdown.target emergency.target
Wants=systemd-journald.socket Wants=systemd-journald.socket
After=systemd-journald.socket systemd-vconsole-setup.service After=systemd-journald.socket systemd-vconsole-setup.service
Before=systemd-udevd.service systemd-udev-trigger.service Before=systemd-udevd.service systemd-udev-trigger.service shutdown.target emergency.target
[Service] [Service]
Environment=SHELL_PROMPT_PREFIX="pre-udev " Environment=SHELL_PROMPT_PREFIX="pre-udev "