Skip to content

Commit

Permalink
podvm: update qemu for rhel s390x
Browse files Browse the repository at this point in the history
Packer is picking qemu-system-x86 instead of s390x as qemu binaries

Fixes: #1740

Signed-off-by: Saripalli Lavanya <Saripalli.Lavanya@ibm.com>
  • Loading branch information
Saripalli-lavanya committed Mar 28, 2024
1 parent 93ae704 commit 89c644b
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 3 deletions.
18 changes: 17 additions & 1 deletion src/cloud-api-adaptor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ BINARIES := cloud-api-adaptor agent-protocol-forwarder process-user-data
SOURCEDIRS := ./cmd ./pkg
PACKAGES := $(shell go list $(addsuffix /...,$(SOURCEDIRS)))
SOURCES := $(shell find $(SOURCEDIRS) -name '*.go' -print)
YQ_CHECKSUM_${ARCH} ?= $(YQ_CHECKSUM)
# End-to-end tests overall run timeout.
TEST_E2E_TIMEOUT ?= 60m

Expand Down Expand Up @@ -163,13 +164,27 @@ BINARIES_DOCKERFILE := Dockerfile.podvm_binaries$(DOCKERFILE_SUFFIX)
PODVM_DOCKERFILE := Dockerfile.podvm$(DOCKERFILE_SUFFIX)

podvm-builder:
ifeq ($(PODVM_DISTRO),rhel)
docker buildx build -t $(PODVM_BUILDER_IMAGE) -f podvm/$(BUILDER_DOCKERFILE) \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg ORG_ID=$(ORG_ID) \
--build-arg ARCH=$(ARCH) \
--build-arg ACTIVATION_KEY=$(ACTIVATION_KEY) \
--build-arg PACKER_VERSION=$(PACKER_VERSION) \
--build-arg PROTOC_VERSION=$(PROTOC_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--build-arg YQ_VERSION=$(YQ_VERSION) \
--build-arg YQ_CHECKSUM=$(YQ_CHECKSUM) \
--build-arg YQ_CHECKSUM=${YQ_CHECKSUM_$(ARCH)} \
$(DOCKER_OPTS) .
else
docker buildx build -t $(PODVM_BUILDER_IMAGE) -f podvm/$(BUILDER_DOCKERFILE) \
--build-arg GO_VERSION=$(GO_VERSION) \
--build-arg PROTOC_VERSION=$(PROTOC_VERSION) \
--build-arg RUST_VERSION=$(RUST_VERSION) \
--build-arg YQ_VERSION=$(YQ_VERSION) \
--build-arg YQ_CHECKSUM=${YQ_CHECKSUM_$(ARCH)} \
$(DOCKER_OPTS) .
endif

podvm-binaries:
cp -rf ../../.git .git
Expand All @@ -189,6 +204,7 @@ podvm-image:
--build-arg BINARIES_IMG=$(PODVM_BINARIES_IMAGE) \
--build-arg PODVM_DISTRO=$(PODVM_DISTRO) \
--build-arg ARCH=$(ARCH) \
--build-arg IMAGE_URL=$(IMAGE_URL) \
--build-arg CLOUD_PROVIDER=$(or $(CLOUD_PROVIDER),generic) \
$(DOCKER_OPTS) .
rm -rf .git
2 changes: 2 additions & 0 deletions src/cloud-api-adaptor/Makefile.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ endif
# stored in versions.yaml
YQ_VERSION := v4.35.1
YQ_CHECKSUM := "sha256:bd695a6513f1196aeda17b174a15e9c351843fb1cef5f9be0af170f2dd744f08"
YQ_CHECKSUM_s390x:= "sha256:4e6324d08630e7df733894a11830412a43703682d65a76f1fc925aac08268a45"

MINIMUM_YQ_MAJOR_VERSION := 4
INSTALLED_YQ_MAJOR_VERSION := $(shell $(YQ_COMMAND) --version | sed -nE 's/.* v?([0-9]+).*/\1/p')
Expand Down Expand Up @@ -51,3 +52,4 @@ PAUSE_REPO := $(or $(PAUSE_REPO),$(call query,oci.pause.registry))
PAUSE_VERSION := $(or $(PAUSE_VERSION),$(call query,oci.pause.tag))
OPA_REPO := $(or $(OPA_REPO),$(call query,git.opa.url))
OPA_VERSION := $(or $(OPA_VERSION),$(call query,git.opa.reference))
PACKER_VERSION := $(or $(PACKER_VERSION),$(call query,tools.packer))
5 changes: 5 additions & 0 deletions src/cloud-api-adaptor/podvm/Dockerfile.podvm.rhel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ ENV ARCH ${ARCH}
ENV UEFI ${UEFI}

ARG IMAGE_URL="/tmp/rhel.qcow2"

ARG IMAGE_CHECKSUM

ENV IMAGE_URL ${IMAGE_URL}
Expand All @@ -46,6 +47,10 @@ COPY . /src

WORKDIR /src/cloud-api-adaptor/podvm

RUN if [ "${ARCH}" == "x86_64" || "${ARCH}" == "amd64"]; then \
packer plugins install github.com/hashicorp/qemu; \
fi

RUN LIBC=gnu make image

# The below instructions can be used if you prefer to rebuild all the binaries
Expand Down
5 changes: 4 additions & 1 deletion src/cloud-api-adaptor/podvm/Dockerfile.podvm_builder.rhel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ ARG RUST_VERSION
ARG ORG_ID
ARG ACTIVATION_KEY
ARG YQ_VERSION
ARG YQ_CHECKSUM

ENV SMDEV_CONTAINER_OFF=1
ENV ARCH ${ARCH}
Expand All @@ -31,7 +32,9 @@ RUN subscription-manager repos --enable codeready-builder-for-rhel-9-${ARCH}-rpm
dnf install -y yum-utils gnupg git --allowerasing curl pkg-config clang perl libseccomp-devel gpgme-devel \
device-mapper-devel qemu-kvm unzip wget libassuan-devel genisoimage cloud-utils-growpart cloud-init;

ADD --checksum=${YQ_CHECKSUM} https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH/x86_64/amd64} /usr/local/bin/yq
RUN curl -L -o /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_${ARCH/x86_64/amd64} \
&& echo "${YQ_CHECKSUM#sha256:} /usr/local/bin/yq" | sha256sum -c -

