Skip to content

Commit

Permalink
(squash) Move dracut-specific parts into dropins
Browse files Browse the repository at this point in the history
  • Loading branch information
tbzatek committed Feb 18, 2025
1 parent 4f7b651 commit fb13046
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 19 deletions.
25 changes: 15 additions & 10 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,27 @@ foreach file : dracut_conf_files
)
endforeach

systemd_files = [
'nvmefc-boot-connections.service',
'nvmf-autoconnect.service',
'nvmf-connect-nbft.service',
'nvmf-connect.target',
'[email protected]',
]

want_dracut_module = get_option('dracut-module')
if want_dracut_module
dracut_nbft_files = [
'module-setup.sh',
systemd_files += [
'nbft-boot-pre.service',
'nbft-boot-connect.service'
]

dracut_nbft_files = [
'module-setup.sh',
'nbft-boot-pre-dracut.conf',
'nbft-boot-connect-dracut.conf'
]

foreach file : dracut_nbft_files
configure_file(
input: 'nvmf-autoconnect/dracut-95nbft/' + file + '.in',
Expand Down Expand Up @@ -278,14 +291,6 @@ if want_dracut_module
endforeach
endif

systemd_files = [
'nvmefc-boot-connections.service',
'nvmf-autoconnect.service',
'nvmf-connect-nbft.service',
'nvmf-connect.target',
'[email protected]',
]

foreach file : systemd_files
configure_file(
input: 'nvmf-autoconnect/systemd/' + file + '.in',
Expand Down
3 changes: 3 additions & 0 deletions nvmf-autoconnect/dracut-95nbft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ While this module is currently built around dracut, the amount of dracut
involvement in this module is kept to a required minimum with the intention
of supporting more initramfs frameworks (like `mkosi`) in the future.

This is achieved by splitting the framework-specific directives into systemd
unit dropins while keeping the main unit files generic.

Related nvme-cli meson configure options:
* `-Ddracut-module` (default=false) - enables the 95nbft dracut module
* `-Ddracutmodulesdir` (default=`$prefix/lib/dracut/modules.d/`)
Expand Down
8 changes: 7 additions & 1 deletion nvmf-autoconnect/dracut-95nbft/module-setup.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,16 @@ install() {
# TODO: /etc/nvme/hostnqn

inst_multiple "$systemdsystemunitdir"/[email protected]

inst_simple "$moddir/nbft-boot-pre-dracut.conf" \
"$systemdsystemunitdir/nbft-boot-pre.service.d/nbft-boot-pre-dracut.conf"
inst_simple "$moddir/nbft-boot-connect-dracut.conf" \
"$systemdsystemunitdir/nbft-boot-connect.service.d/nbft-boot-connect-dracut.conf"

for i in \
nbft-boot-pre.service \
nbft-boot-connect.service; do
inst_simple "${moddir}/$i" "${systemdsystemunitdir}/$i"
inst_multiple "${systemdsystemunitdir}/$i"
$SYSTEMCTL -q --root "$initdir" enable $i
done
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[Unit]
Before=dracut-initqueue.service
6 changes: 6 additions & 0 deletions nvmf-autoconnect/dracut-95nbft/nbft-boot-pre-dracut.conf.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[Unit]
Before=dracut-cmdline.service

[Service]
# Tell dracut to start networking
ExecStart=bash -c 'echo rd.neednet=1 > /etc/cmdline.d/95nbft-args.conf'
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# This unit parses the ACPI NBFT table and performs actual NVMe/TCP connections
# Establish NVMe/TCP connections as defined in the ACPI NBFT table

[Unit]
# Prevent deadlock by avoiding systemd adding dependencies
# on unreachable targets.
Expand All @@ -11,7 +12,6 @@ After=modprobe@nvme_fabrics.service
Wants=network-online.target
After=network-online.target
Before=remote-fs-pre.target
Before=dracut-initqueue.service

[Service]
RestrictAddressFamilies=AF_INET AF_INET6
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
# This unit checks for the ACPI NBFT table presence and tells
# dracut to activate networking.
# This unit checks for the ACPI NBFT table presence and sets up
# defined network interfaces

[Unit]
DefaultDependencies=no
# Specify 'rd.nvmf.nonbft' to disable NBFT boot
ConditionKernelCommandLine=!rd.nvmf.nonbft
ConditionPathExistsGlob=/sys/firmware/acpi/tables/NBFT*
Before=dracut-cmdline.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStartPre=-/usr/bin/mkdir -p /etc/systemd/network
# generate udev link files
ExecStart=/usr/sbin/nvme nbft gen-udev-link-files /etc/systemd/network/
# tell dracut to start the network
ExecStart=bash -c 'echo rd.neednet=1 > /etc/cmdline.d/95nbft-args.conf'

[Install]
WantedBy=sysinit.target

0 comments on commit fb13046

Please sign in to comment.