Chao pointed out that it's better to use get_option_value to get get a specific config_val.
And also there's a potential risk when use below sed command to do the replacement.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
Say user configure kdump.conf like the following. Then sed may replace "/var/crash/post.sh" with something else, depanding on mount point.
kdump_post /var/crash/post.sh path /var/crash
So in this patch clean them up.
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..793495a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -313,7 +313,7 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return
- _save_path=$(grep ^path "/etc/kdump.conf"| cut -d' ' -f2) + _save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
_mntpoint=$(get_mntpoint_from_path $_save_path) @@ -331,7 +331,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"} - sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf + sed -i -e "s#^path[[:space:]]+$_save_path#path $_path#" /tmp/$$-kdump.conf fi
} @@ -346,7 +346,7 @@ kdump_install_conf() { config_val=$(strip_comments $config_val) case "$config_opt" in ext[234]|xfs|btrfs|minix|raw) - sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf + sed -i -e "s#^$config_opt[[:space:]]+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$config_val"
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
In this patch add a judgement, if user specified path let's use sed command to replace it with parsed path. Otherwise execute a echo command to add the path:
echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..10c561d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,11 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"} - sed -i -e "s#^path[[:space:]]+$_save_path#path $_path#" /tmp/$$-kdump.conf + if [ -n "$(get_option_value "path")" ]; then + sed -i -e "s#^path[[:space:]]+$_save_path#path $_path#" /tmp/$$-kdump.conf + else + echo "path $_path" >> /tmp/$$-kdump.conf + fi fi
}
On 12/18/14 at 02:07pm, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
In this patch add a judgement, if user specified path let's use sed command to replace it with parsed path. Otherwise execute a echo command to add the path:
echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
This looks good to me.
Acked-by: WANG Chao chaowang@redhat.com
dracut-module-setup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..10c561d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,11 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
if [ -n "$(get_option_value "path")" ]; then
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
else
echo "path $_path" >> /tmp/$$-kdump.conf
fifi
}
1.9.0
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/18/14 at 02:07pm, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
In this patch add a judgement, if user specified path let's use sed command to replace it with parsed path. Otherwise execute a echo command to add the path:
echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
dracut-module-setup.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..10c561d 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,11 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
if [ -n "$(get_option_value "path")" ]; then
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
else
echo "path $_path" >> /tmp/$$-kdump.conf
fi
Baoquan, seems above code is using $_path which is a path relative to mount point in 2nd kernel $$-kdump.conf, so how about just dropping the sed line, use below instead: 1) delete original ^path line in /tmp/$$-kdump.conf 2) echo "path $_path" >> /tmp/$$-kdump.conf
It looks simple than original sed logic.
Thanks Dave
On 12/22/14 at 03:12pm, Dave Young wrote:
On 12/18/14 at 02:07pm, Baoquan He wrote:
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
if [ -n "$(get_option_value "path")" ]; then
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
else
echo "path $_path" >> /tmp/$$-kdump.conf
fi
Baoquan, seems above code is using $_path which is a path relative to mount point in 2nd kernel $$-kdump.conf, so how about just dropping the sed line, use below instead:
- delete original ^path line in /tmp/$$-kdump.conf
- echo "path $_path" >> /tmp/$$-kdump.conf
Yes, it's another way. Will try.
It looks simple than original sed logic.
Thanks Dave _______________________________________________ kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
In this new version, according to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
sed -i -e "s#^path[[:space:]]+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..8200317 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"} - sed -i -e "s#^path[[:space:]]+$_save_path#path $_path#" /tmp/$$-kdump.conf + + #erase the old path line, then insert the parsed path + sed -i -e "s#^path[[:space:]]+$_save_path##" /tmp/$$-kdump.conf + echo "path $_path" >> /tmp/$$-kdump.conf fi
}
Hi, Baoquan
Seems I did not found the patch in my mutt client, but I see it in webmail, thus reply here.
The sed does not work with my below test, anything wrong?
bash-4.2$ cat kdump.conf /var/crash/ssh-key bash-4.2$ sed -i -e "s#^path[[:space:]]+$_save_path##" ./kdump.conf bash-4.2$ cat kdump.conf /var/crash/ssh-key
----- Original Message ----- From: "Baoquan He" bhe@redhat.com To: kexec@lists.fedoraproject.org Cc: chaowang@redhat.com Sent: Friday, December 26, 2014 4:02:26 PM Subject: [PATCH] adding the parsed path to etc/kdump.conf of kdump initrd
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
In this new version, according to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
sed -i -e "s#^path[[:space:]]+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..8200317 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"} - sed -i -e "s#^path[[:space:]]+$_save_path#path $_path#" /tmp/$$-kdump.conf + + #erase the old path line, then insert the parsed path + sed -i -e "s#^path[[:space:]]+$_save_path##" /tmp/$$-kdump.conf + echo "path $_path" >> /tmp/$$-kdump.conf fi
}
On 12/30/14 at 12:34am, Dave Young wrote:
Hi, Baoquan
Seems I did not found the patch in my mutt client, but I see it in webmail, thus reply here.
I'm using mutt in a remote machine, offlineimap did not run there...
The sed does not work with my below test, anything wrong?
bash-4.2$ cat kdump.conf /var/crash/ssh-key bash-4.2$ sed -i -e "s#^path[[:space:]]+$_save_path##" ./kdump.conf bash-4.2$ cat kdump.conf /var/crash/ssh-key
I'm wrong, I did not specify ^path in the begginning, please ignore this comment
Thanks Dave
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..d0d2d1a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"} - sed -i -e "s#^path[[:space:]]+$_save_path#path $_path#" /tmp/$$-kdump.conf + + #erase the old path line, then insert the parsed path + sed -i -e "s#^path.*##" /tmp/$$-kdump.conf + echo "path $_path" >> /tmp/$$-kdump.conf fi
}
On 12/30/14 at 02:51pm, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..d0d2d1a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
#erase the old path line, then insert the parsed path
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf
fiecho "path $_path" >> /tmp/$$-kdump.conf
}
Looks good, thanks for another version.
Acked-by: Dave Young dyoung@redhat.com
Thanks Dave
On 12/30/14 at 02:51pm, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..d0d2d1a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
#erase the old path line, then insert the parsed path
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf
I think next time it's better to use sed -i '/^path/d' to remove the whole line (including the \n). Anyway I'm not strong with this, but please do next time.
Thanks WANG Chao
On 12/30/14 at 05:19pm, WANG Chao wrote:
On 12/30/14 at 02:51pm, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..d0d2d1a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
#erase the old path line, then insert the parsed path
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf
I think next time it's better to use sed -i '/^path/d' to remove the whole line (including the \n). Anyway I'm not strong with this, but please do next time.
s#^path.*## will leave a blank line, but /^path/d will delete the line Agree with you, since we found the problem it is better to do it. Bao, care to resend?
Thanks Dave
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v4->v5: Chaowang suggested using sed command d to remove the whole line like below: sed -i "/^path/d" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com --- dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..ff7a088 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"} - sed -i -e "s#^path[[:space:]]+$_save_path#path $_path#" /tmp/$$-kdump.conf + + #erase the old path line, then insert the parsed path + sed -i "/^path/d" /tmp/$$-kdump.conf + echo "path $_path" >> /tmp/$$-kdump.conf fi
}
On 12/31/14 at 10:48am, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v4->v5: Chaowang suggested using sed command d to remove the whole line like below: sed -i "/^path/d" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
Thanks for the update again.
This patch looks good to me.
Acked-by: WANG Chao chaowang@redhat.com
dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..ff7a088 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
#erase the old path line, then insert the parsed path
sed -i "/^path/d" /tmp/$$-kdump.conf
fiecho "path $_path" >> /tmp/$$-kdump.conf
}
1.8.5.3
On 12/31/14 at 10:48am, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v4->v5: Chaowang suggested using sed command d to remove the whole line like below: sed -i "/^path/d" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
Dave, do you any objection for this version?
dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..ff7a088 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
#erase the old path line, then insert the parsed path
sed -i "/^path/d" /tmp/$$-kdump.conf
fiecho "path $_path" >> /tmp/$$-kdump.conf
}
1.8.5.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 01/13/15 at 01:09pm, WANG Chao wrote:
On 12/31/14 at 10:48am, Baoquan He wrote:
Steve found a bug. When mount a disk in /var and not specify path in /etc/kdump.conf, the vmcore will be dumped into /var/crash of that disk, but not /crash on that disk.
This is because when write the parsed path into /tmp/$$-kdump.conf in default_dump_target_install_conf() of mkdumprd, it uses below sed command. So if no path specified at all, this sed command won't add it to /tmp/$$-kdump.conf. Then in 2nd kernel it will take default path, namely "/var/crash" as path if no path in /etc/kdump.conf in 2nd kernel.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
According to Dave Young's suggestion, erase the old path line and then insert the parsed path. This can fix it.
v2->v3: erase the old path line and then insert the parsed path.
sed -i -e "s#^path[[:space:]]\+$_save_path##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v3->v4: Change the sed pattern, erase lines starting with "path" and then insert the parsed path.
sed -i -e "s#^path.*##" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
v4->v5: Chaowang suggested using sed command d to remove the whole line like below: sed -i "/^path/d" /tmp/$$-kdump.conf echo "path $_path" >> /tmp/$$-kdump.conf
Signed-off-by: Baoquan He bhe@redhat.com
Dave, do you any objection for this version?
It looks good to me.
Acked-by: Dave Young dyoung@redhat.com
dracut-module-setup.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 793495a..ff7a088 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -331,7 +331,10 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
#erase the old path line, then insert the parsed path
sed -i "/^path/d" /tmp/$$-kdump.conf
fiecho "path $_path" >> /tmp/$$-kdump.conf
}
1.8.5.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec
On 12/18/14 at 02:07pm, Baoquan He wrote:
Chao pointed out that it's better to use get_option_value to get get a specific config_val.
And also there's a potential risk when use below sed command to do the replacement.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
Say user configure kdump.conf like the following. Then sed may replace "/var/crash/post.sh" with something else, depanding on mount point.
kdump_post /var/crash/post.sh path /var/crash
So in this patch clean them up.
Signed-off-by: Baoquan He bhe@redhat.com
Thanks. This patch looks good me.
Acked-by: WANG Chao chaowang@redhat.com
dracut-module-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..793495a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -313,7 +313,7 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return
- _save_path=$(grep ^path "/etc/kdump.conf"| cut -d' ' -f2)
_save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
_mntpoint=$(get_mntpoint_from_path $_save_path)
@@ -331,7 +331,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
fised -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
} @@ -346,7 +346,7 @@ kdump_install_conf() { config_val=$(strip_comments $config_val) case "$config_opt" in ext[234]|xfs|btrfs|minix|raw)
sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf
sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$config_val"
-- 1.9.0
On 12/18/14 at 02:07pm, Baoquan He wrote:
Chao pointed out that it's better to use get_option_value to get get a specific config_val.
And also there's a potential risk when use below sed command to do the replacement.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
Say user configure kdump.conf like the following. Then sed may replace "/var/crash/post.sh" with something else, depanding on mount point.
kdump_post /var/crash/post.sh path /var/crash
So in this patch clean them up.
Signed-off-by: Baoquan He bhe@redhat.com
Hi, Baoquan
I think this patch also needs update regarding your [patch 2/2 v5]
Thanks WANG Chao
dracut-module-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..793495a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -313,7 +313,7 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return
- _save_path=$(grep ^path "/etc/kdump.conf"| cut -d' ' -f2)
_save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
_mntpoint=$(get_mntpoint_from_path $_save_path)
@@ -331,7 +331,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
fised -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
} @@ -346,7 +346,7 @@ kdump_install_conf() { config_val=$(strip_comments $config_val) case "$config_opt" in ext[234]|xfs|btrfs|minix|raw)
sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf
sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$config_val"
-- 1.9.0
On 01/04/15 at 02:09pm, WANG Chao wrote:
On 12/18/14 at 02:07pm, Baoquan He wrote:
Chao pointed out that it's better to use get_option_value to get get a specific config_val.
And also there's a potential risk when use below sed command to do the replacement.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
Say user configure kdump.conf like the following. Then sed may replace "/var/crash/post.sh" with something else, depanding on mount point.
kdump_post /var/crash/post.sh path /var/crash
So in this patch clean them up.
Signed-off-by: Baoquan He bhe@redhat.com
Hi, Baoquan
I think this patch also needs update regarding your [patch 2/2 v5]
more specific part?
Thanks WANG Chao
dracut-module-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..793495a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -313,7 +313,7 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return
- _save_path=$(grep ^path "/etc/kdump.conf"| cut -d' ' -f2)
_save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
_mntpoint=$(get_mntpoint_from_path $_save_path)
@@ -331,7 +331,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
fised -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
} @@ -346,7 +346,7 @@ kdump_install_conf() { config_val=$(strip_comments $config_val) case "$config_opt" in ext[234]|xfs|btrfs|minix|raw)
sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf
sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$config_val"
-- 1.9.0
On 01/04/15 at 03:20pm, Baoquan He wrote:
On 01/04/15 at 02:09pm, WANG Chao wrote:
On 12/18/14 at 02:07pm, Baoquan He wrote:
Chao pointed out that it's better to use get_option_value to get get a specific config_val.
And also there's a potential risk when use below sed command to do the replacement.
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
Say user configure kdump.conf like the following. Then sed may replace "/var/crash/post.sh" with something else, depanding on mount point.
kdump_post /var/crash/post.sh path /var/crash
So in this patch clean them up.
Signed-off-by: Baoquan He bhe@redhat.com
Hi, Baoquan
I think this patch also needs update regarding your [patch 2/2 v5]
more specific part?
Never mind. I misread something. This patch looks good to me.
ACK.
Thanks WANG Chao
dracut-module-setup.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index d65c8c0..793495a 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -313,7 +313,7 @@ default_dump_target_install_conf()
is_user_configured_dump_target && return
- _save_path=$(grep ^path "/etc/kdump.conf"| cut -d' ' -f2)
_save_path=$(get_option_value "path") [ -z "$_save_path" ] && _save_path=$DEFAULT_PATH
_mntpoint=$(get_mntpoint_from_path $_save_path)
@@ -331,7 +331,7 @@ default_dump_target_install_conf() echo "$_fstype $_target" >> /tmp/$$-kdump.conf
_path=${_save_path##"$_mntpoint"}
sed -i -e "s#$_save_path#$_path#" /tmp/$$-kdump.conf
fised -i -e "s#^path[[:space:]]\+$_save_path#path $_path#" /tmp/$$-kdump.conf
} @@ -346,7 +346,7 @@ kdump_install_conf() { config_val=$(strip_comments $config_val) case "$config_opt" in ext[234]|xfs|btrfs|minix|raw)
sed -i -e "s#$config_val#$(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf
sed -i -e "s#^$config_opt[[:space:]]\+$config_val#$config_opt $(kdump_to_udev_name $config_val)#" /tmp/$$-kdump.conf ;; ssh|nfs) kdump_install_net "$config_val"
-- 1.9.0