RUN chmod a+x /usr/local/bin/yq && \
curl https://dl.google.com/go/go${GO_VERSION}.linux-${ARCH/x86_64/amd64}.tar.gz -o go${GO_VERSION}.linux-${ARCH/x86_64/amd64}.tar.gz && \
rm -rf /usr/local/go && tar -C /usr/local -xzf go${GO_VERSION}.linux-${ARCH/x86_64/amd64}.tar.gz && \
Expand Down
10 changes: 10 additions & 0 deletions src/cloud-api-adaptor/podvm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,14 @@ endif

endif
else ifeq ($(PODVM_DISTRO),rhel)
@echo defined
$(eval OPTS := -var disk_size=11144)
ifeq ($(ARCH),s390x)
$(eval OPTS += -var machine_type=${QEMU_MACHINE_TYPE_${ARCH}})
ifndef QEMU_BINARY
$(eval OPTS += -var qemu_binary=qemu-system-${ARCH})
endif
endif
else
$(error PODVM_DISTRO is invalid or not defined)
endif
Expand All @@ -75,6 +82,9 @@ $(IMAGE_FILE): $(BINARIES) $(FILES) setopts
if [ "${SE_BOOT}" = "1" ] && [ "${ARCH}" = "s390x" ]; then \
qemu-img create -f qcow2 "se-${IMAGE_FILE}" 100G; \
fi
if [ "${ARCH}" = "x86_64" ]; then \
packer plugins install github.com/hashicorp/qemu; \
fi
packer build ${PACKER_DEFAULT_OPTS} ${OPTS} qcow2/$(PODVM_DISTRO)
rm -fr toupload
rm -f cloud-init.img
Expand Down
4 changes: 3 additions & 1 deletion src/cloud-api-adaptor/podvm/qcow2/rhel/qemu-rhel.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ locals {
machine_type = "${var.os_arch}" == "x86_64" && "${var.is_uefi}" ? "q35" : "${var.machine_type}"
use_pflash = "${var.os_arch}" == "x86_64" && "${var.is_uefi}" ? "true" : "false"
firmware = "${var.os_arch}" == "x86_64" && "${var.is_uefi}" ? "${var.uefi_firmware}" : ""
cpu_type = "${var.os_arch}" == "s390x" ? "max" : "Cascadelake-Server"
}

source "qemu" "rhel" {
Expand All @@ -14,14 +15,15 @@ source "qemu" "rhel" {
iso_checksum = "${var.cloud_image_checksum}"
iso_url = "${var.cloud_image_url}"
output_directory = "output"
qemuargs = [["-m", "${var.memory}"], ["-smp", "cpus=${var.cpus}"], ["-cdrom", "${var.cloud_init_image}"], ["-serial", "mon:stdio"], ["-cpu", "Cascadelake-Server"]]
qemuargs = [["-m", "${var.memory}"], ["-smp", "cpus=${var.cpus}"], ["-cdrom", "${var.cloud_init_image}"], ["-serial", "mon:stdio"], ["-cpu", "${local.cpu_type}"]]
ssh_password = "${var.ssh_password}"
ssh_port = 22
ssh_username = "${var.ssh_username}"
ssh_timeout = "${var.ssh_timeout}"
boot_wait = "${var.boot_wait}"
vm_name = "${var.qemu_image_name}"
shutdown_command = "sudo shutdown -h now"
qemu_binary = "${var.qemu_binary}"
machine_type = "${local.machine_type}"
use_pflash = "${local.use_pflash}"
firmware = "${local.firmware}"
Expand Down
5 changes: 5 additions & 0 deletions src/cloud-api-adaptor/podvm/qcow2/rhel/variables.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ variable "memory" {
default = "2048M"
}

variable "qemu_binary" {
type = string
default = "qemu-system-x86_64"
}

variable "ssh_password" {
type = string
default = "PeerP0d"
Expand Down
1 change: 1 addition & 0 deletions src/cloud-api-adaptor/versions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ tools:
golang: 1.21.8
rust: 1.72.0
protoc: 3.15.0
packer: v1.9.4
# Referenced Git repositories
git:
guest-components:
Expand Down

0 comments on commit 89c644b

Please sign in to comment.