home: hub: mkinitfs

Download patch

ref: a512e4360c1e75bab1bef62ee7b4067edcb7c9d9
parent: bf598dbe1e4642213f111cd7039fb94b0d1f1853
author: grobe0ba <grobe0ba@tcp80.org>
date: Tue May 23 09:30:10 CDT 2023

init: support for booting from an aoe device

- aoe: causes the aoe module to be loaded. if passed a comma separated
list of targets, it will attempt to explicitly discover these targets.
aoe autodiscovery is automatic on linux, so passing a list of targets
should not generally be needed.

- aoe_iflist: takes a comma separated list of ethernet interfaces to
attach to the aoe subsystem. this also ensures that those links are set
to `up'. you effectively must pass this to use aoe because it is useless
without being bound to at least one interface.

it is up to the user to add the `network' and `aoe' features to
mkinitfs.conf, and the necessary modules for the nic to the bootloader
modules= configuration.

Signed-off-by: grobe0ba <grobe0ba@tcp80.org>

--- a/Makefile
+++ b/Makefile
@@ -11,6 +11,7 @@
 SHARE_FILES	:= initramfs-init fstab passwd group
 CONF_FILES	:= mkinitfs.conf \
 		features.d/ata.modules \
+		features.d/aoe.modules \
 		features.d/base.files \
 		features.d/base.modules \
 		features.d/bootchart.files \
--- /dev/null
+++ b/features.d/aoe.modules
@@ -1,0 +1,1 @@
+kernel/drivers/block/aoe/*.ko*
--- a/initramfs-init.in
+++ b/initramfs-init.in
@@ -378,7 +378,7 @@
 	cryptdiscards cryptkey debug_init dma init init_args keep_apk_new modules ovl_dev
 	pkgs quiet root_size root usbdelay ip alpine_repo apkovl alpine_start splash
 	blacklist overlaytmpfs overlaytmpfsflags rootfstype rootflags nbd resume s390x_net
-	dasd ssh_key BOOTIF zfcp uevent_buf_size"
+	dasd ssh_key BOOTIF zfcp uevent_buf_size aoe aoe_iflist aoe_mtu"
 
 for opt; do
 	case "$opt" in
@@ -531,6 +531,28 @@
 	# TODO: Might fail because nlplug-findfs hasn't plugged eth0 yet
 	configure_ip
 	setup_nbd || echo "Failed to setup nbd device."
+fi
+
+if [ -n "$KOPT_aoe" ]; then
+	if [ -n "$KOPT_aoe_iflist" ]; then
+		for iface in $(echo "$KOPT_aoe_iflist" | tr ',' ' '); do
+			$MOCK ip link set dev "$iface" up
+			if [ -n "$KOPT_aoe_mtu" ]; then
+				$MOCK ip link set dev "$iface" mtu "$KOPT_aoe_mtu"
+			fi
+		done
+		$MOCK modprobe aoe aoe_iflist="$KOPT_aoe_iflist"
+	else
+		$MOCK modprobe aoe
+	fi
+	if [ "$KOPT_aoe" != "yes" ]; then
+		for target in $(echo "$KOPT_aoe" | tr ',' ' '); do
+			while [ ! -e /dev/etherd/e$target ]; do
+					echo discover "$target" >>/dev/etherd/discover
+					sleep 1
+			done
+		done
+	fi
 fi
 
 # zpool reports /dev/zfs missing if it can't read /etc/mtab
--- a/tests/initramfs-init.test
+++ b/tests/initramfs-init.test
@@ -15,7 +15,8 @@
 	initramfs_init_tmpfs_root_remount_opts \
 	initramfs_init_tmpfs_root_tiny_cloud \
 	initramfs_init_tmpfs_root_tiny_cloud_disabled \
-	initramfs_init_tmpfs_root_apkovl_url
+	initramfs_init_tmpfs_root_apkovl_url \
+	initramfs_init_aoe
 
 fake_cmdline() {
 	mkdir -p proc
@@ -287,4 +288,14 @@
 		initramfs-init
 }
 
+initramfs_init_aoe_body() {
+	fake_cmdline "aoe=yes aoe_iflist=eth0 aoe_mtu=9000"
+	fake_sysroot_init
+	fake_switch_root
 
+	atf_check \
+		-o match:'ip link set dev eth0 up' \
+		-o match:'ip link set dev eth0 mtu 9000' \
+		-o match:'modprobe aoe aoe_iflist=eth0' \
+		initramfs-init
+}