If set the dump target "/var/crash", the kdump will save the core in
/sysroot/var/crash, instead of /var/crash.
The mount point "/sysroot" is a special directory in Atomic, that it
will conflict in 2nd kernel where kdump will mount the "/" on the mount
point "/sysroot/".
To solve it, handle the Atomic kdump specially. If is the Atomic and
kdump path is the subdirectory in "/var/", save the core to the path
which specified in the /etc/kdump.conf directly.
Signed-off-by: Minfei Huang <mhuang(a)redhat.com>
---
kdump-lib-initramfs.sh | 91 +++++++++++++++++++++++++++++++++++++++++++-------
kdump-lib.sh | 9 +++++
2 files changed, 88 insertions(+), 12 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 57b8304..8ccd72c 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -81,10 +81,74 @@ get_kdump_confs()
fi
}
-# dump_fs <mount point| device>
-dump_fs()
+dump_common_fs()
+{
+ local _mp=$1
+
+ # Remove -F in makedumpfile case. We don't want a flat format dump here.
+ [[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo
$CORE_COLLECTOR | sed -e "s/-F//g"`
+
+ mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
+
+ save_vmcore_dmesg_fs ${DMESG_COLLECTOR}
"$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+
+ echo "kdump: saving vmcore"
+ $CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete ||
return 1
+ mv $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete
$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore
+ sync
+
+ echo "kdump: saving vmcore complete"
+}
+
+is_ostree() {
+ local _ostree=$(getarg ostree=)
+ if test -n "${_ostree}"; then
+ return 0
+ fi
+ return 1
+}
+
+# find out the specified target in Atomic, like /var
+atomic_specified_path()
+{
+ local _path=""
+
+ for p in "var/" "/var/"; do
+ if [[ $KDUMP_PATH =~ "$p"* ]]; then
+ _path="/$p"
+ break
+ fi
+ done
+ echo $_path
+}
+
+is_atomic_specified_path()
{
+ local _path=$(atomic_specified_path)
+ if [[ "x" = "x$_path" ]]; then
+ echo 1
+ else
+ echo 0
+ fi
+}
+
+# handle the special case Atomic, if the target is "/var". Due to the
+# bind mounted directory /var, we hard code the real path of /var
+# where the /var is in.
+dump_atomic_rootfs()
+{
+ local _mp=$NEWROOT
+ local _bind_mp="$_mp/ostree/deploy/rhel-atomic-host"
+
+ echo "kdump: saving to $_bind_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+ mount -o remount,rw $_mp || return 1
+ dump_common_fs $_bind_mp
+ return $?
+}
+
+dump_generic_fs()
+{
local _dev=$(findmnt -k -f -n -r -o SOURCE $1)
local _mp=$(findmnt -k -f -n -r -o TARGET $1)
@@ -95,22 +159,25 @@ dump_fs()
return 1
fi
- # Remove -F in makedumpfile case. We don't want a flat format dump here.
- [[ $CORE_COLLECTOR = *makedumpfile* ]] && CORE_COLLECTOR=`echo
$CORE_COLLECTOR | sed -e "s/-F//g"`
-
echo "kdump: saving to $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
mount -o remount,rw $_mp || return 1
- mkdir -p $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR || return 1
- save_vmcore_dmesg_fs ${DMESG_COLLECTOR}
"$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/"
+ dump_common_fs $_mp
- echo "kdump: saving vmcore"
- $CORE_COLLECTOR /proc/vmcore $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete ||
return 1
- mv $_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore-incomplete
$_mp/$KDUMP_PATH/$HOST_IP-$DATEDIR/vmcore
- sync
+ return $?
+}
- echo "kdump: saving vmcore complete"
+# dump_fs <mount point| device>
+dump_fs()
+{
+
+ if is_ostree && is_atomic_specified_path && is_rootfs; then
+ dump_atomic_rootfs
+ else
+ dump_generic_fs $1
+ fi
+ return $?
}
save_vmcore_dmesg_fs() {
diff --git a/kdump-lib.sh b/kdump-lib.sh
index e4df376..81f2969 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -17,6 +17,15 @@ is_nfs_dump_target()
grep -q "^nfs" /etc/kdump.conf
}
+is_rootfs()
+{
+ if is_ssh_dump_target || is_nfs_dump_target; then
+ return 1
+ else
+ return 0
+ fi
+}
+
is_raw_dump_target()
{
grep -q "^raw" /etc/kdump.conf
--
2.2.2