From 928c386f979ec8a69a3680a542e1fbff4544b2f1 Mon Sep 17 00:00:00 2001 From: Coiby Xu Date: Mon, 19 Sep 2022 09:03:48 +0800 Subject: [PATCH] Allow to update kexec-tools using virt-customize for cloud base image Resolves: bz2089871 Upstream: Fedora Conflict: None commit da0ca0d205e7ac64426ad43540dae3d03cd4447a Author: Coiby Xu Date: Tue Jun 28 14:38:28 2022 +0800 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 Signed-off-by: Coiby Xu --- kdumpctl | 11 +++++++++-- kexec-tools.spec | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/kdumpctl b/kdumpctl index 208faef..989da79 100755 --- a/kdumpctl +++ b/kdumpctl @@ -44,9 +44,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 b10c836..0929df8 100644 --- a/kexec-tools.spec +++ b/kexec-tools.spec @@ -275,6 +275,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