]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Merge pull request #197 from danimo/update-gitignore
authorHarald Hoyer <harald@redhat.com>
Wed, 25 Jan 2017 13:55:08 +0000 (14:55 +0100)
committerGitHub <noreply@github.com>
Wed, 25 Jan 2017 13:55:08 +0000 (14:55 +0100)
Ignore more generated files

65 files changed:
.dir-locals.el
NEWS
README.md
README.testsuite
dracut-init.sh
dracut.8.asc
dracut.cmdline.7.asc
dracut.conf.5.asc
dracut.modules.7.asc
dracut.sh
dracut.spec
install/dracut-install.c
modules.d/01fips/module-setup.sh
modules.d/10i18n/module-setup.sh
modules.d/40network/dhclient-script.sh
modules.d/40network/ifup.sh
modules.d/40network/net-genrules.sh
modules.d/40network/net-lib.sh
modules.d/40network/parse-vlan.sh
modules.d/45ifcfg/write-ifcfg.sh
modules.d/90crypt/module-setup.sh
modules.d/90kernel-network-modules/module-setup.sh
modules.d/95iscsi/iscsiroot.sh
modules.d/95nfs/module-setup.sh
modules.d/95nfs/parse-nfsroot.sh
modules.d/95ssh-client/module-setup.sh
modules.d/95terminfo/module-setup.sh
modules.d/98dracut-systemd/dracut-cmdline.sh
modules.d/98dracut-systemd/dracut-pre-mount.sh
modules.d/98dracut-systemd/dracut-pre-pivot.sh
modules.d/98dracut-systemd/dracut-pre-trigger.sh
modules.d/99base/dracut-lib.sh
modules.d/99base/init.sh
modules.d/99base/memtrace-ko.sh [new file with mode: 0755]
modules.d/99base/module-setup.sh
test/Makefile
test/TEST-01-BASIC/test.sh
test/TEST-02-SYSTEMD/test.sh
test/TEST-03-USR-MOUNT/test.sh
test/TEST-04-FULL-SYSTEMD/test.sh
test/TEST-10-RAID/test.sh
test/TEST-11-LVM/test.sh
test/TEST-12-RAID-DEG/test.sh
test/TEST-13-ENC-RAID-LVM/test.sh
test/TEST-14-IMSM/test.sh
test/TEST-15-BTRFSRAID/test.sh
test/TEST-16-DMSQUASH/test.sh
test/TEST-17-LVM-THIN/test.sh
test/TEST-20-NFS/test.sh
test/TEST-30-ISCSI/test.sh
test/TEST-40-NBD/test.sh
test/TEST-50-MULTINIC/test.sh
test/TEST-70-BONDBRIDGETEAMVLAN/99-idesymlinks.rules [new file with mode: 0644]
test/TEST-70-BONDBRIDGETEAMVLAN/Makefile [new file with mode: 0644]
test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh [new file with mode: 0755]
test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf [new file with mode: 0644]
test/TEST-70-BONDBRIDGETEAMVLAN/exports [new file with mode: 0644]
test/TEST-70-BONDBRIDGETEAMVLAN/finished-false.sh [moved from test/TEST-99-RPM/finished-false.sh with 100% similarity]
test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh [new file with mode: 0755]
test/TEST-70-BONDBRIDGETEAMVLAN/hosts [new file with mode: 0644]
test/TEST-70-BONDBRIDGETEAMVLAN/server-init.sh [new file with mode: 0755]
test/TEST-70-BONDBRIDGETEAMVLAN/test.sh [new file with mode: 0755]
test/TEST-99-RPM/test.sh
test/run-qemu
test/test-rhel-7.2.rpms [deleted file]

index 81300584ea0163eff30b27ab3ad4d24492a91cf9..b38d4d63f19136fda0bf529216bccd7a2075c01e 100644 (file)
@@ -1,3 +1,7 @@
-((nil . ((sh-basic-offset . 4)
-         (indent-tabs-mode . nil)
-         )))
+;;; Directory Local Variables
+;;; For more information see (info "(emacs) Directory Variables")
+
+((sh-mode
+  (indent-tabs-mode)
+  (sh-basic-offset . 4)))
+
diff --git a/NEWS b/NEWS
index 6f68de81486b9246829ffd31e9c88c974ca3c7d7..2766a802472e30e071e47b69949b3f5fdd4f361a 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ dracut now requires libkmod for the dracut-install binary helper.
 dracut.sh:
 - restorecon final image file
 - fail hard, if we find modules and modules.dep is missing
+- support --tmpdir as a relative path
+- add default path for --uefi
 
 dracut-functions.sh:
 - fix check_vol_slaves() volume group name stripping
@@ -23,6 +25,7 @@ dracut-install:
     --silent
     --kerneldir
     --firmwaredirs
+- fallback to non-hostonly mode if lsmod fails
 
 lsinitrd:
 - new option "--unpack"
@@ -35,6 +38,8 @@ general initramfs fixes:
 - break at switch_root only for bare rd.break
 - add rd.emergency=[reboot|poweroff|halt]
   specifies what action to execute in case of a critical failure
+- rd.memdebug=4 gives information, about kernel module memory consumption
+  during loading
 
 dmsquash-live:
 - fixed livenet-generator execution flag
@@ -53,6 +58,8 @@ kernel-modules:
   people swap keyboards sometimes and should be able to enter their disk password
 - add usb-storage
   To save the rdsosreport.txt to a USB stick, the usb-storage module is needed.
+- add xennet
+- add nvme
 
 systemd:
 - add /etc/machine-info
@@ -74,6 +81,7 @@ network:
 - support for iBFT IPv6
 - support macaddr in brackets [] (commit 740c46c0224a187d6b5a42b4aa56e173238884cc)
 - use arping2, if available
+- support multiple default gateways from DHCP server
 
 nbd:
 - add systemd generator
@@ -92,6 +100,19 @@ fips:
 plymouth:
 - also trigger the acpi subsystem
 
+syslog:
+- add imjournal.so to read systemd journal
+- move start from udev to initqueue/online
+
+caps:
+- make it a non default module
+
+livenet:
+- support nfs:// urls in livenet-generator
+
+nfs:
+- install all nfs modules non-hostonly
+
 dracut-044
 ==========
 creation:
index 27ad3eaa9eb1030298a8b2329af507a9b5efaf50..781de62801737c3a6098cc44b9616b8b36057ed5 100644 (file)
--- a/README.md
+++ b/README.md
@@ -2,3 +2,5 @@
 
 dracut is an initramfs infrastructure.
 
