Skip to content

Commit

Permalink
Add support for mariner-3.0 in dom0 kernel installer
Browse files Browse the repository at this point in the history
dom0 image based on mariner 3.0 has different
parameter that need to be changed while installing kernel
under different file. Add support for it under kernel
installer transformer.

Signed-off-by: Smit Gardhariya <[email protected]>
  • Loading branch information
smit-gardhariya committed Nov 20, 2024
1 parent ceac54d commit a4a95e5
Showing 1 changed file with 28 additions and 7 deletions.
35 changes: 28 additions & 7 deletions lisa/transformers/dom0_kernel_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -211,22 +217,37 @@ 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]

# Modify the /boot/mariner-mshv.cfg to point new kernel binary
# Param for Dom0 2.0 kernel installation
mariner_config = "/boot/mariner-mshv.cfg"
vmlinuz_regexp = f"vmlinuz-{current_kernel}"
vmlinuz_replacement = f"vmlinuz-{new_kernel}"
initrd_regexp = f"mariner_initrd_mshv=initrd.img-{current_kernel}"
initrd_replacement = f"mariner_initrd_mshv=initrd.img-{new_kernel}"

if distro == "Microsoft Azure Linux 3.0":
# Change param for Dom0 3.0 kernel installation
mariner_config = "/boot/grub2/grub.cfg"
initrd_regexp = f"initramfs-{current_kernel}.img"
initrd_replacement = f"initrd.img-{new_kernel}"

# Modify file 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
# Modify file 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}")

0 comments on commit a4a95e5

Please sign in to comment.