KVERSION=${KVERSION-$(uname -r)}
# Uncomment this to debug failures
-#DEBUGFAIL="rdinitdebug rdnetdebug"
+#DEBUGFAIL="rdinitdebug rdnetdebug rdbreak"
run_server() {
# Start server first
local test_name="$1"
local mac=$2
local cmdline="$3"
+ local fstype=$4
+ local fsopt=$5
+ local found opts nbdinfo
+
+ [[ $fstype ]] || fstype=ext3
+ [[ $fsopt ]] || fsopt="errors=continue"
echo "CLIENT TEST START: $test_name"
return 1
fi
+ # nbdinfo=( fstype fsoptions )
+ nbdinfo=($(awk '{print $2, $3; exit}' flag.img))
+
+ if [[ "${nbdinfo[0]}" != "$fstype" ]]; then
+ echo "CLIENT TEST END: $test_name [FAILED - WRONG FS TYPE]"
+ return 1
+ fi
+
+ opts=${nbdinfo[1]},
+ while [[ $opts ]]; do
+ if [[ ${opts%%,*} == $fsopt ]]; then
+ found=1
+ break
+ fi
+ opts=${opts#*,}
+ done
+
+ if [[ ! $found ]]; then
+ echo "CLIENT TEST END: $test_name [FAILED - BAD FS OPTS]"
+ return 1
+ fi
+
echo "CLIENT TEST END: $test_name [OK]"
}
return 1
fi
- client_test "NBD root=nbd:..." 52:54:00:12:34:00 \
+ # The default is ext3,errors=continue so use that to determine
+ # if our options were parsed and used
+
+ client_test "NBD root=nbd:IP:port" 52:54:00:12:34:00 \
"root=nbd:192.168.50.1:2000" || return 1
+ client_test "NBD root=nbd:IP:port:fstype" 52:54:00:12:34:00 \
+ "root=nbd:192.168.50.1:2000:ext2" ext2 || return 1
+
+ client_test "NBD root=nbd:IP:port::fsopts" 52:54:00:12:34:00 \
+ "root=nbd:192.168.50.1:2000::errors=panic" \
+ ext3 errors=panic || return 1
+
+ client_test "NBD root=nbd:IP:port:fstype:fsopts" 52:54:00:12:34:00 \
+ "root=nbd:192.168.50.1:2000:ext2:errors=panic" \
+ ext2 errors=panic || return 1
+
+ # There doesn't seem to be a good way to validate the NBD options, so
+ # just check that we don't screw up the other options
+
+ client_test "NBD root=nbd:IP:port:::NBD opts" 52:54:00:12:34:00 \
+ "root=nbd:192.168.50.1:2000:::bs=2048" || return 1
+
+ client_test "NBD root=nbd:IP:port:fstype::NBD opts" 52:54:00:12:34:00 \
+ "root=nbd:192.168.50.1:2000:ext2::bs=2048" ext2 || return 1
+
+ client_test "NBD root=nbd:IP:port:fstype:fsopts:NBD opts" \
+ 52:54:00:12:34:00 \
+ "root=nbd:192.168.50.1:2000:ext2:errors=panic:bs=2048" \
+ ext2 errors=panic || return 1
+
+ # Check legacy parsing
+
client_test "NBD root=nbd nbdroot=srv:port" 52:54:00:12:34:00 \
"root=nbd nbdroot=192.168.50.1:2000" || return 1
client_test "NBD root=dhcp nbdroot=srv,port" 52:54:00:12:34:00 \
"root=dhcp nbdroot=192.168.50.1,2000" || return 1
+ # DHCP root-path parsing
+
client_test "NBD root=dhcp DHCP root-path nbd:srv:port" 52:54:00:12:34:01 \
"root=dhcp" || return 1
+
+ client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype" \
+ 52:54:00:12:34:02 "root=dhcp" ext2 || return 1
+
+ client_test "NBD root=dhcp DHCP root-path nbd:srv:port::fsopts" \
+ 52:54:00:12:34:03 "root=dhcp" ext3 errors=panic || return 1
+
+ client_test "NBD root=dhcp DHCP root-path nbd:srv:port:fstype:fsopts" \
+ 52:54:00:12:34:04 "root=dhcp" ext2 errors=panic || return 1
}
make_client_root() {
dd if=/dev/zero of=nbd.ext2 bs=1M count=30
- mke2fs -F nbd.ext2
+ mke2fs -F -j nbd.ext2
mkdir mnt
sudo mount -o loop nbd.ext2 mnt
initdir=mnt
. $basedir/dracut-functions
dracut_install sh ls shutdown poweroff stty cat ps ln ip \
- /lib/terminfo/l/linux dmesg mkdir cp ping
+ /lib/terminfo/l/linux dmesg mkdir cp ping
inst ./client-init /sbin/init
(
cd "$initdir";
sudo $basedir/dracut -l -i overlay / \
-m "dash crypt lvm mdraid udev-rules base rootfs-block nbd debug" \
- -d "ata_piix ext2 sd_mod e1000" \
+ -d "ata_piix ext2 ext3 sd_mod e1000" \
-f initramfs.testing $KVERSION || return 1
}