+CentOS CI: [![Build Status](https://ci.centos.org/job/dracut-push-master/badge/icon)](https://ci.centos.org/job/dracut-push-master/)
+
index 127e3025ab46a0c7d211218067b7a5e94d155ec5..dc08df34178b0eff2bf39e3bb501174d4803c2a7 100644 (file)
@@ -4,6 +4,7 @@ bridge-utils \
 asciidoc \
 mdadm \
 lvm2 \
+dmraid \
 cryptsetup \
 nfs-utils \
 nbd \
@@ -24,7 +25,6 @@ xz \
 tar \
 wget \
 rpm-build \
-dash \
 ${NULL}
 
 TEST-04-FULL-SYSTEMD: systemd >= 187
index 7f628ce964e81750fbdbeb0f7823493ff6a7426e..239fb68478f4e449fe9579324678fa0a843b759b 100644 (file)
 #
 export LC_MESSAGES=C
 
+if [[ "$EUID" = "0" ]]; then
+    export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,xattr,links -dfr"
+else
+    export DRACUT_CP="cp --reflink=auto --sparse=auto --preserve=mode,timestamps,links -dfr"
+fi
+
 # is_func <command>
 # Check whether $1 is a function.
 is_func() {
index 0e017070a6e8909b217180406eb3531b1a26302a..4ab0872f8bc2262445662786facb531c5dfe574d 100644 (file)
@@ -485,7 +485,15 @@ will not be able to boot.
 
 **--uefi**::
     Instead of creating an initramfs image, dracut will create an UEFI executable,
-    which can be executed by an UEFI BIOS.
+    which can be executed by an UEFI BIOS. The default output filename is
+    _<EFI>/EFI/Linux/linux-$kernel$-<MACHINE_ID>-<BUILD_ID>.efi_. <EFI> might be
+    _/efi_, _/boot_ or _/boot/efi_ depending on where the ESP partition is mounted.
+    The <BUILD_ID> is taken from BUILD_ID in _/usr/lib/os-release_ or if it exists
+    _/etc/os-release_ and is left out, if BUILD_ID is non-existant or empty.
+
+**--no-machineid**::
+    affects the default output filename of **--uefi** and will discard the <MACHINE_ID>
+    part.
 
 **--uefi-stub _<FILE>_**::
     Specifies the UEFI stub loader, which will load the attached kernel, initramfs and
index 0009ff247d8383c3ee6eca948de1cfe33500cd52..36d5656106b21a58e654e43c4239042df61ce5f4 100644 (file)
@@ -187,8 +187,8 @@ It should be attached to any report about dracut problems.
     _/run/initramfs/init.log_.
     If "quiet" is set, it also logs to the console.
 
-**rd.memdebug=[0-3]**::
-    Print memory usage info at various points, set the verbose level from 0 to 3.
+**rd.memdebug=[0-4]**::
+    Print memory usage info at various points, set the verbose level from 0 to 4.
 +    
     Higher level means more debugging output:
 +
@@ -197,6 +197,10 @@ It should be attached to any report about dracut problems.
     1 - partial /proc/meminfo
     2 - /proc/meminfo
     3 - /proc/meminfo + /proc/slabinfo
+    4 - /proc/meminfo + /proc/slabinfo + tracekomem
+        NOTE: tracekomem is a shell script utilizing kernel trace to track
+              the rough total memory consumption of kernel modules during
+              loading. It may override other trace configurations.
 ----
 
 **rd.break**::
@@ -608,7 +612,7 @@ NFS
     method. This is supported by dracut, but not recommended.
 
 **rd.nfs.domain=**__<NFSv4 domain name>__::
-    Set the NFSv4 domain name. Will overwrite the settings in _/etc/idmap.conf_.
+    Set the NFSv4 domain name. Will override the settings in _/etc/idmap.conf_.
 
 **rd.net.dhcp.retry=**__<cnt>__::
     If this option is set, dracut will try to connect via dhcp <cnt> times before failing.
index 318024a94e0c4bf995465bcba05dc13c4083e361..6e1155b557dba714cfe2929142f865e9f8b0d30c 100644 (file)
@@ -17,17 +17,17 @@ _/usr/lib/dracut/dracut.conf.d/*.conf_
 Description
 -----------
 _dracut.conf_ is loaded during the initialisation phase of dracut. Command line
-parameter will overwrite any values set here.
+parameter will override any values set here.
 
 _*.conf_ files are read from /usr/lib/dracut/dracut.conf.d and
 /etc/dracut.conf.d. Files with the same name in /etc/dracut.conf.d will replace
 files in /usr/lib/dracut/dracut.conf.d.
-The files are then read in alphanumerical order and will overwrite parameters
+The files are then read in alphanumerical order and will override parameters
 set in _/etc/dracut.conf_. Each line specifies an attribute and a value. A '#'
 indicates the beginning of a comment; following characters, up to the end of the
 line are not interpreted.
 
-dracut command line options will overwrite any values set here.
+dracut command line options will override any values set here.
 
 Configuration files must have the extension .conf; other extensions are ignored.
 
@@ -218,7 +218,7 @@ _/etc/dracut.conf_::
     _/etc/dracut.conf.d/_.
 
 _/etc/dracut.conf.d/_::
-    Any _/etc/dracut.conf.d/*.conf_ file can overwrite the values in
+    Any _/etc/dracut.conf.d/*.conf_ file can override the values in
     _/etc/dracut.conf_. The configuration files are read in alphanumerical
     order.
 
index dbdf66e3128a8346f353d49f081d82c6849afe7a..9c3f547567b4476cbc00c5363ff8ed220d83264c 100644 (file)
@@ -168,7 +168,7 @@ inst_hook cmdline 20 "$moddir/parse-insmodpost.sh"
 inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh
 ----
 
-The _pase-instmodpost.sh_ parses the kernel command line for a argument
+The _parse-instmodpost.sh_ parses the kernel command line for a argument
 rd.driver.post, blacklists the module from being autoloaded and installs the
 hook _insmodpost.sh_ in the _initqueue/settled_.
 
index 2d79bbcc1e19ad69f01205767931110918e867c8..a94401f67ff8223d75bcb0cecf9569c1b907adc7 100755 (executable)
--- a/dracut.sh
+++ b/dracut.sh
@@ -371,6 +371,7 @@ rearrange_params()
         --long kernel-image: \
         --long no-hostonly-i18n \
         --long hostonly-i18n \
+        --long no-machineid \
         -- "$@")
 
     if (( $? != 0 )); then
@@ -566,6 +567,8 @@ while :; do
                        uefi_stub_l="$2";               PARMS_TO_STORE+=" '$2'"; shift;;
         --kernel-image)
                        kernel_image_l="$2";            PARMS_TO_STORE+=" '$2'"; shift;;
+        --no-machineid)
+                       machine_id_l="no";;
         --) shift; break;;
 
         *)  # should not even reach this point
@@ -624,20 +627,10 @@ if [[ $kernel ]]; then
     fi
 fi
 
-if ! [[ $outfile ]]; then
-    [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
-
-    if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
-        outfile="/boot/${MACHINE_ID}/$kernel/initrd"
-    else
-        outfile="/boot/initramfs-$kernel.img"
-    fi
-fi
-
-unset LC_MESSAGES
-unset LC_CTYPE
 export LC_ALL=C
 export LANG=C
+unset LC_MESSAGES
+unset LC_CTYPE
 unset LD_LIBRARY_PATH
 unset LD_PRELOAD
 unset GREP_OPTIONS
@@ -751,6 +744,36 @@ stdloglvl=$((stdloglvl + verbosity_mod_l))
 [[ $loginstall_l ]] && loginstall="$loginstall_l"
 [[ $uefi_stub_l ]] && uefi_stub="$uefi_stub_l"
 [[ $kernel_image_l ]] && kernel_image="$kernel_image_l"
+[[ $machine_id_l ]] && machine_id="$machine_id_l"
+
+if ! [[ $outfile ]]; then
+    if [[ $machine_id != "no" ]]; then
+        [[ -f /etc/machine-id ]] && read MACHINE_ID < /etc/machine-id
+    fi
+
+    if [[ $uefi == "yes" ]]; then
+        BUILD_ID=$(cat /etc/os-release /usr/lib/os-release \
+                       | while read -r line || [[ $line ]]; do \
+                       [[ $line =~ BUILD_ID\=* ]] && eval "$line" && echo "$BUILD_ID" && break; \
+                   done)
+        if [[ -d /efi ]] && mountpoint -q /efi; then
+            efidir=/efi
+        else
+            efidir=/boot/EFI
+            if [[ -d /boot/efi/EFI ]] && mountpoint -q /boot/efi; then
+                efidir=/boot/efi/EFI
+            fi
+        fi
+        mkdir -p "$efidir/Linux"
+        outfile="$efidir/Linux/linux-$kernel${MACHINE_ID:+-${MACHINE_ID}}${BUILD_ID:+-${BUILD_ID}}.efi"
+    else
+        if [[ $MACHINE_ID ]] && ( [[ -d /boot/${MACHINE_ID} ]] || [[ -L /boot/${MACHINE_ID} ]] ); then
+            outfile="/boot/${MACHINE_ID}/$kernel/initrd"
+        else
+            outfile="/boot/initramfs-$kernel.img"
+        fi
+    fi
+fi
 
 # eliminate IFS hackery when messing with fw_dir
 export DRACUT_FIRMWARE_PATH=${fw_dir// /:}
@@ -820,7 +843,11 @@ esac
 
 [[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1
 
-readonly TMPDIR="$tmpdir"
+readonly TMPDIR="$(realpath -e "$tmpdir")"
+[ -d "$TMPDIR" ] || {
+    printf "%s\n" "dracut: Invalid tmpdir '$tmpdir'." >&2
+    exit 1
+}
 readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
 [ -d "$DRACUT_TMPDIR" ] || {
     printf "%s\n" "dracut: mktemp -p '$TMPDIR/' -d -t dracut.XXXXXX failed." >&2
@@ -1361,10 +1388,12 @@ if [[ $kernel_only != yes ]]; then
     for _d in $hookdirs; do
         mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
     done
-    if [[ "$UID" = "0" ]]; then
+    if [[ "$EUID" = "0" ]]; then
         [ -c ${initdir}/dev/null ] || mknod ${initdir}/dev/null c 1 3
         [ -c ${initdir}/dev/kmsg ] || mknod ${initdir}/dev/kmsg c 1 11
         [ -c ${initdir}/dev/console ] || mknod ${initdir}/dev/console c 5 1
+        [ -c ${initdir}/dev/random ] || mknod ${initdir}/dev/random c 1 8
+        [ -c ${initdir}/dev/urandom ] || mknod ${initdir}/dev/urandom c 1 9
     fi
 fi
 
@@ -1530,9 +1559,9 @@ for ((i=0; i < ${#include_src[@]}; i++)); do
                         mkdir -m 0755 -p "$object_destdir"
                         chmod --reference="$objectname" "$object_destdir"
                     fi
-                    cp --reflink=auto --sparse=auto -fa -t "$object_destdir" "$objectname"/*
+                    $DRACUT_CP -t "$object_destdir" "$objectname"/*
                 else
-                    cp --reflink=auto --sparse=auto -fa -t "$destdir" "$objectname"
+                    $DRACUT_CP -t "$destdir" "$objectname"
                 fi
             done
         fi
@@ -1545,7 +1574,7 @@ if [[ $kernel_only != yes ]]; then
         [[ -f $f ]] && inst_simple "$f"
     done
     if ! ldconfig -r "$initdir"; then
-        if [[ $UID = 0 ]]; then
+        if [[ $EUID = 0 ]]; then
             derror "ldconfig exited ungracefully"
         else
             derror "ldconfig might need uid=0 (root) for chroot()"
@@ -1554,7 +1583,7 @@ if [[ $kernel_only != yes ]]; then
 fi
 
 PRELINK_BIN="$(command -v prelink)"
-if [[ $UID = 0 ]] && [[ $PRELINK_BIN ]]; then
+if [[ $EUID = 0 ]] && [[ $PRELINK_BIN ]]; then
     if [[ $DRACUT_FIPS_MODE ]]; then
         dinfo "*** Installing prelink files ***"
         inst_multiple -o prelink /etc/prelink.conf /etc/prelink.conf.d/*.conf /etc/prelink.cache
@@ -1644,7 +1673,7 @@ if [[ $acpi_override = yes ]] && [[ -d $acpi_table_dir ]]; then
     mkdir -p $_dest_dir
     for table in $acpi_table_dir/*.aml; do
         dinfo "   Adding ACPI table: $table"
-        cp -a $table $_dest_dir
+        $DRACUT_CP $table $_dest_dir
         create_early_cpio="yes"
     done
 fi
@@ -1688,7 +1717,7 @@ if [[ $DRACUT_REPRODUCIBLE ]]; then
     fi
 fi
 
-[[ "$UID" != 0 ]] && cpio_owner_root="-R 0:0"
+[[ "$EUID" != 0 ]] && cpio_owner_root="-R 0:0"
 
 if [[ $create_early_cpio = yes ]]; then
     echo 1 > "$early_cpio_dir/d/early_cpio"
index 0515006e3c0b90ccbd9642a5d340b5c08f2ecff3..d4566cfa303e92b37e82cb24eaffe8b638372d16 100644 (file)
@@ -115,6 +115,7 @@ Requires: kpartx
 %if 0%{?fedora} || 0%{?rhel} > 6
 Requires: util-linux >= 2.21
 Requires: systemd >= 219
+Requires: systemd-udev >= 219
 Requires: procps-ng
 Conflicts: grubby < 8.23
 Conflicts: initscripts < 8.63-1
index fe30bbac0c5c76d0f0a197b9164217c54e7a61fa..32faee6f8ea08cc24259267895f09d2efe6e7390 100644 (file)
@@ -59,6 +59,7 @@ static bool arg_resolvedeps = false;
 static bool arg_hostonly = false;
 static char *destrootdir = NULL;
 static char *kerneldir = NULL;
+static size_t kerneldirlen = 0;
 static char **firmwaredirs = NULL;
 static char **pathdirs;
 static char *logdir = NULL;
@@ -274,8 +275,13 @@ static int cp(const char *src, const char *dst)
                 if (ret == 0) {
                         struct timeval tv[2];
                         if (fchown(dest_desc, sb.st_uid, sb.st_gid) != 0)
-                                if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0)
-                                    log_error("Failed to chown %s: %m", dst);
+                                if(fchown(dest_desc, (uid_t) - 1, sb.st_gid) != 0) {
+                                        if (geteuid() == 0)
+                                                log_error("Failed to chown %s: %m", dst);
+                                        else
+                                                log_info("Failed to chown %s: %m", dst);
+                                }
+
                         tv[0].tv_sec = sb.st_atime;
                         tv[0].tv_usec = 0;
                         tv[1].tv_sec = sb.st_mtime;
@@ -294,16 +300,24 @@ static int cp(const char *src, const char *dst)
  normal_copy:
         pid = fork();
         if (pid == 0) {
-                execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src, dst,
-                       NULL);
+                if (geteuid() == 0)
+                        execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,xattr,timestamps", "-fL", src, dst,
+                               NULL);
+                else
+                        execlp("cp", "cp", "--reflink=auto", "--sparse=auto", "--preserve=mode,timestamps", "-fL", src, dst,
+                               NULL);
                 _exit(EXIT_FAILURE);
         }
 
         while (waitpid(pid, &ret, 0) < 0) {
                 if (errno != EINTR) {
                         ret = -1;
-                        log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s", src,
-                                  dst);
+                        if (geteuid() == 0)
+                                log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,xattr,timestamps -fL %s %s", src,
+                                          dst);
+                        else
+                                log_error("Failed: cp --reflink=auto --sparse=auto --preserve=mode,timestamps -fL %s %s", src,
+                                          dst);
                         break;
                 }
         }
@@ -910,6 +924,13 @@ static int parse_argv(int argc, char *argv[])
                         break;
                 case ARG_KERNELDIR:
                         kerneldir = strdup(optarg);
+                        if ((strncmp("/lib/modules/", kerneldir, 13) != 0)
+                            && (strncmp("/usr/lib/modules/", kerneldir, 17) != 0)) {
+                                char *p;
+                                p = strstr(kerneldir, "/lib/modules/");
+                                if (p != NULL)
+                                        kerneldirlen = p - kerneldir;
+                        }
                         break;
                 case ARG_FIRMWAREDIRS:
                         firmwaredirs = strv_split(optarg, ":");
@@ -1241,8 +1262,9 @@ static int install_module(struct kmod_module *mod)
                 return 1;
         }
 
-        log_debug("dracut_install '%s'", path);
-        ret = dracut_install(path, path, false, false, true);
+        log_debug("dracut_install '%s' '%s'", path, &path[kerneldirlen]);
+
+        ret = dracut_install(path, &path[kerneldirlen], false, false, true);
         if (ret == 0) {
                 log_debug("dracut_install '%s' OK", kmod_module_get_name(mod));
         } else if (!arg_optional) {
@@ -1256,17 +1278,18 @@ static int install_module(struct kmod_module *mod)
         kmod_list_foreach(itr, modlist) {
                 mod = kmod_module_get_module(itr);
                 path = kmod_module_get_path(mod);
+
                 name = kmod_module_get_name(mod);
                 if (arg_mod_filter_noname && (regexec(&mod_filter_noname, name, 0, NULL, 0) == 0)) {
                         kmod_module_unref(mod);
                         continue;
                 }
-                ret = dracut_install(path, path, false, false, true);
+                ret = dracut_install(path, &path[kerneldirlen], false, false, true);
                 if (ret == 0) {
-                        log_debug("dracut_install '%s' OK", kmod_module_get_name(mod));
+                        log_debug("dracut_install '%s' '%s' OK", path, &path[kerneldirlen]);
                         install_firmware(mod);
                 } else {
-                        log_error("dracut_install '%s' ERROR", kmod_module_get_name(mod));
+                        log_error("dracut_install '%s' '%s' ERROR", path, &path[kerneldirlen]);
                 }
                 kmod_module_unref(mod);
         }
@@ -1287,7 +1310,6 @@ static int install_modules(int argc, char **argv)
         int i;
 
         ctx = kmod_new(kerneldir, NULL);
-
         if (arg_hostonly) {
                 err = kmod_module_new_from_loaded(ctx, &loaded_list);
                 if (err < 0) {
index 65177a96a82c3a1a962fd5e13ccd1739711db65c..263f981bc9e443ae39056dc5e56398b680fa3a5b 100755 (executable)
@@ -46,5 +46,16 @@ install() {
 
     inst_multiple -o prelink
     inst_simple /etc/system-fips
+    [ -c ${initdir}/dev/random ] || mknod ${initdir}/dev/random c 1 8 \
+        || {
+            dfatal "Cannot create /dev/random"
+            dfatal "To create an initramfs with fips support, dracut has to run as root"
+            return 1
+        }
+    [ -c ${initdir}/dev/urandom ] || mknod ${initdir}/dev/urandom c 1 9 \
+        || {
+            dfatal "Cannot create /dev/random"
+            dfatal "To create an initramfs with fips support, dracut has to run as root"
+            return 1
+        }
 }
-
index 9618aa7752d0835e6f3af5d1de34732ea7d80f0a..595b2dc31a34e8149bf96a47a8566da695ba3bb1 100755 (executable)
@@ -114,7 +114,7 @@ install() {
 
         for _src in $(eval echo ${kbddir}/{${KBDSUBDIRS}}); do
             inst_dir "$_src"
-            cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_src}" "$_src"/*
+            $DRACUT_CP -L -t "${initdir}/${_src}" "$_src"/*
         done
 
         # remove unnecessary files
index f49cdb88bb8faf0aa905dc9a04c8366a1f381089..3d9af99f24502e7194b8f257ee332a2794bcf5b6 100755 (executable)
@@ -48,7 +48,16 @@ setup_interface() {
             # point-to-point connection => set explicit route to gateway
             echo ip route add $gw dev $netif > /tmp/net.$netif.gw
         fi
-        echo ip route replace default via $gw dev $netif >> /tmp/net.$netif.gw
+
+        echo "$gw" | {
+            IFS=' ' read -r main_gw other_gw
+            echo ip route replace default via $main_gw dev $netif >> /tmp/net.$netif.gw
+            if [ -n "$other_gw" ] ; then
+                for g in $other_gw; do
+                    echo ip route add default via $g dev $netif >> /tmp/net.$netif.gw
+                done
+            fi
+        }
     fi
 
     if getargbool 1 rd.peerdns; then
index 80511562b1362690a3963050cfbc4aa97aba011d..655ce93e5dcee334229c2d711651f2c09966d045 100755 (executable)
@@ -144,12 +144,15 @@ get_vid() {
 
 # check, if we need VLAN's for this interface
 if [ -z "$DO_VLAN_PHY" ] && [ -e /tmp/vlan.${netif}.phy ]; then
+    unset DO_VLAN
     NO_AUTO_DHCP=yes DO_VLAN_PHY=yes ifup "$netif"
     modprobe -b -q 8021q
 
     for i in /tmp/vlan.*.${netif}; do
         [ -e "$i" ] || continue
-        read vlanname < "$i"
+        unset vlanname
+        unset phydevice
+        . "$i"
         if [ -n "$vlanname" ]; then
             linkup "$phydevice"
             ip link add dev "$vlanname" link "$phydevice" type vlan id "$(get_vid $vlanname)"
@@ -159,6 +162,16 @@ if [ -z "$DO_VLAN_PHY" ] && [ -e /tmp/vlan.${netif}.phy ]; then
     exit 0
 fi
 
+# Check, if interface is VLAN interface
+if ! [ -e /tmp/vlan.${netif}.phy ]; then
+    for i in /tmp/vlan.${netif}.*; do
+        [ -e "$i" ] || continue
+        export DO_VLAN=yes
+        break
+    done
+fi
+
+
 # bridge this interface?
 if [ -z "$NO_BRIDGE_MASTER" ]; then
     for i in /tmp/bridge.*.info; do
@@ -319,6 +332,7 @@ if [ -n "$manualup" ]; then
     rm -f /tmp/net.${netif}.did-setup
 else
     [ -e /tmp/net.${netif}.did-setup ] && exit 0
+    [ -z "$DO_VLAN" ] && \
     [ -e /sys/class/net/$netif/address ] && \
         [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && exit 0
 fi
@@ -391,7 +405,7 @@ for p in $(getargs ip=); do
     if [ $ret -eq 0 ]; then
         > /tmp/net.${netif}.up
 
-        if [ -e /sys/class/net/${netif}/address ]; then
+        if  [ -z "$DO_VLAN" ] && [ -e /sys/class/net/${netif}/address ]; then
             > /tmp/net.$(cat /sys/class/net/${netif}/address).up
         fi
 
index 5df50bdd19db7379a1021030a6db1fa80e8df5c7..f0cfa57b9f2f3c18298ab5413b7486c126b6b40c 100755 (executable)
@@ -17,7 +17,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
         unset bridgeslaves
         unset bridgename
         . "$i"
-        IFACES="$IFACES ${bridgeslaves%% *}"
+        RAW_IFACES="$RAW_IFACES $bridgeslaves"
         MASTER_IFACES="$MASTER_IFACES $bridgename"
     done
 
@@ -28,29 +28,35 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
         unset bondname
         . "$i"
         # It is enough to fire up only one
-        IFACES="$IFACES ${bondslaves%% *}"
+        RAW_IFACES="$RAW_IFACES $bondslaves"
         MASTER_IFACES="$MASTER_IFACES ${bondname}"
     done
 
-    if [ -e /tmp/team.info ]; then
-        . /tmp/team.info
-        IFACES="$IFACES ${teamslaves}"
+    for i in /tmp/team.*.info; do
+        [ -e "$i" ] || continue
+        unset teamslaves
+        unset teammaster
+        . "$i"
+        RAW_IFACES="$RAW_IFACES ${teamslaves}"
         MASTER_IFACES="$MASTER_IFACES ${teammaster}"
-    fi
+    done
 
-    for j in /tmp/vlan.*.phy; do
-        [ -e "$j" ] || continue
+    for i in /tmp/vlan.*.phy; do
+        [ -e "$i" ] || continue
         unset phydevice
-        . "$j"
-        for i in /tmp/vlan.*.${phydevice}; do
-            [ -e "$i" ] || continue
+        . "$i"
+        RAW_IFACES="$RAW_IFACES $phydevice"
+        for j in /tmp/vlan.*.${phydevice}; do
+            [ -e "$j" ] || continue
             unset vlanname
-            . "$i"
-            IFACES="$IFACES $phydevice"
+            . "$j"
             MASTER_IFACES="$MASTER_IFACES ${vlanname}"
         done
     done
 
+    MASTER_IFACES="$(trim "$MASTER_IFACES")"
+    RAW_IFACES="$(trim "$RAW_IFACES")"
+
     if [ -z "$IFACES" ]; then
         [ -e /tmp/net.ifaces ] && read IFACES < /tmp/net.ifaces
     fi
@@ -64,10 +70,10 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
     runcmd="RUN+=\"/sbin/initqueue --name ifup-\$env{INTERFACE} --unique --onetime $ifup\""
 
     # We have some specific interfaces to handle
-    if [ -n "$IFACES" ]; then
+    if [ -n "${RAW_IFACES}${IFACES}" ]; then
         echo 'SUBSYSTEM!="net", GOTO="net_end"'
         echo 'ACTION!="add|change|move", GOTO="net_end"'
-        for iface in $IFACES; do
+        for iface in $IFACES $RAW_IFACES; do
             case "$iface" in
                 ??:??:??:??:??:??)  # MAC address
                     cond="ATTR{address}==\"$iface\""
@@ -88,13 +94,7 @@ command -v fix_bootif >/dev/null || . /lib/net-lib.sh
         done
         echo 'LABEL="net_end"'
 
-        if [ -n "$MASTER_IFACES" ]; then
-            wait_ifaces=$MASTER_IFACES
-        else
-            wait_ifaces=$IFACES
-        fi
-
-        for iface in $wait_ifaces; do
+        for iface in $IFACES; do
             if [ "$bootdev" = "$iface" ] || [ "$NEEDNET" = "1" ]; then
                 echo "[ -f /tmp/net.${iface}.did-setup ]" >$hookdir/initqueue/finished/wait-$iface.sh
             fi
index 69d96aa4344f02a33e4d8d8de382a6e253402392..d52682827758fd933c9fc080a8b928d4104725f4 100755 (executable)
@@ -101,7 +101,8 @@ ifdown() {
     ip addr flush dev $netif
     echo "#empty" > /etc/resolv.conf
     rm -f -- /tmp/net.$netif.did-setup
-    [ -e /sys/class/net/$netif/address ] && \
+    [ -z "$DO_VLAN" ] && \
+       [ -e /sys/class/net/$netif/address ] && \
         rm -f -- /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
     # TODO: send "offline" uevent?
 }
@@ -110,7 +111,8 @@ setup_net() {
     local netif="$1" f="" gw_ip="" netroot_ip="" iface="" IFACES=""
     local _p
     [ -e /tmp/net.$netif.did-setup ] && return
-    [ -e /sys/class/net/$netif/address ] && \
+    [ -z "$DO_VLAN" ] && \
+       [ -e /sys/class/net/$netif/address ] && \
         [ -e /tmp/net.$(cat /sys/class/net/$netif/address).did-setup ] && return
     [ -e "/tmp/net.ifaces" ] && read IFACES < /tmp/net.ifaces
     [ -z "$IFACES" ] && IFACES="$netif"
@@ -178,7 +180,8 @@ setup_net() {
     unset layer2
 
     > /tmp/net.$netif.did-setup
-    [ -e /sys/class/net/$netif/address ] && \
+    [ -z "$DO_VLAN" ] && \
+       [ -e /sys/class/net/$netif/address ] && \
         > /tmp/net.$(cat /sys/class/net/$netif/address).did-setup
 }
 
index b2a9c1c2e7f7cc523eebf056616efd3185e54f6c..afc890a5980f5e893a631a95ac0f79ddf6605ac9 100755 (executable)
@@ -4,14 +4,6 @@
 #      vlan=<vlanname>:<phydevice>
 #
 
-# return if vlan already parsed
-[ -n "$vlanname" ] && return
-
-# Check if vlan parameter is valid
-if getarg vlan= >/dev/null ; then
-    :
-fi
-
 parsevlan() {
     local v=${1}:
     set --
@@ -27,16 +19,16 @@ parsevlan() {
     esac
 }
 
-unset vlanname phydevice
-
-if getarg vlan >/dev/null; then
-    # Read vlan= parameters if they exist
-    vlan="$(getarg vlan=)"
+for vlan in $(getargs vlan=); do
+    unset vlanname
+    unset phydevice
     if [ ! "$vlan" = "vlan" ]; then
-        parsevlan "$(getarg vlan=)"
+        parsevlan "$vlan"
     fi
 
-    echo "$phydevice" > /tmp/vlan.${phydevice}.phy
-    echo "$vlanname" > /tmp/vlan.${vlanname}.${phydevice}
-    return
-fi
+    echo "phydevice=\"$phydevice\"" > /tmp/vlan.${phydevice}.phy
+    {
+        echo "vlanname=\"$vlanname\""
+        echo "phydevice=\"$phydevice\""
+    } > /tmp/vlan.${vlanname}.${phydevice}
+done
index c3774ae9b766a06f7a78c79e515d76d03c2289bd..5b0c50dd02d3e5ca8ba618cbd92182427e2e6fc2 100755 (executable)
@@ -132,6 +132,8 @@ for netup in /tmp/net.*.did-setup ; do
     unset slave
     unset ethname
     unset vlan
+    unset vlanname
+    unset phydevice
 
     [ -e /tmp/bond.${netif}.info ] && . /tmp/bond.${netif}.info
     [ -e /tmp/bridge.${netif}.info ] && . /tmp/bridge.${netif}.info
@@ -154,7 +156,7 @@ for netup in /tmp/net.*.did-setup ; do
     {
         echo "# Generated by dracut initrd"
         echo "NAME=\"$netif\""
-        interface_bind "$netif" "$macaddr"
+        [ -z "$vlan" ] && interface_bind "$netif" "$macaddr"
         echo "ONBOOT=yes"
         echo "NETBOOT=yes"
         echo "UUID=\"$uuid\""
@@ -208,7 +210,7 @@ for netup in /tmp/net.*.did-setup ; do
     if [ -n "$vlan" ] ; then
         {
             echo "TYPE=Vlan"
-            echo "NAME=\"$netif\""
+            echo "DEVICE=\"$netif\""
             echo "VLAN=yes"
             echo "PHYSDEV=\"$phydevice\""
         } >> /tmp/ifcfg/ifcfg-$netif
index 6c377efd6a9f04a48ec2d2470b7b5b9b2004a7d6..814ab7afaafa3d60ca0ff1f23360262bff71f870 100755 (executable)
@@ -4,7 +4,7 @@
 check() {
     local _rootdev
     # if cryptsetup is not installed, then we cannot support encrypted devices.
-    require_binaries cryptsetup || return 1
+    require_any_binary $systemdutildir/systemd-cryptsetup cryptsetup || return 1
 
     [[ $hostonly ]] || [[ $mount_needs ]] && {
         for fs in "${host_fs_types[@]}"; do
@@ -57,12 +57,12 @@ install() {
         [[ $_cryptconf ]] && printf "%s\n" "$_cryptconf" >> "${initdir}/etc/cmdline.d/90crypt.conf"
     fi
 
-    inst_multiple cryptsetup rmdir readlink umount
-    inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
-    inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
-    inst_hook cmdline 10 "$moddir/parse-keydev.sh"
     inst_hook cmdline 30 "$moddir/parse-crypt.sh"
     if ! dracut_module_included "systemd"; then
+        inst_multiple cryptsetup rmdir readlink umount
+        inst_script "$moddir"/cryptroot-ask.sh /sbin/cryptroot-ask
+        inst_script "$moddir"/probe-keydev.sh /sbin/probe-keydev
+        inst_hook cmdline 10 "$moddir/parse-keydev.sh"
         inst_hook cleanup 30 "$moddir/crypt-cleanup.sh"
     fi
 
index 11fbab99e88a156597563bcb901795ccf6eb0f79..16ed3a74677a3cd6ec016399fbe09000feaa21bc 100755 (executable)
@@ -28,7 +28,7 @@ installkernel() {
         =drivers/net/phy \
         =drivers/net/team \
         =drivers/net/ethernet \
-        ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net
+        ecb arc4 bridge stp llc ipv6 bonding 8021q af_packet virtio_net xennet
     hostonly="" instmods iscsi_ibft crc32c iscsi_boot_sysfs
 }
 
index 38cbc5e4c5db4c0e2eb22fb5eda8415b1f32688a..379cc29647e48063aa57f9919c1bebf8f32570a9 100755 (executable)
@@ -190,6 +190,7 @@ handle_netroot()
             if [ "$status" != "activating" ] && ! systemctl is-failed "$netroot_enc" >/dev/null 2>&1; then
                 systemd-run --no-block --service-type=oneshot --remain-after-exit --quiet \
                             --description="Login iSCSI Target $iscsi_target_name" \
+                            -p 'DefaultDependencies=no' \
                             --unit="$netroot_enc" -- \
                             $(command -v iscsistart) \
                             -i "$iscsi_initiator" -t "$iscsi_target_name"        \
index 0f87761f9fa30502e02c8ea20cef8caf80241876..307734407be8aa3c1947ed56bd78bbfa78de2be5 100755 (executable)
@@ -70,7 +70,7 @@ install() {
     local _i
     local _nsslibs
     inst_multiple -o portmap rpcbind rpc.statd mount.nfs \
-        mount.nfs4 umount rpc.idmapd sed /etc/netconfig
+        mount.nfs4 umount rpc.idmapd sed /etc/netconfig chmod
     inst_multiple /etc/services /etc/nsswitch.conf /etc/rpc /etc/protocols /etc/idmapd.conf
 
     if [[ $hostonly_cmdline == "yes" ]]; then
@@ -100,7 +100,7 @@ install() {
     inst "$moddir/nfsroot.sh" "/sbin/nfsroot"
     inst "$moddir/nfs-lib.sh" "/lib/nfs-lib.sh"
     mkdir -m 0755 -p "$initdir/var/lib/nfs/rpc_pipefs"
-    mkdir -m 0755 -p "$initdir/var/lib/rpcbind"
+    mkdir -m 0770 -p "$initdir/var/lib/rpcbind"
     mkdir -m 0755 -p "$initdir/var/lib/nfs/statd/sm"
 
     # Rather than copy the passwd file in, just set a user for rpcbind
@@ -112,7 +112,6 @@ install() {
     # file
     chmod 770 "$initdir/var/lib/rpcbind"
     grep -q '^rpc:' /etc/passwd \
-        && grep -q '^rpc:' /etc/group \
-        && chown rpc:rpc "$initdir/var/lib/rpcbind"
+        && grep -q '^rpc:' /etc/group
     dracut_need_initqueue
 }
index 54f73d8c2084c2400c25b64b29ebc7fd1a3cbb09..f715767bb31aeb57c92391262217d374e0bb3b55 100755 (executable)
@@ -117,3 +117,7 @@ rootok=1
 root="$fstype"
 
 echo '[ -e $NEWROOT/proc ]' > $hookdir/initqueue/finished/nfsroot.sh
+
+mkdir -p /var/lib/rpcbind
+chown rpc:rpc /var/lib/rpcbind
+chmod 770 /var/lib/rpcbind
index 0a0e80cd9887a8dc9f96667d711031b948cac8b7..2a7e0ee374dff3af0b01bf53d07fa31985240485 100755 (executable)
@@ -45,9 +45,16 @@ inst_sshenv()
         inst_simple /etc/ssh/ssh_config
         sed -i -e 's/\(^[[:space:]]*\)ProxyCommand/\1# ProxyCommand/' ${initdir}/etc/ssh/ssh_config
         while read key val || [ -n "$key" ]; do
-            [[ $key != "GlobalKnownHostsFile" ]] && continue
-            inst_simple "$val"
-            break
+            if [[ $key == "GlobalKnownHostsFile" ]]; then
+                inst_simple "$val"
+            # Copy customized UserKnowHostsFile
+            elif [[ $key == "UserKnownHostsFile" ]]; then
+                # Make sure that ~/foo will be copied as /root/foo in kdump's initramfs
+                if str_starts "$val" "~/"; then
+                    val="/root/${val#"~/"}"
+                fi
+                inst_simple "$val"
+            fi
         done < /etc/ssh/ssh_config
     fi
 
index ebe7a1669bb4fa7a14b0fd7bcd10032bcbe02c9a..1b572fab7808457d9d097c357ea0be73317b9420 100755 (executable)
@@ -11,7 +11,7 @@ install() {
     if [ -d ${_terminfodir} ]; then
         for i in "l/linux" "v/vt100" "v/vt102" "v/vt220"; do
             inst_dir "$_terminfodir/${i%/*}"
-            cp --reflink=auto --sparse=auto -prfL -t "${initdir}/${_terminfodir}/${i%/*}" "$_terminfodir/$i"
+            $DRACUT_CP -L -t "${initdir}/${_terminfodir}/${i%/*}" "$_terminfodir/$i"
         done
     fi
 }
index 6c6ee02632665aaa9f16ff69d14260ccbcb237ce..bff9435a954c02db8e510f3dd77abea89bb727d8 100755 (executable)
@@ -42,7 +42,7 @@ export root
 export rflags
 export fstype
 
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
 # run scriptlets to parse the command line
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
 source_hook cmdline
index ae5112861f1d2f23f6981db5b3c43bb6f035aa0a..a3b9d2910f2213645f5da81b030ee3ad23670b46 100755 (executable)
@@ -8,7 +8,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
 source_conf /etc/conf.d
 
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
 # pre pivot scripts are sourced just before we doing cleanup and switch over
 # to the new root.
 getarg 'rd.break=pre-mount' 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
index cc70e3c3498a20e2702b05b692abe3ac8946ae40..dc9a2504de664f6c0ada7794b303f76dd0186064 100755 (executable)
@@ -8,12 +8,13 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
 source_conf /etc/conf.d
 
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
 # pre pivot scripts are sourced just before we doing cleanup and switch over
 # to the new root.
 getarg 'rd.break=pre-pivot' 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
 source_hook pre-pivot
 
+cleanup_trace_mem
 # pre pivot cleanup scripts are sourced just before we switch over to the new root.
 getarg 'rd.break=cleanup' 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
 source_hook cleanup
index ac1ec363e75a6d3ab4263a7b1e2bc3f4aeb3384e..7cd821ed7d936c632b27a7740c69ddbc3bf9f58a 100755 (executable)
@@ -8,7 +8,7 @@ type getarg >/dev/null 2>&1 || . /lib/dracut-lib.sh
 
 source_conf /etc/conf.d
 
-make_trace_mem "hook pre-trigger" "1:shortmem" "2+:mem" "3+:slab"
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
 
 source_hook pre-trigger
 
index 060b3fed534829bbd5e21ac8ca852a06e49c6a2c..dc10836da7931038d75b17674d032279ba0f2b08 100755 (executable)
@@ -51,6 +51,13 @@ str_ends() {
     [ "${1%*"$2"}" != "$1" ]
 }
 
+trim() {
+    local var="$*"
+    var="${var#"${var%%[![:space:]]*}"}"   # remove leading whitespace characters
+    var="${var%"${var##*[![:space:]]}"}"   # remove trailing whitespace characters
+    printf "%s" "$var"
+}
+
 if [ -z "$DRACUT_SYSTEMD" ]; then
 
     warn() {
@@ -1206,12 +1213,20 @@ are_lists_eq() {
 
 setmemdebug() {
     if [ -z "$DEBUG_MEM_LEVEL" ]; then
-        export DEBUG_MEM_LEVEL=$(getargnum 0 0 3 rd.memdebug)
+        export DEBUG_MEM_LEVEL=$(getargnum 0 0 4 rd.memdebug)
     fi
 }
 
 setmemdebug
 
+cleanup_trace_mem()
+{
+    # tracekomem based on kernel trace needs cleanup after use.
+    if [ "$DEBUG_MEM_LEVEL" -eq 4 ]; then
+        tracekomem --cleanup
+    fi
+}
+
 # parameters: msg [trace_level:trace]...
 make_trace_mem()
 {
@@ -1296,6 +1311,9 @@ show_memstats()
         iomem)
             cat /proc/iomem
             ;;
+        komem)
+            tracekomem
+            ;;
     esac
 }
 
index a5633936aa203860e2d60964ac837f95a1a2fe3e..e4f7cff1622221617646f928fa695775deab9fce 100755 (executable)
@@ -131,7 +131,7 @@ if ! getargbool 1 'rd.hostonly'; then
 fi
 
 # run scriptlets to parse the command line
-make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab'
+make_trace_mem "hook cmdline" '1+:mem' '1+:iomem' '3+:slab' '4+:komem'
 getarg 'rd.break=cmdline' -d 'rdbreak=cmdline' && emergency_shell -n cmdline "Break before cmdline"
 source_hook cmdline
 
@@ -160,7 +160,7 @@ fi
 
 udevproperty "hookdir=$hookdir"
 
-make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-trigger" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
 getarg 'rd.break=pre-trigger' -d 'rdbreak=pre-trigger' && emergency_shell -n pre-trigger "Break before pre-trigger"
 source_hook pre-trigger
 
@@ -230,7 +230,7 @@ unset RDRETRY
 
 # pre-mount happens before we try to mount the root filesystem,
 # and happens once.
-make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-mount" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
 getarg 'rd.break=pre-mount' -d 'rdbreak=pre-mount' && emergency_shell -n pre-mount "Break pre-mount"
 source_hook pre-mount
 
@@ -266,11 +266,12 @@ done
 
 # pre pivot scripts are sourced just before we doing cleanup and switch over
 # to the new root.
-make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab'
+make_trace_mem "hook pre-pivot" '1:shortmem' '2+:mem' '3+:slab' '4+:komem'
 getarg 'rd.break=pre-pivot' -d 'rdbreak=pre-pivot' && emergency_shell -n pre-pivot "Break pre-pivot"
 source_hook pre-pivot
 
 make_trace_mem "hook cleanup" '1:shortmem' '2+:mem' '3+:slab'
+cleanup_trace_mem
 # pre pivot cleanup scripts are sourced just before we switch over to the new root.
 getarg 'rd.break=cleanup' -d 'rdbreak=cleanup' && emergency_shell -n cleanup "Break cleanup"
 source_hook cleanup
diff --git a/modules.d/99base/memtrace-ko.sh b/modules.d/99base/memtrace-ko.sh
new file mode 100755 (executable)
index 0000000..ee035e1
--- /dev/null
@@ -0,0 +1,191 @@
+#!/bin/sh
+
+# Try to find out kernel modules with large total memory allocation during loading.
+# For large slab allocation, it will fall into buddy, also not trace "mm_page_free"
+# considering large free is quite rare for module_init, thus saving tons of events
+# to avoid trace data overwritten.
+#
+# Therefore, tracing "mm_page_alloc"alone should be enough for the purpose.
+
+# "sys/kernel/tracing" has the priority if exists.
+get_trace_base() {
+    # trace access through debugfs would be obsolete if "/sys/kernel/tracing" is available.
+    if [ -d "/sys/kernel/tracing" ]; then
+        echo "/sys/kernel"
+    else
+        echo "/sys/kernel/debug"
+    fi
+}
+
+# We want to enable these trace events.
+get_want_events() {
+    echo "module:module_put module:module_load kmem:mm_page_alloc"
+}
+
+get_event_filter() {
+    echo "comm == systemd-udevd || comm == modprobe || comm == insmod"
+}
+
+is_trace_ready() {
+    local trace_base want_events current_events
+
+    trace_base=$(get_trace_base)
+    ! [ -f "$trace_base/tracing/trace" ] && return 1
+
+    [ "$(cat $trace_base/tracing/tracing_on)" -eq 0 ] && return 1
+
+    # Also check if trace events were properly setup.
+    want_events=$(get_want_events)
+    current_events=$(echo $(cat $trace_base/tracing/set_event))
+    [ "$current_events" != "$want_events" ] && return 1
+
+    return 0
+}
+
+prepare_trace() {
+    local trace_base
+
+    trace_base=$(get_trace_base)
+    # old debugfs interface case.
+    if ! [ -d "$trace_base/tracing" ]; then
+        mount none -t debugfs $trace_base
+    # new tracefs interface case.
+    elif ! [ -f "$trace_base/tracing/trace" ]; then
+        mount none -t tracefs "$trace_base/tracing"
+    fi
+
+    if ! [ -f "$trace_base/tracing/trace" ]; then
+        echo "WARN: Mount trace failed for kernel module memory analyzing."
+        return 1
+    fi
+
+    # Active all the wanted trace events.
+    echo "$(get_want_events)" > $trace_base/tracing/set_event
+
+    # There are three kinds of known applications for module loading:
+    # "systemd-udevd", "modprobe" and "insmod".
+    # Set them as the global events filter.
+    # NOTE: Some kernel may not support this format of filter, anyway
+    #       the operation will fail and it doesn't matter.
+    echo "$(get_event_filter)" > $trace_base/tracing/events/kmem/filter 2>&1
+    echo "$(get_event_filter)" > $trace_base/tracing/events/module/filter 2>&1
+
+    # Set the number of comm-pid if supported.
+    if [ -f "$trace_base/tracing/saved_cmdlines_size" ]; then
+        # Thanks to filters, 4096 is big enough(also well supported).
+        echo 4096 > $trace_base/tracing/saved_cmdlines_size
+    fi
+
+    # Enable and clear trace data for the first time.
+    echo 1 > $trace_base/tracing/tracing_on
+    echo > $trace_base/tracing/trace
+    echo "Prepare trace success."
+    return 0
+}
+
+order_to_pages()
+{
+    local pages=1
+    local order=$1
+
+    while [ "$order" != 0 ]; do
+        order=$((order-1))
+        pages=$(($pages*2))
+       done
+
+    echo $pages
+}
+
+parse_trace_data() {
+    local module_name tmp_eval pages
+
+    cat "$(get_trace_base)/tracing/trace" | while read pid cpu flags ts function args
+    do
+        # Skip comment lines
+        if [ "$pid" = "#" ]; then
+            continue
+        fi
+
+        pid=${pid##*-}
+        function=${function%:}
+        if [ "$function" = "module_load" ]; then
+            # One module is being loaded, save the task pid for tracking.
+            # Remove the trailing after whitespace, there may be the module flags.
+            module_name=${args%% *}
+            # Mark current_module to track the task.
+            eval current_module_$pid="$module_name"
+            tmp_eval=$(eval echo '${module_loaded_'${module_name}'}')
+            if [ -n "$tmp_eval" ]; then
+                echo "WARN: \"$module_name\" was loaded multiple times!"
+            fi
+            eval unset module_loaded_$module_name
+            eval nr_alloc_pages_$module_name=0
+            continue
+        fi
+
+        module_name=$(eval echo '${current_module_'${pid}'}')
+        if [ -z "$module_name" ]; then
+            continue
+        fi
+
+        # Once we get here, the task is being tracked(is loading a module).
+        if [ "$function" = "module_put" ]; then
+            # Mark the module as loaded when the first module_put event happens after module_load.
+            tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
+            echo "$tmp_eval pages consumed by \"$module_name\""
+            eval module_loaded_$module_name=1
+            # Module loading finished, so untrack the task.
+            eval unset current_module_$pid
+            eval unset nr_alloc_pages_$module_name
+            continue
+        fi
+
+        if [ "$function" = "mm_page_alloc" ]; then
+            # Get order first, then convert to actual pages.
+            pages=$(echo $args | sed -e 's/.*order=\([0-9]*\) .*/\1/')
+            pages=$(order_to_pages "$pages")
+            tmp_eval=$(eval echo '${nr_alloc_pages_'${module_name}'}')
+            eval nr_alloc_pages_$module_name="$(($tmp_eval+$pages))"
+        fi
+    done
+}
+
+cleanup_trace() {
+    local trace_base
+
+    if is_trace_ready; then
+        trace_base=$(get_trace_base)
+        echo 0 > $trace_base/tracing/tracing_on
+        echo > $trace_base/tracing/trace
+        echo > $trace_base/tracing/set_event
+        echo 0 > $trace_base/tracing/events/kmem/filter
+        echo 0 > $trace_base/tracing/events/module/filter
+    fi
+}
+
+show_usage() {
+    echo "Find out kernel modules with large memory consumption during loading based on trace."
+    echo "Usage:"
+    echo "1) run it first to setup trace."
+    echo "2) run again to parse the trace data if any."
+    echo "3) run with \"--cleanup\" option to cleanup trace after use."
+}
+
+if [ "$1" = "--help" ]; then
+    show_usage
+    exit 0
+fi
+
+if [ "$1" = "--cleanup" ]; then
+    cleanup_trace
+    exit 0
+fi
+
+if is_trace_ready ; then
+    echo "tracekomem - Rough memory consumption by loading kernel modules (larger value with better accuracy)"
+    parse_trace_data
+else
+    prepare_trace
+fi
+
+exit $?
index b03772ec5c1b39424397c4076b6b6632a7180bbe..a1569b123893bffe3c0dcba22c7a54230644f872 100755 (executable)
@@ -35,6 +35,7 @@ install() {
     inst_script "$moddir/initqueue.sh" "/sbin/initqueue"
     inst_script "$moddir/loginit.sh" "/sbin/loginit"
     inst_script "$moddir/rdsosreport.sh" "/sbin/rdsosreport"
+    inst_script "$moddir/memtrace-ko.sh" "/sbin/tracekomem"
 
     [ -e "${initdir}/lib" ] || mkdir -m 0755 -p ${initdir}/lib
     mkdir -m 0755 -p ${initdir}/lib/dracut
index f71f8540548b51cf3931735f64cbea5c61a32043..eaa944fba4f882fa584180338de1ff7441b5fc64 100644 (file)
@@ -2,13 +2,14 @@
 
 check:
        @[ "$$EUID" == "0" ] || { echo "'check' must be run as root! Please use 'sudo'."; exit 1; }
-       @for i in TEST-[0-9]*; do \
+       @{ ret=0; \
+       for i in TEST-[0-9]*; do \
                [ -d $$i ] || continue ; \
                [ -f $$i/Makefile ] || continue ; \
                if [ -n "$$TESTS" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${TESTS#*$$t*}" != "$$TESTS" ] || continue; fi; \
                if [ -n "$$SKIP" ]; then t=$${i##TEST-}; t=$${t%%-*}; [ "$${SKIP#*$$t*}" != "$$SKIP" ] && continue; fi; \
-               $(MAKE) -C $$i all ; \
-       done
+               $(MAKE) -C $$i all ; ret=$$((ret + $$?)); \
+       done; exit $$ret; }
 
 clean:
        @for i in TEST-[0-9]*; do \
index e74c6735c6601393b514720de6c16c2e7cb40311..c75106d3e493681ca8d7b377762531bda03b91bb 100755 (executable)
@@ -11,11 +11,11 @@ test_run() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/result \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
        -watchdog i6300esb -watchdog-action poweroff \
         -no-reboot \
-       -append "panic=1 root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL" \
+       -append "panic=1 root=LABEL=dracut rw systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.debug console=ttyS0,115200n81 rd.shell=0 $DEBUGFAIL rd.memdebug=4" \
        -initrd $TESTDIR/initramfs.testing || return 1
     grep -F -m 1 -q dracut-root-block-success $TESTDIR/result || return 1
 }
@@ -80,7 +80,7 @@ test_setup() {
 
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-       -m 256M -smp 2 -nographic -net none \
+       -m 256M  -smp 2 -nographic -net none \
        -append "root=/dev/dracut/root rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
        -initrd $TESTDIR/initramfs.makeroot  || return 1
     grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
index 973627872349e9a931a9ecee80239604eb98d101..ee71e3fcf9f54a78010d43cf750f85cafefd8f38 100755 (executable)
@@ -8,7 +8,7 @@ KVERSION="${KVERSION-$(uname -r)}"
 test_run() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=LABEL=dracut rw loglevel=77 systemd.log_level=debug systemd.log_target=console rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug init=/sbin/init rd.shell=0 $DEBUGFAIL" \
@@ -77,7 +77,7 @@ test_setup() {
 
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext3 \
-       -m 256M -smp 2 -nographic -net none \
+       -m 256M  -smp 2 -nographic -net none \
        -append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
        -initrd $TESTDIR/initramfs.makeroot  || return 1
     grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.ext3 || return 1
index c515613dcb7209338edb0418f0b576b56ac38027..6f33f4f52b8c2e46f40e69d55a28939420968364 100755 (executable)
@@ -18,7 +18,7 @@ client_run() {
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
        -drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
        -watchdog i6300esb -watchdog-action poweroff \
         -no-reboot \
@@ -115,7 +115,7 @@ test_setup() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-       -m 256M -smp 2 -nographic -net none \
+       -m 256M  -smp 2 -nographic -net none \
        -append "root=/dev/dracut/root rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
        -initrd $TESTDIR/initramfs.makeroot  || return 1
     grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1
index 3baabb450ae7e783df33335524dfd5146fd9e120..d3c3275adb7074da4a34c657f6323f3deeecc30c 100755 (executable)
@@ -20,7 +20,7 @@ client_run() {
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
        -drive format=raw,index=2,media=disk,file=$TESTDIR/result \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=LABEL=dracut $client_opts rd.retry=3 console=ttyS0,115200n81 selinux=0 $DEBUGOUT rd.shell=0 $DEBUGFAIL" \
@@ -252,7 +252,7 @@ EOF
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.btrfs \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/usr.btrfs \
-       -m 256M -smp 2 -nographic -net none \
+       -m 256M  -smp 2 -nographic -net none \
        -append "root=/dev/fakeroot rw rootfstype=btrfs quiet console=ttyS0,115200n81 selinux=0" \
        -initrd $TESTDIR/initramfs.makeroot  || return 1
     grep -F -m 1 -q dracut-root-block-created $TESTDIR/root.btrfs || return 1
index 5324457d293b88e4c7f28bb8476ed7d630bfd065..b1408ac436d2e858a301ec1ea18004d48a9d0476 100755 (executable)
@@ -10,7 +10,7 @@ test_run() {
     DISKIMAGE=$TESTDIR/TEST-10-RAID-root.img
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=/dev/dracut/root rd.auto rw rd.retry=10 console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
@@ -77,7 +77,7 @@ test_setup() {
     # Invoke KVM and/or QEMU to actually create the target filesystem.
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-       -m 256M -smp 2 -nographic -net none \
+       -m 256M  -smp 2 -nographic -net none \
        -append "root=/dev/cannotreach rw rootfstype=ext2 console=ttyS0,115200n81 selinux=0" \
        -initrd $TESTDIR/initramfs.makeroot  || return 1
     grep -F -m 1 -q dracut-root-block-created $DISKIMAGE || return 1
index cf7d376b8149668130b9f9ef57d07231bc80138a..3a38c1f9ba0e9196c9297adf461ef6dfb2d52b70 100755 (executable)
@@ -9,7 +9,7 @@ KVERSION=${KVERSION-$(uname -r)}
 test_run() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
@@ -72,7 +72,7 @@ test_setup() {
        -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 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
+    $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M  -smp 2 -nographic -net none \
        -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
index 4c313eb5daf76a8cfb3bb5b3b7873f935ad1321a..71ffc6f67bb91a19c91e0abc8ecd88c0e4de6d1c 100755 (executable)
@@ -15,7 +15,7 @@ client_run() {
     cp --sparse=always --reflink=auto $TESTDIR/disk3.img $TESTDIR/disk3.img.new
 
     $testdir/run-qemu \
-       -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -nographic  -smp 2 \
+       -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -nographic   -smp 2 \
        -drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img.new \
        -drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img.new \
        -net none \
@@ -117,7 +117,7 @@ test_setup() {
        -drive format=raw,index=1,media=disk,file=$TESTDIR/disk1.img \
        -drive format=raw,index=2,media=disk,file=$TESTDIR/disk2.img \
        -drive format=raw,index=3,media=disk,file=$TESTDIR/disk3.img \
-       -m 256M -smp 2 -nographic -net none \
+       -m 256M  -smp 2 -nographic -net none \
        -append "root=/dev/fakeroot rw rootfstype=ext2 quiet console=ttyS0,115200n81 selinux=0" \
        -initrd $TESTDIR/initramfs.makeroot  || return 1
 
index b8fd26e260f969abe84b5ce99a0475a79e00bd24..b98a6c46b8c3529afe7f8726940bf20bb0058336 100755 (executable)
@@ -17,7 +17,7 @@ test_run() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=/dev/dracut/root rw rd.auto rd.retry=20 console=ttyS0,115200n81 selinux=0 rd.debug rootwait $LUKSARGS rd.shell=0 $DEBUGFAIL" \
@@ -31,7 +31,7 @@ test_run() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=/dev/dracut/root rw quiet rd.auto rd.retry=20 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL" \
@@ -45,7 +45,7 @@ test_run() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/check-success.img \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=/dev/dracut/root rw quiet rd.auto rd.retry=10 rd.info console=ttyS0,115200n81 selinux=0 rd.debug  $DEBUGFAIL rd.luks.uuid=failme" \
@@ -111,7 +111,7 @@ test_setup() {
        -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 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
+    $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M  -smp 2 -nographic -net none \
        -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
index f9f03b7bf3f6f9938b5a723ea46bcf5853c4acfd..2fac60633c1e5339fde8b72758af26d8fde3cda5 100755 (executable)
@@ -13,7 +13,7 @@ client_run() {
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
        -drive format=raw,index=1,media=disk,file=$TESTDIR/disk1 \
        -drive format=raw,index=2,media=disk,file=$TESTDIR/disk2 \
-       -m 256M -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 $* root=LABEL=root rw debug rd.retry=5 rd.debug console=ttyS0,115200n81 selinux=0 rd.info rd.shell=0 $DEBUGFAIL" \
index adf31b143e1bcdfb538750af2bb55cecd2d52687..cbcf58c35d36843325f3ac8ea9bb73a34e5a4b5e 100755 (executable)
@@ -9,7 +9,7 @@ test_run() {
     DISKIMAGE=$TESTDIR/TEST-15-BTRFSRAID-root.img
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-       -m 256M  -smp 2 -nographic \
+       -m 256M   -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=LABEL=root rw rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.shell=0 $DEBUGFAIL" \
@@ -78,7 +78,7 @@ test_setup() {
     # Invoke KVM and/or QEMU to actually create the target filesystem.
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$DISKIMAGE \
-       -m 256M  -smp 2 -nographic -net none \
+       -m 256M   -smp 2 -nographic -net none \
        -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
        -initrd $TESTDIR/initramfs.makeroot  || return 1
 
index 876d91038019dfc8fcd61d1066cadbb0596a70f9..3bc440b290549560583fda4e61216f31bd099614 100755 (executable)
@@ -19,7 +19,7 @@ test_run() {
         -boot order=d \
         -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
         -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
-        -m 256M -smp 2 \
+        -m 256M  -smp 2 \
         -nographic \
         -net none \
         -no-reboot \
@@ -30,7 +30,7 @@ test_run() {
     # "$testdir"/run-qemu \
     #     -drive format=raw,bps=1000000,index=0,media=disk,file="$TESTDIR"/livecd.iso \
     #     -drive format=raw,index=1,media=disk,file="$TESTDIR"/root.img \
-    #     -m 256M -smp 2 \
+    #     -m 256M  -smp 2 \
     #     -net none \
     #     -append "root=live:CDLABEL=LiveCD live quiet rhgb selinux=0 rd.live.check" \
     #     -initrd "$TESTDIR"/initramfs.testing
index 1ad9ba6b2db8828f9c68132f9dacfefba3d4fc9d..7a8594b062a688ee6b928a6ac6f428ad17037da6 100755 (executable)
@@ -9,7 +9,7 @@ KVERSION=${KVERSION-$(uname -r)}
 test_run() {
     $testdir/run-qemu \
        -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 \
-       -m 256M -smp 2 -nographic \
+       -m 256M  -smp 2 -nographic \
        -net none \
         -no-reboot \
        -append "panic=1 root=/dev/dracut/root rw rd.auto=1 quiet rd.retry=3 rd.info console=ttyS0,115200n81 selinux=0 rd.debug rd.shell=0 $DEBUGFAIL" \
@@ -72,7 +72,7 @@ test_setup() {
        -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 -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M -smp 2 -nographic -net none \
+    $testdir/run-qemu -drive format=raw,index=0,media=disk,file=$TESTDIR/root.ext2 -m 256M  -smp 2 -nographic -net none \
        -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
index 039fb61b8fb75c8eee7831a1ab19ca401d9eb7d6..01c9fd7b4f9fe06f9d619d1bf38f68f14f7a1901 100755 (executable)
@@ -14,7 +14,7 @@ run_server() {
     fsck -a $TESTDIR/server.ext3 || return 1
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext3 \
-        -m 256M -smp 2 \
+        -m 256M  -smp 2 \
         -display none \
         -net socket,listen=127.0.0.1:12320 \
         -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
@@ -51,7 +51,7 @@ client_test() {
 
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
-        -m 256M -smp 2 -nographic \
+        -m 256M  -smp 2 -nographic \
         -net nic,macaddr=$mac,model=e1000 \
         -net socket,connect=127.0.0.1:12320 \
         -watchdog i6300esb -watchdog-action poweroff \
index 53ac5c7997ee19f5a4f9e4f73dfe44a3625d6436..2a3700dec3e28d1c9812c1b0d15878e764449eca 100755 (executable)
@@ -19,7 +19,7 @@ run_server() {
         -drive format=raw,index=1,media=disk,file=$TESTDIR/root.ext3 \
         -drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
         -drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-        -m 512M  -smp 2 \
+        -m 512M   -smp 2 \
         -display none \
         -serial $SERIAL \
         -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
@@ -46,7 +46,7 @@ run_client() {
 
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file=$TESTDIR/client.img \
-        -m 512M -smp 2 -nographic \
+        -m 512M  -smp 2 -nographic \
         -net nic,macaddr=52:54:00:12:34:00,model=e1000 \
         -net nic,macaddr=52:54:00:12:34:01,model=e1000 \
         -net socket,connect=127.0.0.1:12330 \
@@ -207,7 +207,7 @@ test_setup() {
         -drive format=raw,index=1,media=disk,file=$TESTDIR/client.img \
         -drive format=raw,index=2,media=disk,file=$TESTDIR/iscsidisk2.img \
         -drive format=raw,index=3,media=disk,file=$TESTDIR/iscsidisk3.img \
-        -smp 2 -m 256M -nographic -net none \
+         -smp 2 -m 256M -nographic -net none \
         -append "root=/dev/fakeroot rw rootfstype=ext3 quiet console=ttyS0,115200n81 selinux=0" \
         -initrd $TESTDIR/initramfs.makeroot  || return 1
     grep -F -m 1 -q dracut-root-block-created $TESTDIR/client.img || return 1
index 8d49b057ce464d26853cd6507c2a6936e8aec066..9d3167db9554012b009499c27e544f72b75e3e8b 100755 (executable)
@@ -17,7 +17,7 @@ run_server() {
         -drive format=raw,index=0,media=disk,file=$TESTDIR/server.ext2 \
         -drive format=raw,index=1,media=disk,file=$TESTDIR/nbd.ext2 \
         -drive format=raw,index=2,media=disk,file=$TESTDIR/encrypted.ext2 \
-        -m 256M -smp 2 \
+        -m 256M  -smp 2 \
         -display none \
         -net nic,macaddr=52:54:00:12:34:56,model=e1000 \
         -net socket,listen=127.0.0.1:12340 \
@@ -55,7 +55,7 @@ client_test() {
 
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \
-        -m 512M -smp 2 \
+        -m 512M  -smp 2 \
         -nographic \
         -net nic,macaddr=$mac,model=e1000 \
         -net socket,connect=127.0.0.1:12340 \
@@ -249,7 +249,7 @@ make_encrypted_root() {
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file=$TESTDIR/flag.img \
         -drive format=raw,index=1,media=disk,file=$TESTDIR/encrypted.ext2 \
-        -m 256M -smp 2\
+        -m 256M  -smp 2\
         -nographic -net none \
         -append "root=/dev/fakeroot rw quiet console=ttyS0,115200n81 selinux=0" \
         -initrd $TESTDIR/initramfs.makeroot  || return 1
index ef27682bdce0b32ea7072e71cd6f8dbba69c412e..3da0cb918caa594ea4cac2ee7a6cb4536931261c 100755 (executable)
@@ -14,7 +14,7 @@ run_server() {
     fsck -a "$TESTDIR"/server.ext3 || return 1
     $testdir/run-qemu \
         -drive format=raw,index=0,media=disk,file="$TESTDIR"/server.ext3 \
-        -m 512M -smp 2 \
+        -m 512M  -smp 2 \
         -display none \
         -net socket,listen=127.0.0.1:12350 \
         -net nic,macaddr=52:54:01:12:34:56,model=e1000 \
@@ -49,7 +49,7 @@ client_test() {
         return 1
     fi
 
-    $testdir/run-qemu -drive format=raw,index=0,media=disk,file="$TESTDIR"/client.img -m 512M -smp 2 -nographic \
+    $testdir/run-qemu -drive format=raw,index=0,media=disk,file="$TESTDIR"/client.img -m 512M  -smp 2 -nographic \
         -net socket,connect=127.0.0.1:12350 \
         -net nic,macaddr=52:54:00:12:34:$mac1,model=e1000 \
         -net nic,macaddr=52:54:00:12:34:$mac2,model=e1000 \
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/99-idesymlinks.rules b/test/TEST-70-BONDBRIDGETEAMVLAN/99-idesymlinks.rules
new file mode 100644 (file)
index 0000000..d557790
--- /dev/null
@@ -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-70-BONDBRIDGETEAMVLAN/Makefile b/test/TEST-70-BONDBRIDGETEAMVLAN/Makefile
new file mode 100644 (file)
index 0000000..aad2705
--- /dev/null
@@ -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-70-BONDBRIDGETEAMVLAN/client-init.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/client-init.sh
new file mode 100755 (executable)
index 0000000..2018393
--- /dev/null
@@ -0,0 +1,22 @@
+#!/bin/sh
+exec >/dev/console 2>&1
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+strstr() { [ "${1#*$2*}" != "$1" ]; }
+CMDLINE=$(while read line; do echo $line;done < /proc/cmdline)
+export TERM=linux
+export PS1='initramfs-test:\w\$ '
+stty sane
+echo "made it to the rootfs! Powering down."
+
+(
+    echo OK
+    ip -o -4 address show scope global | while read n if rest; do echo $if;done
+    for i in /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-*; do
+       echo $i
+       grep -v 'UUID=' $i
+    done
+    echo EOF
+) > /dev/sda
+
+strstr "$CMDLINE" "rd.shell" && sh -i
+poweroff -f
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf b/test/TEST-70-BONDBRIDGETEAMVLAN/dhcpd.conf
new file mode 100644 (file)
index 0000000..e26bd60
--- /dev/null
@@ -0,0 +1,27 @@
+ddns-update-style none;
+
+use-host-decl-names true;
+
+subnet 192.168.50.0 netmask 255.255.255.0 {
+       option subnet-mask      255.255.255.0;
+       option routers          192.168.50.1;
+       next-server             192.168.50.1;
+       server-identifier       192.168.50.1;
+       option domain-name-servers 192.168.50.1;
+       option domain-search "example.com";
+       option domain-name "other.com";
+       option root-path "nfs:192.168.50.1:/nfs/client";
+       range 192.168.50.10 192.168.50.100;
+}
+
+subnet 192.168.51.0 netmask 255.255.255.0 {
+       option subnet-mask      255.255.255.0;
+       option routers          192.168.51.1;
+       next-server             192.168.51.1;
+       server-identifier       192.168.51.1;
+       option domain-name-servers 192.168.51.1;
+       option domain-search "example.com";
+       option domain-name "other.com";
+       option root-path "nfs:192.168.51.1:/nfs/client";
+       range 192.168.51.10 192.168.51.100;
+}
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/exports b/test/TEST-70-BONDBRIDGETEAMVLAN/exports
new file mode 100644 (file)
index 0000000..ff5f29b
--- /dev/null
@@ -0,0 +1 @@
+/nfs/client    192.168.50.0/24(rw,insecure,no_subtree_check,no_root_squash)
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/hard-off.sh
new file mode 100755 (executable)
index 0000000..12c3d5a
--- /dev/null
@@ -0,0 +1,3 @@
+#!/bin/sh
+getarg rd.shell || poweroff -f
+getarg failme && poweroff -f
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/hosts b/test/TEST-70-BONDBRIDGETEAMVLAN/hosts
new file mode 100644 (file)
index 0000000..d02a4e9
--- /dev/null
@@ -0,0 +1,5 @@
+127.0.0.1      localhost
+192.168.50.1   server
+192.168.50.100 client-if1
+192.168.50.101 client-if2
+192.168.50.102 client-if3
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/server-init.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/server-init.sh
new file mode 100755 (executable)
index 0000000..9f45c42
--- /dev/null
@@ -0,0 +1,115 @@
+#!/bin/sh
+exec </dev/console >/dev/console 2>&1
+set -x
+export PATH=/sbin:/bin:/usr/sbin:/usr/bin
+export TERM=linux
+export PS1='nfstest-server:\w\$ '
+stty sane
+echo "made it to the rootfs!"
+echo server > /proc/sys/kernel/hostname
+
+wait_for_if_link() {
+    local cnt=0
+    local li
+    while [ $cnt -lt 600 ]; do
+        li=$(ip -o link show dev $1 2>/dev/null)
+        [ -n "$li" ] && return 0
+        sleep 0.1
+        cnt=$(($cnt+1))
+    done
+    return 1
+}
+
+wait_for_if_up() {
+    local cnt=0
+    local li
+    while [ $cnt -lt 200 ]; do
+        li=$(ip -o link show up dev $1)
+        [ -n "$li" ] && return 0
+        sleep 0.1
+        cnt=$(($cnt+1))
+    done
+    return 1
+}
+
+wait_for_route_ok() {
+    local cnt=0
+    while [ $cnt -lt 200 ]; do
+        li=$(ip route show)
+        [ -n "$li" ] && [ -z "${li##*$1*}" ] && return 0
+        sleep 0.1
+        cnt=$(($cnt+1))
+    done
+    return 1
+}
+
+linkup() {
+    wait_for_if_link $1 2>/dev/null\
+     && ip link set $1 up 2>/dev/null\
+     && wait_for_if_up $1 2>/dev/null
+}
+
+modprobe -b -q 8021q
+>/dev/watchdog
+ip addr add 127.0.0.1/8 dev lo
+linkup lo
+ip link set dev eth0 name ens3
+ip addr add 192.168.50.1/24 dev ens3
+linkup ens3
+>/dev/watchdog
+ip link set dev eth1 name ens4
+ip link add dev ens4.1 link ens4 type vlan id 1
+ip link add dev ens4.2 link ens4 type vlan id 2
+ip link add dev ens4.3 link ens4 type vlan id 3
+ip link add dev ens4.4 link ens4 type vlan id 4
+ip addr add 192.168.54.1/24 dev ens4.1
+ip addr add 192.168.55.1/24 dev ens4.2
+ip addr add 192.168.56.1/24 dev ens4.3
+ip addr add 192.168.57.1/24 dev ens4.4
+linkup ens4
+ip link set dev eth2 name ens5
+ip addr add 192.168.51.1/24 dev ens5
+linkup ens5
+ip link set dev eth3 name ens6
+linkup ens6
+>/dev/watchdog
+modprobe af_packet
+> /dev/watchdog
+modprobe sunrpc
+>/dev/watchdog
+mount -t rpc_pipefs sunrpc /var/lib/nfs/rpc_pipefs
+>/dev/watchdog
+[ -x /sbin/portmap ] && portmap
+>/dev/watchdog
+[ -x /sbin/rpcbind ] && rpcbind
+>/dev/watchdog
+modprobe nfsd
+>/dev/watchdog
+mount -t nfsd nfsd /proc/fs/nfsd
+>/dev/watchdog
+exportfs -r
+>/dev/watchdog
+rpc.nfsd
+>/dev/watchdog
+rpc.mountd
+>/dev/watchdog
+rpc.idmapd
+>/dev/watchdog
+exportfs -r
+>/dev/watchdog
+>/var/lib/dhcpd/dhcpd.leases
+>/dev/watchdog
+chmod 777 /var/lib/dhcpd/dhcpd.leases
+>/dev/watchdog
+dhcpd -cf /etc/dhcpd.conf -lf /var/lib/dhcpd/dhcpd.leases ens3 ens5
+#echo -n 'V' > /dev/watchdog
+#sh -i
+#tcpdump -i ens3
+# Wait forever for the VM to die
+echo "Serving NFS mounts"
+while :; do
+       sleep 10
+       >/dev/watchdog
+done
+mount -n -o remount,ro /
+poweroff -f
diff --git a/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh b/test/TEST-70-BONDBRIDGETEAMVLAN/test.sh
new file mode 100755 (executable)
index 0000000..bcfdf27
--- /dev/null
@@ -0,0 +1,313 @@
+#!/bin/bash
+# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
+# ex: ts=8 sw=4 sts=4 et filetype=sh
+TEST_DESCRIPTION="root filesystem on NFS with bridging/bonding/vlan"
+KVERSION=${KVERSION-$(uname -r)}
+
+# Uncomment this to debug failures
+#DEBUGFAIL="rd.shell rd.break"
+#DEBUGFAIL="rd.shell rd.break rd.debug"
+#SERIAL="tcp:127.0.0.1:9999"
+
+run_server() {
+    # Start server first
+    echo "MULTINIC TEST SETUP: Starting DHCP/NFS server"
+
+    fsck -a "$TESTDIR"/server.ext3 || return 1
+    $testdir/run-qemu \
+        -hda "$TESTDIR"/server.ext3 \
+        -m 512M -smp 2 \
+        -display none \
+        -net socket,vlan=0,listen=127.0.0.1:12350 \
+        -net socket,vlan=1,listen=127.0.0.1:12351 \
+        -net socket,vlan=2,listen=127.0.0.1:12352 \
+        -net socket,vlan=3,listen=127.0.0.1:12353 \
+        -net nic,vlan=0,macaddr=52:54:01:12:34:56,model=e1000 \
+        -net nic,vlan=1,macaddr=52:54:01:12:34:57,model=e1000 \
+        -net nic,vlan=2,macaddr=52:54:01:12:34:58,model=e1000 \
+        -net nic,vlan=3,macaddr=52:54:01:12:34:59,model=e1000 \
+        ${SERIAL:+-serial "$SERIAL"} \
+        ${SERIAL:--serial file:"$TESTDIR"/server.log} \
+        -watchdog i6300esb -watchdog-action poweroff \
+        -kernel /boot/vmlinuz-"$KVERSION" \
+        -no-reboot \
+        -append "panic=1 loglevel=7 root=/dev/sda rootfstype=ext3 rw console=ttyS0,115200n81 selinux=0 rd.debug" \
+        -initrd "$TESTDIR"/initramfs.server \
+        -pidfile "$TESTDIR"/server.pid -daemonize || return 1
+    chmod 644 -- "$TESTDIR"/server.pid || return 1
+
+    # Cleanup the terminal if we have one
+    tty -s && stty sane
+
+    echo Sleeping 10 seconds to give the server a head start
+    sleep 10
+}
+
+client_test() {
+    local test_name="$1"
+    local do_vlan13="$2"
+    local cmdline="$3"
+    local check="$4"
+    local CONF
+
+    echo "CLIENT TEST START: $test_name"
+
+    [ "$do_vlan13" != "yes" ] && unset do_vlan13
+
+    # Need this so kvm-qemu will boot (needs non-/dev/zero local disk)
+    if ! dd if=/dev/zero of="$TESTDIR"/client.img bs=1M count=1; then
+        echo "Unable to make client sda image" 1>&2
+        return 1
+    fi
+
+    $testdir/run-qemu -hda "$TESTDIR"/client.img -m 256M -smp 2 -nographic \
+        -net socket,vlan=0,connect=127.0.0.1:12350 \
+        ${do_vlan13:+-net socket,vlan=1,connect=127.0.0.1:12351} \
+        -net socket,vlan=2,connect=127.0.0.1:12352 \
+        ${do_vlan13:+-net socket,vlan=3,connect=127.0.0.1:12353} \
+        -net nic,vlan=0,macaddr=52:54:00:12:34:01,model=e1000 \
+        -net nic,vlan=0,macaddr=52:54:00:12:34:02,model=e1000 \
+        -net nic,vlan=1,macaddr=52:54:00:12:34:03,model=e1000 \
+        -net nic,vlan=2,macaddr=52:54:00:12:34:04,model=e1000 \
+        -net nic,vlan=3,macaddr=52:54:00:12:34:05,model=e1000 \
+        -watchdog i6300esb -watchdog-action poweroff \
+        -kernel /boot/vmlinuz-"$KVERSION" \
+        -no-reboot \
+        -append "panic=1 $cmdline rd.debug $DEBUGFAIL rd.retry=5 rw console=ttyS0,115200n81 selinux=0 init=/sbin/init" \
+        -initrd "$TESTDIR"/initramfs.testing
+
+    { 
+        read OK
+        if [[ "$OK" != "OK" ]]; then
+            echo "CLIENT TEST END: $test_name [FAILED - BAD EXIT]"
+            return 1
+        fi
+
+        while read line; do
+            [[ $line == END ]] && break
+            CONF+="$line "
+        done
+    } < "$TESTDIR"/client.img || return 1
+
+    if [[ "$check" != "$CONF" ]]; then
+        echo "Expected: '$check'"
+        echo
+        echo
+        echo "Got:      '$CONF'"
+        echo "CLIENT TEST END: $test_name [FAILED - BAD CONF]"
+        return 1
+    fi
+
+    echo "CLIENT TEST END: $test_name [OK]"
+    return 0
+}
+
+
+test_run() {
+    if ! run_server; then
+        echo "Failed to start server" 1>&2
+        return 1
+    fi
+    test_client || { kill_server; return 1; }
+}
+
+test_client() {
+    client_test "Multiple VLAN" \
+        "yes" \
+        "
+vlan=vlan0001:ens4
+vlan=vlan2:ens4
+vlan=ens4.3:ens4
+vlan=ens4.0004:ens4
+ip=ens3:dhcp
+ip=192.168.54.101::192.168.54.1:24:test:vlan0001:none
+ip=192.168.55.102::192.168.55.1:24:test:vlan2:none
+ip=192.168.56.103::192.168.56.1:24:test:ens4.3:none
+ip=192.168.57.104::192.168.57.1:24:test:ens4.0004:none
+rd.neednet=1
+root=nfs:192.168.50.1:/nfs/client bootdev=ens3
+" \
+    'ens3 ens4.0004 ens4.3 vlan0001 vlan2 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens3 # Generated by dracut initrd NAME="ens3" DEVICE="ens3" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Ethernet /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4.0004 # Generated by dracut initrd NAME="ens4.0004" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.57.104" PREFIX="24" GATEWAY="192.168.57.1" TYPE=Vlan DEVICE="ens4.0004" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4.3 # Generated by dracut initrd NAME="ens4.3" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.56.103" PREFIX="24" GATEWAY="192.168.56.1" TYPE=Vlan DEVICE="ens4.3" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan0001 # Generated by dracut initrd NAME="vlan0001" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.54.101" PREFIX="24" GATEWAY="192.168.54.1" TYPE=Vlan DEVICE="vlan0001" VLAN=yes PHYSDEV="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-vlan2 # Generated by dracut initrd NAME="vlan2" ONBOOT=yes NETBOOT=yes BOOTPROTO=none IPADDR="192.168.55.102" PREFIX="24" GATEWAY="192.168.55.1" TYPE=Vlan DEVICE="vlan2" VLAN=yes PHYSDEV="ens4" EOF ' \
+    || return 1
+
+    client_test "Multiple Bonds" \
+        "yes" \
+        "
+bond=bond0:ens4,ens5
+bond=bond1:ens6,ens7
+ip=bond0:dhcp
+ip=bond1:dhcp
+rd.neednet=1
+root=nfs:192.168.50.1:/nfs/client bootdev=bond0
+" \
+    'bond0 bond1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond0 # Generated by dracut initrd NAME="bond0" DEVICE="bond0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond0" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-bond1 # Generated by dracut initrd NAME="bond1" DEVICE="bond1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp BONDING_OPTS="" NAME="bond1" TYPE=Bond /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes SLAVE=yes MASTER="bond1" DEVICE="ens7" EOF ' \
+    || return 1
+
+    client_test "Multiple Bridges" \
+        "no" \
+        "
+bridge=br0:ens4,ens5
+bridge=br1:ens6,ens7
+ip=br0:dhcp
+ip=br1:dhcp
+rd.neednet=1
+root=nfs:192.168.50.1:/nfs/client bootdev=br0
+" \
+    'br0 br1 /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br0 # Generated by dracut initrd NAME="br0" DEVICE="br0" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br0" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-br1 # Generated by dracut initrd NAME="br1" DEVICE="br1" ONBOOT=yes NETBOOT=yes IPV6INIT=yes BOOTPROTO=dhcp TYPE=Bridge NAME="br1" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens4 # Generated by dracut initrd NAME="ens4" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens4" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens5 # Generated by dracut initrd NAME="ens5" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br0" DEVICE="ens5" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens6 # Generated by dracut initrd NAME="ens6" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens6" /run/initramfs/state/etc/sysconfig/network-scripts/ifcfg-ens7 # Generated by dracut initrd NAME="ens7" TYPE=Ethernet ONBOOT=yes NETBOOT=yes BRIDGE="br1" DEVICE="ens7" EOF ' \
+    || return 1
+
+    kill_server
+    return 0
+}
+
+test_setup() {
+     # Make server root
+    dd if=/dev/null of="$TESTDIR"/server.ext3 bs=1M seek=60
+    mke2fs -j -F -- "$TESTDIR"/server.ext3
+    mkdir -- "$TESTDIR"/mnt
+    mount -o loop -- "$TESTDIR"/server.ext3 "$TESTDIR"/mnt
+
+    (
+        export initdir="$TESTDIR"/mnt
+        . "$basedir"/dracut-init.sh
+
+        (
+            cd "$initdir";
+            mkdir -p -- dev sys proc run etc var/run tmp var/lib/{dhcpd,rpcbind}
+            mkdir -p -- var/lib/nfs/{v4recovery,rpc_pipefs}
+            chmod 777 -- var/lib/rpcbind var/lib/nfs
+        )
+
+        for _f in modules.builtin.bin modules.builtin; do
+            [[ $srcmods/$_f ]] && break
+        done || {
+            dfatal "No modules.builtin.bin and modules.builtin found!"
+            return 1
+        }
+
+        for _f in modules.builtin.bin modules.builtin modules.order; do
+            [[ $srcmods/$_f ]] && inst_simple "$srcmods/$_f" "/lib/modules/$kernel/$_f"
+        done
+
+        inst_multiple sh ls shutdown poweroff stty cat ps ln ip \
+            dmesg mkdir cp ping exportfs \
+            modprobe rpc.nfsd rpc.mountd showmount tcpdump \
+            /etc/services sleep mount chmod
+        for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
+            [ -f "${_terminfodir}"/l/linux ] && break
+        done
+        inst_multiple -o "${_terminfodir}"/l/linux
+        type -P portmap >/dev/null && inst_multiple portmap
+        type -P rpcbind >/dev/null && inst_multiple rpcbind
+        [ -f /etc/netconfig ] && inst_multiple /etc/netconfig
+        type -P dhcpd >/dev/null && inst_multiple dhcpd
+        [ -x /usr/sbin/dhcpd3 ] && inst /usr/sbin/dhcpd3 /usr/sbin/dhcpd
+        instmods nfsd sunrpc ipv6 lockd af_packet 8021q
+        inst_simple /etc/os-release
+        inst ./server-init.sh /sbin/init
+        inst ./hosts /etc/hosts
+        inst ./exports /etc/exports
+        inst ./dhcpd.conf /etc/dhcpd.conf
+        inst_multiple /etc/nsswitch.conf /etc/rpc /etc/protocols
+
+        inst_multiple rpc.idmapd /etc/idmapd.conf
+
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
+        inst_libdir_file 'libnfsidmap/*.so*'
+        inst_libdir_file 'libnfsidmap*.so*'
+
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' /etc/nsswitch.conf \
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+        _nsslibs=${_nsslibs#|}
+        _nsslibs=${_nsslibs%|}
+
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
+
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
+        inst /etc/passwd /etc/passwd
+        inst /etc/group /etc/group
+
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
+        ldconfig -r "$initdir"
+        dracut_kernel_post
+    )
+
+    # Make client root inside server root
+    (
+        export initdir="$TESTDIR"/mnt/nfs/client
+        . "$basedir"/dracut-init.sh
+        inst_multiple sh shutdown poweroff stty cat ps ln ip \
+            mount dmesg mkdir cp ping grep ls
+        for _terminfodir in /lib/terminfo /etc/terminfo /usr/share/terminfo; do
+            [[ -f ${_terminfodir}/l/linux ]] && break
+        done
+        inst_multiple -o "${_terminfodir}"/l/linux
+        inst_simple /etc/os-release
+        inst ./client-init.sh /sbin/init
+        (
+            cd "$initdir"
+            mkdir -p -- dev sys proc etc run
+            mkdir -p -- var/lib/nfs/rpc_pipefs
+        )
+        inst /etc/nsswitch.conf /etc/nsswitch.conf
+        inst /etc/passwd /etc/passwd
+        inst /etc/group /etc/group
+
+        inst_multiple rpc.idmapd /etc/idmapd.conf
+        inst_libdir_file 'libnfsidmap_nsswitch.so*'
+        inst_libdir_file 'libnfsidmap/*.so*'
+        inst_libdir_file 'libnfsidmap*.so*'
+
+        _nsslibs=$(sed -e '/^#/d' -e 's/^.*://' -e 's/\[NOTFOUND=return\]//' -- /etc/nsswitch.conf \
+            |  tr -s '[:space:]' '\n' | sort -u | tr -s '[:space:]' '|')
+        _nsslibs=${_nsslibs#|}
+        _nsslibs=${_nsslibs%|}
+
+        inst_libdir_file -n "$_nsslibs" 'libnss_*.so*'
+
+        cp -a -- /etc/ld.so.conf* "$initdir"/etc
+        ldconfig -r "$initdir"
+    )
+
+    umount "$TESTDIR"/mnt
+    rm -fr -- "$TESTDIR"/mnt
+
+    # Make an overlay with needed tools for the test harness
+    (
+        export initdir="$TESTDIR"/overlay
+        . "$basedir"/dracut-init.sh
+        inst_multiple poweroff shutdown
+        inst_hook emergency 000 ./hard-off.sh
+        inst_simple ./99-idesymlinks.rules /etc/udev/rules.d/99-idesymlinks.rules
+    )
+
+    # Make server's dracut image
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
+        --no-early-microcode \
+        -m "udev-rules base rootfs-block fs-lib debug kernel-modules watchdog" \
+        -d "af_packet piix ide-gd_mod ata_piix ext3 sd_mod nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files nfsd e1000 i6300esb ib700wdt" \
+        --no-hostonly-cmdline -N \
+        -f "$TESTDIR"/initramfs.server "$KVERSION" || return 1
+
+    # Make client's dracut image
+    $basedir/dracut.sh -l -i "$TESTDIR"/overlay / \
+        --no-early-microcode \
+        -o "plymouth" \
+        -a "debug" \
+        -d "af_packet piix sd_mod sr_mod ata_piix ide-gd_mod e1000 nfsv2 nfsv3 nfsv4 nfs_acl nfs_layout_nfsv41_files sunrpc i6300esb ib700wdt" \
+        --no-hostonly-cmdline -N \
+        -f "$TESTDIR"/initramfs.testing "$KVERSION" || return 1
+}
+
+kill_server() {
+    if [[ -s "$TESTDIR"/server.pid ]]; then
+        kill -TERM -- $(cat "$TESTDIR"/server.pid)
+        rm -f -- "$TESTDIR"/server.pid
+    fi
+}
+
+test_cleanup() {
+    kill_server
+}
+
+. "$testdir"/test-functions
index 0e3a1a688e5fb60bb744308dc7d88b0a6e85477e..5c25f954effd8d178c5b191bc5d52cc4bab21342 100755 (executable)
@@ -16,34 +16,52 @@ test_run() {
     mkdir -p "$rootdir/proc"
     mkdir -p "$rootdir/sys"
     mkdir -p "$rootdir/dev"
+    mkdir -p "$rootdir/boot"
 
-trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit $ret;' EXIT
-trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit 1;' SIGINT
+    trap 'ret=$?; [[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit $ret;' EXIT
+    trap '[[ -d $rootdir ]] && { umount "$rootdir/proc"; umount "$rootdir/sys"; umount "$rootdir/dev"; rm -rf -- "$rootdir"; } || :; exit 1;' SIGINT
 
     mount --bind /proc "$rootdir/proc"
     mount --bind /sys "$rootdir/sys"
     mount -t devtmpfs devtmpfs "$rootdir/dev"
 
+    mkdir -p "$rootdir/$TESTDIR"
+    cp --reflink=auto -a \
+       "$TESTDIR"/dracut-[0-9]*.$(arch).rpm \
+       "$TESTDIR"/dracut-network-[0-9]*.$(arch).rpm \
+       "$rootdir/$TESTDIR/"
+
     dnf_or_yum=yum
-    command -v dnf >/dev/null && dnf_or_yum=dnf
-    $dnf_or_yum --nogpgcheck --installroot "$rootdir"/ --releasever 25 --disablerepo=updates-testing install --allowerasing -y \
-       $dnf_or_yum \
-       passwd \
-       rootfiles \
-       systemd \
-       kernel \
-       fedora-release \
-       device-mapper-multipath \
-       lvm2 \
-       mdadm \
-        bash \
-        iscsi-initiator-utils \
-        "$TESTDIR"/dracut-[0-9]*.$(arch).rpm \
-        "$TESTDIR"/dracut-network-[0-9]*.$(arch).rpm
+    dnf_or_yum_cmd=yum
+    command -v dnf >/dev/null && { dnf_or_yum="dnf"; dnf_or_yum_cmd="dnf --allowerasing"; }
+    for (( i=0; i < 5 ; i++)); do
+        $dnf_or_yum_cmd -v --nogpgcheck --installroot "$rootdir"/ --releasever 25 --disablerepo='*' \
+                        --enablerepo=fedora --enablerepo=updates \
+                        install -y \
+                        $dnf_or_yum \
+                        passwd \
+                        rootfiles \
+                        systemd \
+                        systemd-udev \
+                        kernel \
+                        kernel-core \
+                        redhat-release \
+                        device-mapper-multipath \
+                        lvm2 \
+                        mdadm \
+                        bash \
+                        iscsi-initiator-utils \
+                        "$TESTDIR"/dracut-[0-9]*.$(arch).rpm \
+                        ${NULL} && break
+        #"$TESTDIR"/dracut-config-rescue-[0-9]*.$(arch).rpm \
+            #"$TESTDIR"/dracut-network-[0-9]*.$(arch).rpm \
+            #    ${NULL}
+    done
+    (( i < 5 ))
 
     cat >"$rootdir"/test.sh <<EOF
 #!/bin/bash
-set -xe
+set -x
 export LC_MESSAGES=C
 rpm -Va |& grep -F -v '85-display-manager.preset' &> /test.output
 find / -xdev -type f -not -path '/var/*' \
@@ -61,7 +79,8 @@ find / -xdev -type f -not -path '/var/*' \
   -not -path '/dev/null' \
   -not -path "/boot/loader/entries/\$(cat /etc/machine-id)-*" \
   -not -path "/boot/\$(cat /etc/machine-id)/*" \
-  -exec rpm -qf '{}' ';' | \
+  -not -path '/etc/openldap/certs/*' \
+  -print0 | xargs -0 rpm -qf | \
   grep -F 'not owned' &>> /test.output || :
 exit 0
 EOF
@@ -71,9 +90,9 @@ EOF
     chroot "$rootdir" /test.sh || :
 
     if [[ -s "$rootdir"/test.output ]]; then
-       failed=1
-       echo TEST Failed >&2
-       cat "$rootdir"/test.output >&2
+        failed=1
+        echo TEST Failed >&2
+        cat "$rootdir"/test.output >&2
     fi
 
     umount "$rootdir/proc"
index a65ea198821c2b3f5eaeea5ababac33ccacd18b0..1de58230d55a63124703a02faf179081a4e23dac 100755 (executable)
@@ -29,4 +29,4 @@ if ! [ -f "$VMLINUZ" ]; then
     fi
 fi
 
-exec sudo $BIN $ARGS -kernel $VMLINUZ "$@"
+exec sudo $BIN $ARGS -kernel $VMLINUZ -cpu host "$@"
diff --git a/test/test-rhel-7.2.rpms b/test/test-rhel-7.2.rpms
deleted file mode 100644 (file)
index edec0cc..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-dash
-bridge-utils
-asciidoc
-mdadm
-lvm2
-cryptsetup
-nfs-utils
-nbd
-dhcp-server
-scsi-target-utils
-iscsi-initiator-utils
-