dracut-034-74.git20131218

- do not systemctl daemon-reload
- do iscsistart for iscsi_firmware even without network
This commit is contained in:
Harald Hoyer 2013-12-18 16:33:33 +01:00
parent 30adad218e
commit 131b9510f9
5 changed files with 451 additions and 1 deletions

View File

@ -0,0 +1,232 @@
From 61a02caca422ddca0ee7c71e63d3cdfd786293c8 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Mon, 16 Dec 2013 13:15:48 +0100
Subject: [PATCH] test/TEST-17-LVM-THIN: add test case for lvm thin pools
---
test/TEST-17-LVM-THIN/.testdir | 1 +
test/TEST-17-LVM-THIN/99-idesymlinks.rules | 8 +++
test/TEST-17-LVM-THIN/Makefile | 10 ++++
test/TEST-17-LVM-THIN/create-root.sh | 31 +++++++++++
test/TEST-17-LVM-THIN/finished-false.sh | 2 +
test/TEST-17-LVM-THIN/hard-off.sh | 3 +
test/TEST-17-LVM-THIN/test-init.sh | 17 ++++++
test/TEST-17-LVM-THIN/test.sh | 88 ++++++++++++++++++++++++++++++
8 files changed, 160 insertions(+)
create mode 100644 test/TEST-17-LVM-THIN/.testdir
create mode 100644 test/TEST-17-LVM-THIN/99-idesymlinks.rules
create mode 100644 test/TEST-17-LVM-THIN/Makefile
create mode 100755 test/TEST-17-LVM-THIN/create-root.sh
create mode 100755 test/TEST-17-LVM-THIN/finished-false.sh
create mode 100755 test/TEST-17-LVM-THIN/hard-off.sh
create mode 100755 test/TEST-17-LVM-THIN/test-init.sh
create mode 100755 test/TEST-17-LVM-THIN/test.sh
diff --git a/test/TEST-17-LVM-THIN/.testdir b/test/TEST-17-LVM-THIN/.testdir
new file mode 100644
index 0000000..9af2638
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/.testdir
@@ -0,0 +1 @@
+TESTDIR="/var/tmp/dracut-test.uElZSK"
diff --git a/test/TEST-17-LVM-THIN/99-idesymlinks.rules b/test/TEST-17-LVM-THIN/99-idesymlinks.rules
new file mode 100644
index 0000000..d557790
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/99-idesymlinks.rules
@@ -0,0 +1,8 @@
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hda", SYMLINK+="sda"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hda*", SYMLINK+="sda$env{MINOR}"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdb", SYMLINK+="sdb"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdb*", SYMLINK+="sdb$env{MINOR}"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdc", SYMLINK+="sdc"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdc*", SYMLINK+="sdc$env{MINOR}"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", KERNEL=="hdd", SYMLINK+="sdd"
+ACTION=="add|change", SUBSYSTEM=="block", ENV{DEVTYPE}=="partition", KERNEL=="hdd*", SYMLINK+="sdd$env{MINOR}"
diff --git a/test/TEST-17-LVM-THIN/Makefile b/test/TEST-17-LVM-THIN/Makefile
new file mode 100644
index 0000000..aad2705
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/Makefile
@@ -0,0 +1,10 @@
+all:
+ @$(MAKE) -s --no-print-directory -C ../.. all
+ @V=$(V) basedir=../.. testdir=../ ./test.sh --all
+setup:
+ @$(MAKE) --no-print-directory -C ../.. all
+ @basedir=../.. testdir=../ ./test.sh --setup
+clean:
+ @basedir=../.. testdir=../ ./test.sh --clean
+run:
+ @basedir=../.. testdir=../ ./test.sh --run
diff --git a/test/TEST-17-LVM-THIN/create-root.sh b/test/TEST-17-LVM-THIN/create-root.sh
new file mode 100755
index 0000000..740704f
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/create-root.sh
@@ -0,0 +1,31 @@
+#!/bin/sh
+# don't let udev and this script step on eachother's toes
+for x in 64-lvm.rules 70-mdadm.rules 99-mount-rules; do
+ > "/etc/udev/rules.d/$x"
+done
+rm -f -- /etc/lvm/lvm.conf
+udevadm control --reload
+# save a partition at the beginning for future flagging purposes
+sfdisk -C 2560 -H 2 -S 32 -L /dev/sda <<EOF
+,1
+,800
+,800
+,800
+EOF
+for i in sda2 sda3 sda4; do
+lvm pvcreate -ff -y /dev/$i ;
+done && \
+lvm vgcreate dracut /dev/sda[234] && \
+lvm lvcreate -l 16 -T dracut/mythinpool && \
+lvm lvcreate -V1G -T dracut/mythinpool -n root && \
+lvm vgchange -ay && \
+mke2fs /dev/dracut/root && \
+mkdir -p /sysroot && \
+mount /dev/dracut/root /sysroot && \
+cp -a -t /sysroot /source/* && \
+umount /sysroot && \
+sleep 1 && \
+lvm lvchange -a n /dev/dracut/root && \
+sleep 1 && \
+echo "dracut-root-block-created" >/dev/sda1
+poweroff -f
diff --git a/test/TEST-17-LVM-THIN/finished-false.sh b/test/TEST-17-LVM-THIN/finished-false.sh
new file mode 100755
index 0000000..ecdbef9
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/finished-false.sh
@@ -0,0 +1,2 @@
+#!/bin/sh
+exit 1
diff --git a/test/TEST-17-LVM-THIN/hard-off.sh b/test/TEST-17-LVM-THIN/hard-off.sh
new file mode 100755
index 0000000..12c3d5a
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/hard-off.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+getarg rd.shell || poweroff -f
+getarg failme && poweroff -f
diff --git a/test/TEST-17-LVM-THIN/test-init.sh b/test/TEST-17-LVM-THIN/test-init.sh
new file mode 100755
index 0000000..fd03aa5
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/test-init.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+strstr() { [ "${1#*$2*}" != "$1" ]; }
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
+plymouth --quit
+exec >/dev/console 2>&1
+echo "dracut-root-block-success" >/dev/sda1
+export TERM=linux
+export PS1='initramfs-test:\w\$ '
+[ -f /etc/mtab ] || ln -sfn /proc/mounts /etc/mtab
+[ -f /etc/fstab ] || ln -sfn /proc/mounts /etc/fstab
+stty sane
+echo "made it to the rootfs!"
+strstr "$CMDLINE" "rd.shell" && sh -i
+echo "Powering down."
+mount -n -o remount,ro /
+poweroff -f
diff --git a/test/TEST-17-LVM-THIN/test.sh b/test/TEST-17-LVM-THIN/test.sh
new file mode 100755
index 0000000..0cfce19
--- /dev/null
+++ b/test/TEST-17-LVM-THIN/test.sh
@@ -0,0 +1,88 @@
+#!/bin/bash
+TEST_DESCRIPTION="root filesystem on LVM PV with thin pool"
+
+KVERSION=${KVERSION-$(uname -r)}
+
+# Uncomment this to debug failures
+#DEBUGFAIL="rd.break rd.shell"
+
+test_run() {
+ $testdir/run-qemu \
+ -hda $TESTDIR/root.ext2 \
+ -m 256M -smp 2 -nographic \
+ -net none -kernel /boot/vmlinuz-$KVERSION \
+ -append "root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug $DEBUGFAIL" \
+ -initrd $TESTDIR/initramfs.testing
+ grep -F -m 1 -q dracut-root-block-success $TESTDIR/root.ext2 || return 1
+}
+
+test_setup() {
+ # Create the blank file to use as a root filesystem
+ dd if=/dev/null of=$TESTDIR/root.ext2 bs=1M seek=80
+
+ kernel=$KVERSION
+ # Create what will eventually be our root filesystem onto an overlay
+ (
+ export initdir=$TESTDIR/overlay/source
+ . $basedir/dracut-functions.sh
+ inst_multiple sh df free ls shutdown poweroff stty cat ps ln ip route \
+ mount dmesg ifconfig dhclient mkdir cp ping dhclient
+ for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
+ [ -f ${_terminfodir}/l/linux ] && break
+ done
+ inst_multiple -o ${_terminfodir}/l/linux
+ inst "$basedir/modules.d/40network/dhclient-script.sh" "/sbin/dhclient-script"
+ inst "$basedir/modules.d/40network/ifup.sh" "/sbin/ifup"
+ inst_multiple grep
+ inst_simple /etc/os-release
+ inst ./test-init.sh /sbin/init
+ find_binary plymouth >/dev/null && inst_multiple plymouth
+ (cd "$initdir"; mkdir -p dev sys proc etc var/run tmp )
+ cp -a /etc/ld.so.conf* $initdir/etc
+ mkdir $initdir/run
+ sudo ldconfig -r "$initdir"
+ )
+
+ # second, install the files needed to make the root filesystem
+ (
+ export initdir=$TESTDIR/overlay
+ . $basedir/dracut-functions.sh
+ inst_multiple sfdisk mke2fs poweroff cp umount
+ inst_hook initqueue 01 ./create-root.sh
+ inst_hook initqueue/finished 01 ./finished-false.sh
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
+ )
+
+ # create an initramfs that will create the target root filesystem.
+ # We do it this way so that we do not risk trashing the host mdraid
+ # devices, volume groups, encrypted partitions, etc.
+ $basedir/dracut.sh -l -i $TESTDIR/overlay / \
+ -m "dash lvm mdraid udev-rules base rootfs-block kernel-modules" \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ -f $TESTDIR/initramfs.makeroot $KVERSION || return 1
+ rm -rf -- $TESTDIR/overlay
+ # Invoke KVM and/or QEMU to actually create the target filesystem.
+ $testdir/run-qemu -hda $TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
+ -kernel "/boot/vmlinuz-$kernel" \
+ -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
+ -initrd $TESTDIR/initramfs.makeroot || return 1
+ grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext2 || return 1
+ (
+ export initdir=$TESTDIR/overlay
+ . $basedir/dracut-functions.sh
+ inst_multiple poweroff shutdown
+ inst_hook emergency 000 ./hard-off.sh
+ inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
+ )
+ sudo $basedir/dracut.sh -l -i $TESTDIR/overlay / \
+ -o "plymouth network" \
+ -a "debug" -I lvs \
+ -d "piix ide-gd_mod ata_piix ext2 sd_mod" \
+ -f $TESTDIR/initramfs.testing $KVERSION || return 1
+}
+
+test_cleanup() {
+ return 0
+}
+
+. $testdir/test-functions

View File

@ -0,0 +1,17 @@
From 859e3a77d0a1343fe84fc425676d8f8fa09c558c Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Tue, 17 Dec 2013 13:36:55 +0100
Subject: [PATCH] test/TEST-17-LVM-THIN: remove .testdir
---
test/TEST-17-LVM-THIN/.testdir | 1 -
1 file changed, 1 deletion(-)
delete mode 100644 test/TEST-17-LVM-THIN/.testdir
diff --git a/test/TEST-17-LVM-THIN/.testdir b/test/TEST-17-LVM-THIN/.testdir
deleted file mode 100644
index 9af2638..0000000
--- a/test/TEST-17-LVM-THIN/.testdir
+++ /dev/null
@@ -1 +0,0 @@
-TESTDIR="/var/tmp/dracut-test.uElZSK"

View File

@ -0,0 +1,66 @@
From ab6f4a825e31b582cb77181ef6803c77236f74f0 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 18 Dec 2013 12:26:05 +0100
Subject: [PATCH] iscsi: do iscsi_firmware regardless of network
Do the iscsi_firmware iscsistart at least once, even if the network is
not up, to activate offload HBA iSCSI.
https://bugzilla.redhat.com/show_bug.cgi?id=1031160
---
modules.d/95iscsi/iscsiroot.sh | 12 +++++++-----
modules.d/95iscsi/parse-iscsiroot.sh | 2 +-
test/TEST-30-ISCSI/test.sh | 2 +-
3 files changed, 9 insertions(+), 7 deletions(-)
diff --git a/modules.d/95iscsi/iscsiroot.sh b/modules.d/95iscsi/iscsiroot.sh
index 738fff4..ef090f7 100755
--- a/modules.d/95iscsi/iscsiroot.sh
+++ b/modules.d/95iscsi/iscsiroot.sh
@@ -44,13 +44,15 @@ if getargbool 0 rd.iscsi.firmware -d -y iscsi_firmware ; then
iscsi_param="$iscsi_param --param $p"
done
- iscsistart -b $iscsi_param
- echo 'started' > "/tmp/iscsistarted-iscsi"
- echo 'started' > "/tmp/iscsistarted-firmware"
- need_shutdown
- exit 0
+ if ! [ -e /tmp/iscsistarted-firmware ] && iscsistart -b $iscsi_param; then
+ echo 'started' > "/tmp/iscsistarted-iscsi"
+ echo 'started' > "/tmp/iscsistarted-firmware"
+ need_shutdown
+ fi
+ [ "$netif" = dummy ] && exit 0
fi
+
handle_netroot()
{
local iscsi_initiator iscsi_target_name iscsi_target_ip iscsi_target_port
diff --git a/modules.d/95iscsi/parse-iscsiroot.sh b/modules.d/95iscsi/parse-iscsiroot.sh
index 0c8b524..77bd991 100755
--- a/modules.d/95iscsi/parse-iscsiroot.sh
+++ b/modules.d/95iscsi/parse-iscsiroot.sh
@@ -64,7 +64,7 @@ if [ -n "$iscsi_firmware" ] ; then
netroot=${netroot:-iscsi}
modprobe -q iscsi_boot_sysfs 2>/dev/null
modprobe -q iscsi_ibft
- echo "[ -f '/tmp/iscsistarted-firmware' ]" > $hookdir/initqueue/finished/iscsi_firmware_started.sh
+ initqueue --onetime --settled /sbin/iscsiroot dummy "$netroot" "$NEWROOT"
fi
# If it's not iscsi we don't continue
diff --git a/test/TEST-30-ISCSI/test.sh b/test/TEST-30-ISCSI/test.sh
index 4c29956..f597783 100755
--- a/test/TEST-30-ISCSI/test.sh
+++ b/test/TEST-30-ISCSI/test.sh
@@ -69,7 +69,7 @@ do_test_run() {
|| return 1
run_client "netroot=iscsi" \
- "root=LABEL=sysroot ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens3:off" \
+ "iscsi_firmware root=LABEL=sysroot ip=192.168.50.101::192.168.50.1:255.255.255.0:iscsi-1:ens3:off" \
"netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target1 netroot=iscsi:192.168.50.1::::iqn.2009-06.dracut:target2" \
|| return 1
return 0

View File

@ -0,0 +1,127 @@
From ac5bff2b6fcbeb6a2409ac9e79721c92b10b4fa9 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 18 Dec 2013 12:28:51 +0100
Subject: [PATCH] dracut-lib/wait_for_dev(): prevent systemd daemon-reload
prevent a systemd daemon-reload, if it is not necessary to do.
---
modules.d/98systemd/dracut-cmdline.sh | 2 --
modules.d/98systemd/module-setup.sh | 2 ++
modules.d/98systemd/rootfs-generator.sh | 30 ++++++++++++++++++++++++++++++
modules.d/99base/dracut-lib.sh | 30 ++++++++++++++++++++++++------
4 files changed, 56 insertions(+), 8 deletions(-)
create mode 100755 modules.d/98systemd/rootfs-generator.sh
diff --git a/modules.d/98systemd/dracut-cmdline.sh b/modules.d/98systemd/dracut-cmdline.sh
index aa8a02b..3170e75 100755
--- a/modules.d/98systemd/dracut-cmdline.sh
+++ b/modules.d/98systemd/dracut-cmdline.sh
@@ -61,8 +61,6 @@ case "$root" in
rootok=1 ;;
esac
-[ "${root%%:*}" = "block" ] && wait_for_dev "${root#block:}"
-
[ -z "$root" ] && die "No or empty root= argument"
[ -z "$rootok" ] && die "Don't know how to handle 'root=$root'"
diff --git a/modules.d/98systemd/module-setup.sh b/modules.d/98systemd/module-setup.sh
index 748e25b..74ce5f9 100755
--- a/modules.d/98systemd/module-setup.sh
+++ b/modules.d/98systemd/module-setup.sh
@@ -181,6 +181,8 @@ install() {
inst_script "$moddir/dracut-mount.sh" /bin/dracut-mount
inst_script "$moddir/dracut-pre-pivot.sh" /bin/dracut-pre-pivot
+ inst_script "$moddir/rootfs-generator.sh" /lib/systemd/system-generators/dracut-rootfs-generator
+
inst_rules 99-systemd.rules
for i in \
diff --git a/modules.d/98systemd/rootfs-generator.sh b/modules.d/98systemd/rootfs-generator.sh
new file mode 100755
index 0000000..3770c6b
--- /dev/null
+++ b/modules.d/98systemd/rootfs-generator.sh
@@ -0,0 +1,30 @@
+#!/bin/sh
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+
+type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
+root=$(getarg root=)
+case "$root" in
+ block:LABEL=*|LABEL=*)
+ root="${root#block:}"
+ root="$(echo $root | sed 's,/,\\x2f,g')"
+ root="block:/dev/disk/by-label/${root#LABEL=}"
+ rootok=1 ;;
+ block:UUID=*|UUID=*)
+ root="${root#block:}"
+ root="block:/dev/disk/by-uuid/${root#UUID=}"
+ rootok=1 ;;
+ block:PARTUUID=*|PARTUUID=*)
+ root="${root#block:}"
+ root="block:/dev/disk/by-partuuid/${root#PARTUUID=}"
+ rootok=1 ;;
+ block:PARTLABEL=*|PARTLABEL=*)
+ root="${root#block:}"
+ root="block:/dev/disk/by-partlabel/${root#PARTLABEL=}"
+ rootok=1 ;;
+ /dev/*)
+ root="block:${root}"
+ rootok=1 ;;
+esac
+
+[ "${root%%:*}" = "block" ] && wait_for_dev -n "${root#block:}"
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
index 970bcfb..85f7cdf 100755
--- a/modules.d/99base/dracut-lib.sh
+++ b/modules.d/99base/dracut-lib.sh
@@ -853,7 +853,18 @@ dev_unit_name()
wait_for_dev()
{
local _name
+ local _needreload
+ local _noreload
+
+ if [ "$1" = "-n" ]; then
+ _noreload=1
+ shift
+ fi
+
_name="$(str_replace "$1" '/' '\x2f')"
+
+ [ -e "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh" ] && return 0
+
printf '[ -e "%s" ]\n' $1 \
>> "${PREFIX}$hookdir/initqueue/finished/devexists-${_name}.sh"
{
@@ -866,14 +877,21 @@ wait_for_dev()
if ! [ -L ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device ]; then
[ -d ${PREFIX}/etc/systemd/system/initrd.target.wants ] || mkdir -p ${PREFIX}/etc/systemd/system/initrd.target.wants
ln -s ../${_name}.device ${PREFIX}/etc/systemd/system/initrd.target.wants/${_name}.device
+ _needreload=1
fi
- mkdir -p ${PREFIX}/etc/systemd/system/${_name}.device.d
- {
- echo "[Unit]"
- echo "JobTimeoutSec=3600"
- } > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
- [ -z "$PREFIX" ] && /sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload
+ if ! [ -f ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf ]; then
+ mkdir -p ${PREFIX}/etc/systemd/system/${_name}.device.d
+ {
+ echo "[Unit]"
+ echo "JobTimeoutSec=3600"
+ } > ${PREFIX}/etc/systemd/system/${_name}.device.d/timeout.conf
+ _needreload=1
+ fi
+
+ if [ -z "$PREFIX" ] && [ "$_needreload" = 1 ] && [ -z "$_noreload" ]; then
+ /sbin/initqueue --onetime --unique --name daemon-reload systemctl daemon-reload
+ fi
fi
}

View File

@ -10,7 +10,7 @@
Name: dracut
Version: 034
Release: 70.git20131216%{?dist}
Release: 74.git20131218%{?dist}
Summary: Initramfs generator using udev
%if 0%{?fedora} || 0%{?rhel}
@ -98,6 +98,10 @@ Patch66: 0066-fcoe-move-uefi-parsing-to-fcoe-uefi-module.patch
Patch67: 0067-move-uefi-lib-to-a-seperate-module.patch
Patch68: 0068-lvm-fixed-lvm-thin-check.patch
Patch69: 0069-dracut.spec-add-95fcoe-uefi-and-99uefi-lib.patch
Patch70: 0070-test-TEST-17-LVM-THIN-add-test-case-for-lvm-thin-poo.patch
Patch71: 0071-test-TEST-17-LVM-THIN-remove-.testdir.patch
Patch72: 0072-iscsi-do-iscsi_firmware-regardless-of-network.patch
Patch73: 0073-dracut-lib-wait_for_dev-prevent-systemd-daemon-reloa.patch
BuildRequires: bash git
@ -525,6 +529,10 @@ rm -rf -- $RPM_BUILD_ROOT
%endif
%changelog
* Wed Dec 18 2013 Harald Hoyer <harald@redhat.com> 034-74.git20131218
- do not systemctl daemon-reload
- do iscsistart for iscsi_firmware even without network
* Mon Dec 16 2013 Harald Hoyer <harald@redhat.com> 034-70.git20131216
- fixed systemd password waiting
- split out fcoe uefi