Skip to content

Commit

Permalink
Add kernel config as optional parameter to transformer 'dom0_binaries'
Browse files Browse the repository at this point in the history
Copy kernel config under /boot if passed to the transformer

Signed-off-by: Smit Gardhariya <[email protected]>
  • Loading branch information
smit-gardhariya committed Sep 3, 2024
1 parent d97439f commit 95fe5af
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions lisa/transformers/dom0_kernel_installer.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ class BinaryInstallerSchema(BaseInstallerSchema):
),
)

# kernel config local absolute path
kernel_config_path: str = field(
default="",
metadata=field_metadata(
required=True,
),
)

# initrd binary local absolute path
initrd_image_path: str = field(
default="",
Expand Down Expand Up @@ -67,6 +75,7 @@ def install(self) -> str:
kernel_image_path: str = runbook.kernel_image_path
initrd_image_path: str = runbook.initrd_image_path
kernel_modules_path: str = runbook.kernel_modules_path
kernel_config_path: str = runbook.kernel_config_path
is_initrd: bool = False

uname = node.tools[Uname]
Expand Down Expand Up @@ -117,6 +126,20 @@ def install(self) -> str:
node.get_pure_path(f"/boot/initrd.img-{new_kernel}"),
)

if kernel_config_path:
# Copy kernel config
err = f"Can not find kernel config path: {kernel_config_path}"
assert os.path.exists(kernel_config_path), err
node.shell.copy(
PurePath(kernel_config_path),
node.get_pure_path(f"/var/tmp/config-{new_kernel}"),
)
_copy_kernel_binary(
node,
node.get_pure_path(f"/var/tmp/config-{new_kernel}"),
node.get_pure_path(f"/boot/config-{new_kernel}"),
)

_update_mariner_config(
node,
is_initrd,
Expand Down Expand Up @@ -199,6 +222,19 @@ def _update_mariner_config(
sudo=True,
)

cp = node.tools[Cp]
cp.copy(
src=PurePath(f"/boot/initrd.img-{current_kernel}"),
dest=PurePath(f"/boot/initrd.img-{new_kernel}"),
sudo=True,
)
sed.substitute(
regexp=f"mariner_initrd_mshv=initrd.img-{current_kernel}",
replacement=f"mariner_initrd_mshv=initrd.img-{new_kernel}",
file=mariner_config,
sudo=True,
)

if is_initrd:
# Modify the /boot/mariner-mshv.cfg to point new initrd binary
sed.substitute(
Expand Down

0 comments on commit 95fe5af

Please sign in to comment.