-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup SNP on the RHEL host #15
Open
LakshmiSaiHarika
wants to merge
6
commits into
amd:main
Choose a base branch
from
LakshmiSaiHarika:rhel-changes
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
fdd5bd4
Update snp docs for RHEL
LakshmiSaiHarika 91aa8be
snp.sh: Update ubuntu dependency installation structure
LakshmiSaiHarika 7a5fe80
snp.sh: Remove nasm package uninstallation step
LakshmiSaiHarika ae2466c
snp.sh: Add Redhat dependencies installation prior to the SNP kernel …
LakshmiSaiHarika 23f1f93
snp.sh: Set GRUB default menu to built SNP kernel
LakshmiSaiHarika 876b7f7
snp.sh: Update AMDSEV_URL and AMDSEV_DEFAULT_BRANCH for the RHEL fixes
LakshmiSaiHarika File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -91,8 +91,8 @@ IMAGE="${IMAGE:-${LAUNCH_WORKING_DIR}/${GUEST_NAME}.img}" | |
GENERATED_INITRD_BIN="${SETUP_WORKING_DIR}/initrd.img" | ||
|
||
# URLs and repos | ||
AMDSEV_URL="https://github.com/ryansavino/AMDSEV.git" | ||
AMDSEV_DEFAULT_BRANCH="snp-latest-fixes" | ||
AMDSEV_URL="https://github.com/LakshmiSaiHarika/AMDSEV.git" | ||
AMDSEV_DEFAULT_BRANCH="rhel-setup-host" | ||
AMDSEV_NON_UPM_BRANCH="snp-non-upm" | ||
SNPGUEST_URL="https://github.com/virtee/snpguest.git" | ||
SNPGUEST_BRANCH="tags/v0.7.1" | ||
|
@@ -173,9 +173,6 @@ install_nasm_from_source() { | |
return 0 | ||
fi | ||
|
||
# Remove package manager nasm | ||
sudo apt purge nasm | ||
|
||
pushd "${WORKING_DIR}" >/dev/null | ||
|
||
# Install from source | ||
|
@@ -214,15 +211,7 @@ install_sev_snp_measure() { | |
pip install sev-snp-measure==${SEV_SNP_MEASURE_VERSION} | ||
} | ||
|
||
install_dependencies() { | ||
local dependencies_installed_file="${WORKING_DIR}/dependencies_already_installed" | ||
source "${HOME}/.cargo/env" 2>/dev/null || true | ||
|
||
if [ -f "${dependencies_installed_file}" ]; then | ||
echo -e "Dependencies previously installed" | ||
return 0 | ||
fi | ||
|
||
install_ubuntu_dependencies() { | ||
# Build dependencies | ||
sudo apt install -y build-essential git | ||
|
||
|
@@ -274,7 +263,96 @@ install_dependencies() { | |
|
||
# Needed to build 6.11.0-rc3 SNP kernel on the host | ||
pip install tomli | ||
|
||
} | ||
|
||
install_rhel_dependencies() { | ||
# Build dependencies | ||
sudo dnf install -y wget curl | ||
sudo dnf install -y git | ||
|
||
# Check if codeready-builder RH repository is enabled for ninja-build qemu dependency | ||
if [[ -z $(sudo dnf repolist | grep codeready-builder-for-rhel-9-x86_64-rpms) ]]; then | ||
echo "Install and enable codeready-builder RH repository for ninja-build dependency" | ||
return 1 | ||
fi | ||
|
||
# qemu dependencies | ||
sudo dnf install -y gcc | ||
sudo dnf install -y ninja-build | ||
sudo dnf install -y bzip2 | ||
sudo dnf install -y glib2-devel | ||
|
||
# ovmf dependencies | ||
sudo dnf install -y gcc-c++ | ||
sudo dnf install -y libuuid-devel | ||
sudo dnf install -y iasl | ||
install_nasm_from_source | ||
|
||
# kernel dependencies | ||
sudo dnf install -y bison | ||
sudo dnf install -y flex | ||
sudo dnf install -y kernel-devel | ||
sudo dnf install -y bc | ||
sudo dnf install -y rpm-build | ||
sudo dnf install -y dwarves perl | ||
|
||
# cloud-utils dependency | ||
sudo dnf install -y cloud-init | ||
|
||
# sev-snp-measure | ||
sudo dnf install -y python3-pip | ||
|
||
# Needed to build 6.11.0-rc3 SNP kernel on the host | ||
pip install tomli | ||
} | ||
|
||
get_linux_distro() { | ||
local linux_distro | ||
|
||
[ -e /etc/os-release ] && . /etc/os-release | ||
|
||
case ${ID,,} in | ||
ubuntu | debian) | ||
linux_distro='ubuntu' | ||
;; | ||
rhel) | ||
linux_distro="rhel" | ||
;; | ||
*) | ||
linux_distro="Unsupported Linux Distribution: ${ID}" | ||
;; | ||
esac | ||
|
||
echo "${linux_distro}" | ||
} | ||
|
||
install_dependencies() { | ||
local linux_distro=$(get_linux_distro) | ||
|
||
local dependencies_installed_file="${WORKING_DIR}/dependencies_already_installed" | ||
source "${HOME}/.cargo/env" 2>/dev/null || true | ||
|
||
if [ -f "${dependencies_installed_file}" ]; then | ||
echo -e "Dependencies previously installed" | ||
return 0 | ||
fi | ||
|
||
# Perform the installation of dependencies specific to the linux distribution | ||
case ${linux_distro} in | ||
ubuntu) | ||
install_ubuntu_dependencies | ||
break | ||
;; | ||
rhel) | ||
install_rhel_dependencies | ||
break | ||
;; | ||
*) | ||
>&2 echo -e "ERROR: ${linux_distro}" | ||
return 1 | ||
;; | ||
esac | ||
|
||
echo "true" > "${dependencies_installed_file}" | ||
} | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done.. I cleaned this up |
||
|
@@ -287,7 +365,7 @@ get_host_kernel_version() { | |
echo "${host_kernel}" | ||
} | ||
|
||
set_grub_default_snp() { | ||
set_ubuntu_grub_default_snp() { | ||
# Get the path to host kernel and the version for setting grub default | ||
local host_kernel_version=$(get_host_kernel_version) | ||
|
||
|
@@ -320,6 +398,45 @@ set_grub_default_snp() { | |
sudo update-grub | ||
} | ||
|
||
set_rhel_grub_default_snp() { | ||
# Get the SNP host latest version from snp host kernel config | ||
local snp_host_kernel_version=$(get_host_kernel_version) | ||
|
||
# Retrieve snp menuitem name from grub.cfg | ||
local snp_menuitem_name=$(sudo cat /boot/grub2/grub.cfg \ | ||
| grep "menuentry.*${snp_host_kernel_version}" \ | ||
| grep -v "(recovery mode)" \ | ||
| grep -o -P "(?<=').*" \ | ||
| grep -o -P "^[^']*") | ||
|
||
# Create default grub backup | ||
sudo cp /etc/default/grub /etc/default/grub_bkup | ||
|
||
# Replace grub default with snp menuitem name | ||
sudo sed -i -e "s|^\(GRUB_DEFAULT=\).*$|\1\"${snp_menuitem_name}\"|g" "/etc/default/grub" | ||
|
||
# Regenerate GRUB configuration for UEFI based machine or BIOS based machine | ||
[ -d /sys/firmware/efi ] && sudo grub2-mkconfig -o /boot/efi/EFI/redhat/grub.cfg || sudo grub2-mkconfig -o /boot/grub2/grub.cfg | ||
} | ||
|
||
set_grub_default_snp() { | ||
local linux_distro=$(get_linux_distro) | ||
|
||
# Set the host default GRUB Menu to boot into built SNP kernel based on specific linux distro | ||
case ${linux_distro} in | ||
ubuntu) | ||
set_ubuntu_grub_default_snp | ||
;; | ||
rhel) | ||
set_rhel_grub_default_snp | ||
;; | ||
*) | ||
>&2 echo -e "ERROR: ${linux_distro}" | ||
return 1 | ||
;; | ||
esac | ||
} | ||
|
||
generate_guest_ssh_keypair() { | ||
if [[ -f "${GUEST_SSH_KEY_PATH}" \ | ||
&& -f "${GUEST_SSH_KEY_PATH}.pub" ]]; then | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryansavino Please review and merge my PR for adding minor RHEL fixes into your AMDESE fork
PR link: here