Skip to content
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

SNP Guest Launch for Fedora and Ubuntu #25

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

LakshmiSaiHarika
Copy link
Contributor

This PR performs following tasks:

  1. Launches various unique SNP enabled guests at the same time using different GUEST_NAME and HOST_SSH_PORT.
  2. Creates a guest seed image having userdata and metadata for configuration using genisoimage utility(as this is supported across various linux distros).
  3. Launches Fedora and Ubuntu SNP enabled guest.

Updated snp docs to launch various unique guest using unique values of GUEST_NAME and HOST_SSH_PORT environment variables.

Signed-off-by: Harika Nittala <[email protected]>
Improve the speed of  SNP guest creation through the download of the guest base os image once and re-use the same base image for SNP guest creation process for multiple guests.

Signed-off-by: Harika Nittala <[email protected]>
Users can launch multiple SNP enabled guests at the same time via the export of the GUEST_NAME and HOST_SSH_PORT env. variables

For the launch of multiple SNP guest at the same time, modified snp.sh to create a separate guest user directory and point the launch working directory to point the current specific guest user directory.

Signed-off-by: Harika Nittala <[email protected]>
Creates guest seed image containing user configured metadata and userdata via genisoimage utility in ubuntu as genisoimage utility is  available across different OS distrubutions (cloud-localds utility is supported only in Ubuntu OS)

Signed-off-by: Harika Nittala <[email protected]>
Modified guest cloud-init userdata and metadata to apply the guest configuration details across different OS linux distros(Ubuntu, Fedora, etc) successfuly during SNP guest launch.

Signed-off-by: Harika Nittala <[email protected]>
Modified the structure of SNP guest launch process in ubuntu to standardize the SNP guest launch feature across various OS linux distros.

Observed successful launch of SNP guest in ubuntu 22.04.

Signed-off-by: Harika Nittala <[email protected]>
Updated fedora dependencies for guest seed image creation to apply user configuration data on fedora image via genisoimage utility
Added support for the SNP guest launch on Fedora 38 host

Signed-off-by: Harika Nittala <[email protected]>
GUEST_SIZE_GB="${GUEST_SIZE_GB:-20}"
GUEST_MEM_SIZE_MB="${GUEST_MEM_SIZE_MB:-2048}"
GUEST_SMP="${GUEST_SMP:-4}"
CPU_MODEL="${CPU_MODEL:-EPYC-v4}"
GUEST_USER="${GUEST_USER:-amd}"
GUEST_PASS="${GUEST_PASS:-amd}"
GUEST_SSH_KEY_PATH="${GUEST_SSH_KEY_PATH:-${LAUNCH_WORKING_DIR}/${GUEST_NAME}-key}"
GUEST_ROOT_LABEL="${GUEST_ROOT_LABEL:-cloudimg-rootfs}"
GUEST_ROOT_LABEL="${GUEST_ROOT_LABEL:-""}"
Copy link
Contributor Author

@LakshmiSaiHarika LakshmiSaiHarika Dec 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLOUD_INIT_IMAGE_URL_UBUNTU="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"

IMAGE_BASENAME_UBUNTU=$(basename "${CLOUD_INIT_IMAGE_URL_UBUNTU}")

GUEST_ROOT_LABEL_UBUNTU="root"

IMAGE="${IMAGE:-${LAUNCH_WORKING_DIR}/${GUEST_NAME}.img}"

CLOUD_INIT_IMAGE_URL_FEDORA=""https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/38/Cloud/x86_64/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2"

# Set the guest OS image-cloud init URL based on the Host OS type
case ${linux_distro} in
ubuntu)
CLOUD_INIT_IMAGE_URL="https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64.img"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLOUD_INIT_IMAGE_URL=${CLOUD_INIT_IMAGE_URL_UBUNTU}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMAGE_BASENAME=${IMAGE_BASENAME_UBUNTU}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMAGE_BASENAME=$(basename "${CLOUD_INIT_IMAGE_URL}")

;;
fedora)
CLOUD_INIT_IMAGE_URL="https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/38/Cloud/x86_64/images/Fedora-Cloud-Base-38-1.6.x86_64.qcow2"
;;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLOUD_INIT_IMAGE_URL=${CLOUD_INIT_IMAGE_URL_FEDORA}

@@ -68,25 +68,26 @@ trap cleanup EXIT
# Working directory setup
WORKING_DIR="${WORKING_DIR:-$HOME/snp}"
SETUP_WORKING_DIR="${SETUP_WORKING_DIR:-${WORKING_DIR}/setup}"
LAUNCH_WORKING_DIR="${LAUNCH_WORKING_DIR:-${WORKING_DIR}/launch}"
GUEST_NAME="${GUEST_NAME:-snp-guest}"
LAUNCH_WORKING_DIR="${LAUNCH_WORKING_DIR:-${WORKING_DIR}/launch/${GUEST_NAME}}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LAUNCH_WORKING_DIR="${LAUNCH_WORKING_DIR:-${WORKING_DIR}/launch}"

Add command line option for separate user guest name
--guest_name Specify different guest name


# Download the guest os-image and change name
if [ ! -f "${BASE_CLOUD_IMAGE}" ]; then
wget "${CLOUD_INIT_IMAGE_URL}" -O "${BASE_CLOUD_IMAGE}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wget "${CLOUD_INIT_IMAGE_URL}" -O "${LAUNCH_WORKING_DIR}/IMAGE_BASENAME_UBUNTU"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant