From 82928d14803885b218a4959027b8f39fd8ba9dda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= Date: Wed, 14 May 2025 15:40:15 +0200 Subject: [PATCH] kata-deploy: Avoid changing any component path in case of restart MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous attempt to fix this issue only took in consideration the QEMU binary, as I completely forgot that there were other pieces of the config that we also adjusted. Now, let's just check one of the configs before trying to adjust anything else, and only do the changes if the suffix added with the multi-install suffix is not yet added.{ Signed-off-by: Fabiano FidĂȘncio --- .../kata-deploy/scripts/kata-deploy.sh | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/packaging/kata-deploy/scripts/kata-deploy.sh b/tools/packaging/kata-deploy/scripts/kata-deploy.sh index 850ee260f8..1d7ac8d31f 100755 --- a/tools/packaging/kata-deploy/scripts/kata-deploy.sh +++ b/tools/packaging/kata-deploy/scripts/kata-deploy.sh @@ -352,11 +352,6 @@ function adjust_qemu_cmdline() { [[ "${shim}" =~ ^(qemu|qemu-coco-dev)$ ]] && qemu_share="qemu" qemu_binary=$(tomlq '.hypervisor.qemu.path' ${config_path} | tr -d \") - if [[ -n "${MULTI_INSTALL_SUFFIX}" ]] && [[ "${qemu_binary}" == *-installation-prefix ]]; then - # This means that we'e already adapted the qemu-binary to the - # correct path, and we have nothing else to do here. - return - fi qemu_binary_script="${qemu_binary}-installation-prefix" qemu_binary_script_host_path="/host/${qemu_binary_script}" @@ -450,13 +445,23 @@ function install_artifacts() { fi if [ "${dest_dir}" != "${default_dest_dir}" ]; then - # We could always do this sed, regardless, but I have a strong preference - # on not touching the configuration files unless extremelly needed - sed -i -e "s|${default_dest_dir}|${dest_dir}|g" "${kata_config_file}" + kernel_path=$(tomlq ".hypervisor.${shim}.path" ${kata_config_file} | tr -d \") + if echo $kernel_path | grep -q "${dest_dir}"; then + # If we got to this point here, it means that we're dealing with + # a kata containers configuration file that has already been changed + # to support multi-install suffix, and we're here most likely due to + # and update or container restart, and we simply should not try to + # do anything else, thus just leave the conditional. + break + else + # We could always do this sed, regardless, but I have a strong preference + # on not touching the configuration files unless extremelly needed + sed -i -e "s|${default_dest_dir}|${dest_dir}|g" "${kata_config_file}" - # Let's only adjust qemu_cmdline for the QEMUs that we build and ship ourselves - [[ "${shim}" =~ ^(qemu|qemu-snp|qemu-nvidia-gpu|qemu-nvidia-gpu-snp|qemu-sev|qemu-se|qemu-coco-dev)$ ]] && \ - adjust_qemu_cmdline "${shim}" "${kata_config_file}" + # Let's only adjust qemu_cmdline for the QEMUs that we build and ship ourselves + [[ "${shim}" =~ ^(qemu|qemu-snp|qemu-nvidia-gpu|qemu-nvidia-gpu-snp|qemu-sev|qemu-se|qemu-coco-dev)$ ]] && \ + adjust_qemu_cmdline "${shim}" "${kata_config_file}" + fi fi done