On Tue, Jun 16, 2020 at 3:30 PM Dave Young <dyoung(a)redhat.com> wrote:
On 06/16/20 at 01:53pm, Kairui Song wrote:
> Dracut get_persistent_dev function don't recognize UUID= or LABEL=
> format, so caller should conver it to the path to the block device
> before calling it. There is already such a helper
> "kdump_get_persistent_dev", just move it to kdump-lib.sh and rename
> it to reuse it,
Any special reason to rename it to get_kdump_persistent_dev?
The kdump_get_persistent_dev was meant to add a "kdump" prefix so it is
like a "kdump" version of "get_persistent_dev"
I can keep the name, just want to align the naming style in kdump-lib.sh
I'm fine either way.
>
> Signed-off-by: Kairui Song <kasong(a)redhat.com>
> ---
> dracut-module-setup.sh | 20 +++-----------------
> kdump-lib.sh | 14 ++++++++++++++
> kdumpctl | 2 +-
> mkdumprd | 4 ++--
> 4 files changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh
> index 90f3772..c7eeff8 100755
> --- a/dracut-module-setup.sh
> +++ b/dracut-module-setup.sh
> @@ -48,20 +48,6 @@ depends() {
> return 0
> }
>
> -kdump_get_persistent_dev() {
> - local dev="${1//\"/}"
> -
> - case "$dev" in
> - UUID=*)
> - dev=`blkid -U "${dev#UUID=}"`
> - ;;
> - LABEL=*)
> - dev=`blkid -L "${dev#LABEL=}"`
> - ;;
> - esac
> - echo $(get_persistent_dev "$dev")
> -}
> -
> kdump_is_bridge() {
> [ -d /sys/class/net/"$1"/bridge ]
> }
> @@ -466,7 +452,7 @@ default_dump_target_install_conf()
> kdump_install_net "$_target"
> _fstype="nfs"
> else
> - _target=$(kdump_get_persistent_dev $_target)
> + _target=$(get_kdump_persistent_dev $_target)
> fi
>
> echo "$_fstype $_target" >> ${initdir}/tmp/$$-kdump.conf
> @@ -491,11 +477,11 @@ kdump_install_conf() {
> # remove inline comments after the end of a directive.
> case "$_opt" in
> raw)
> - _pdev=$(persistent_policy="by-id" kdump_get_persistent_dev
$_val)
> + _pdev=$(persistent_policy="by-id" get_kdump_persistent_dev
$_val)
> sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#"
${initdir}/tmp/$$-kdump.conf
> ;;
> ext[234]|xfs|btrfs|minix)
> - _pdev=$(kdump_get_persistent_dev $_val)
> + _pdev=$(get_kdump_persistent_dev $_val)
> sed -i -e "s#^$_opt[[:space:]]\+$_val#$_opt $_pdev#"
${initdir}/tmp/$$-kdump.conf
> ;;
> ssh|nfs)
> diff --git a/kdump-lib.sh b/kdump-lib.sh
> index 74dac4c..0040483 100755
> --- a/kdump-lib.sh
> +++ b/kdump-lib.sh
> @@ -301,6 +301,20 @@ get_kdump_mntpoint_from_target()
> echo $_mntpoint | tr -s "/"
> }
>
> +get_kdump_persistent_dev() {
> + local dev="${1//\"/}"
> +
> + case "$dev" in
> + UUID=*)
> + dev=`blkid -U "${dev#UUID=}"`
> + ;;
> + LABEL=*)
> + dev=`blkid -L "${dev#LABEL=}"`
> + ;;
> + esac
> + echo $(get_persistent_dev "$dev")
> +}
> +
> # get_option_value <option_name>
> # retrieves value of option defined in kdump.conf
> get_option_value() {
> diff --git a/kdumpctl b/kdumpctl
> index 408b88a..8004783 100755
> --- a/kdumpctl
> +++ b/kdumpctl
> @@ -482,7 +482,7 @@ check_dump_fs_modified()
> if [[ $(expr substr $_new_fstype 1 3) = "nfs" ]];then
> _new_dev=$_target
> else
> - _new_dev=$(get_persistent_dev $_target)
> + _new_dev=$(get_kdump_persistent_dev $_target)
> if [ -z "$_new_dev" ]; then
> echo "Get persistent device name failed"
> return 2
> diff --git a/mkdumprd b/mkdumprd
> index 7bc1bd1..c7b8f17 100644
> --- a/mkdumprd
> +++ b/mkdumprd
> @@ -93,7 +93,7 @@ to_mount() {
> _mntopts="$_new_mntpoint $_fstype $_options"
> # for non-nfs _target converting to use udev persistent name
> if [ -b "$_target" ]; then
> - _pdev="$(get_persistent_dev $_target)"
> + _pdev="$(get_kdump_persistent_dev $_target)"
> if [ -z "$_pdev" ]; then
> return 1
> fi
> @@ -438,7 +438,7 @@ do
> dd if=$config_val count=1 of=/dev/null > /dev/null 2>&1 || {
> perror_exit "Bad raw disk $config_val"
> }
> - _praw=$(persistent_policy="by-id" get_persistent_dev
$config_val)
> + _praw=$(persistent_policy="by-id" get_kdump_persistent_dev
$config_val)
> if [ -z "$_praw" ]; then
> exit 1
> fi
> --
> 2.26.2
> _______________________________________________
> kexec mailing list -- kexec(a)lists.fedoraproject.org
> To unsubscribe send an email to kexec-leave(a)lists.fedoraproject.org
> Fedora Code of Conduct:
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
> List Guidelines:
https://fedoraproject.org/wiki/Mailing_list_guidelines
> List Archives:
https://lists.fedoraproject.org/archives/list/kexec@lists.fedoraproject.org
Thanks
Dave
--
Best Regards,
Kairui Song