From da0ca0d205e7ac64426ad43540dae3d03cd4447a Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Tue, 28 Jun 2022 14:38:28 +0800 Subject: [PATCH] Allow to update kexec-tools using virt-customize for cloud base image Resolves: bz2089871 Currently, kexec-tools can't be updated using virt-customize because older version of kdumpctl can't acquire instance lock for the get-default-crashkernel subcommand. The reason is /var/lock is linked to /run/lock which however doesn't exist in the case of virt-customize. This patch fixes this problem by using /tmp/kdump.lock as the lock file if /run/lock doesn't exist. Note 1. The lock file is now created in /run/lock instead of /var/run/lock since Fedora has adopted adopted /run [2] since F15. 2. %pre scriptlet now always return success since package update won't be blocked [1] https://fedoraproject.org/wiki/Features/var-run-tmpfs Fixes: 0adb0f4 ("try to reset kernel crashkernel when kexec-tools updates the default crashkernel value") Reported-by: Nicolas Hicher Suggested-by: Laszlo Ersek Suggested-by: Philipp Rudo Signed-off-by: Coiby Xu Reviewed-by: Philipp Rudo --- kdumpctl | 11 +++++++++-- kexec-tools.spec | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 7ff635c..fed55bd 100755 --- a/kdumpctl +++ b/kdumpctl @@ -49,9 +49,16 @@ fi single_instance_lock() { - local rc timeout=5 + local rc timeout=5 lockfile - if ! exec 9> /var/lock/kdump; then + if [[ -d /run/lock ]]; then + lockfile=/run/lock/kdump + else + # when updating package using virt-customize, /run/lock doesn't exist + lockfile=/tmp/kdump.lock + fi + + if ! exec 9> $lockfile; then derror "Create file lock failed" exit 1 fi diff --git a/kexec-tools.spec b/kexec-tools.spec index c6e42b2..bdc3b95 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -269,6 +269,8 @@ if ! grep -qs "ostree" /proc/cmdline && [ $1 == 2 ] && grep -q get-default-crash kdumpctl get-default-crashkernel fadump > /tmp/old_default_crashkernel_fadump 2>/dev/null %endif fi +# don't block package update +: %post # Initial installation