diff --git a/lisa/transformers/dom0_kernel_installer.py b/lisa/transformers/dom0_kernel_installer.py index 19a63c0b48..8afe68afab 100644 --- a/lisa/transformers/dom0_kernel_installer.py +++ b/lisa/transformers/dom0_kernel_installer.py @@ -144,10 +144,13 @@ def install(self) -> str: node.get_pure_path(f"/boot/config-{new_kernel}"), ) + node_info = node.get_information() + distro = node_info.get("distro_version", "") _update_mariner_config( node, current_kernel, new_kernel, + distro, ) return new_kernel @@ -185,10 +188,13 @@ def install(self) -> str: uname = node.tools[Uname] current_kernel = uname.get_linux_information().kernel_version_raw + node_info = node.get_information() + distro = node_info.get("distro_version", "") _update_mariner_config( node, current_kernel, new_kernel, + distro, ) return new_kernel @@ -211,22 +217,39 @@ def _update_mariner_config( node: Node, current_kernel: str, new_kernel: str, + distro: str, ) -> None: - mariner_config: str = "/boot/mariner-mshv.cfg" sed = node.tools[Sed] + if distro == "Microsoft Azure Linux 3.0": + # Change param for new Dom0 3.0 kernel installation + mariner_config = "/boot/grub2/grub.cfg" + vmlinuz_regexp = f"vmlinuz-{current_kernel}", + vmlinuz_replacement = f"vmlinuz-{new_kernel}", + initrd_regexp = f"initramfs-{current_kernel}.img", + initrd_replacement = f"initrd.img-{new_kernel}", + else: + # Change param for new Dom0 2.0 kernel installation + mariner_config = "/boot/mariner-mshv.cfg" + vmlinuz_regexp = f"mariner_linux_mshv=vmlinuz-{current_kernel}", + vmlinuz_replacement = f"mariner_linux_mshv=vmlinuz-{new_kernel}", + initrd_regexp = f"mariner_initrd_mshv=initrd.img-{current_kernel}", + initrd_replacement = f"mariner_initrd_mshv=initrd.img-{new_kernel}", + # Modify the /boot/mariner-mshv.cfg to point new kernel binary sed.substitute( - regexp=f"mariner_linux_mshv=vmlinuz-{current_kernel}", - replacement=f"mariner_linux_mshv=vmlinuz-{new_kernel}", + regexp=vmlinuz_regexp, + replacement=vmlinuz_replacement, file=mariner_config, sudo=True, ) # Modify the /boot/mariner-mshv.cfg to point new initrd binary sed.substitute( - regexp=f"mariner_initrd_mshv=initrd.img-{current_kernel}", - replacement=f"mariner_initrd_mshv=initrd.img-{new_kernel}", + regexp=initrd_regexp, + replacement=initrd_replacement, file=mariner_config, sudo=True, ) + res = node.execute(f"cat {mariner_config}", sudo=True) + print(f"MARINER CONFIG: {res.stdout}")