Skip to content

Commit

Permalink
podvm-mkosi: refine podvm-mkosi s390x se image build logical
Browse files Browse the repository at this point in the history
- Update podvm-mkosi s390x podvm image build logical
- Use `SE_BOOT=true` to enable se image build
- support push fedora s390x-se image

Signed-off-by: Da Li Liu <liudali@cn.ibm.com>
  • Loading branch information
liudalibj committed Jul 29, 2024
1 parent af5f446 commit 44cecf6
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 13 deletions.
2 changes: 2 additions & 0 deletions src/cloud-api-adaptor/hack/build-s390x-se-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,7 @@ qemu-nbd --disconnect "${tmp_nbd}"

output_img_name="podvm-s390x-se.qcow2"
qemu-img convert -O qcow2 -c "${tmp_img_path}" "${output_img_name}"
output_img_path=$(realpath "${output_img_name}")
echo "podvm se-image is generated: ${output_img_path}"

popd
47 changes: 37 additions & 10 deletions src/cloud-api-adaptor/podvm-mkosi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ../Makefile.defaults
ATTESTER ?= none
ARCH ?= $(subst x86_64,amd64,$(shell uname -m))
BUILDER = fedora-binaries-builder-$(ARCH)
SEDEBUG ?= false
SE_BOOT ?= false
IS_DEBIAN := $(shell if grep -q 'ID_LIKE=debian' /etc/os-release; then echo "true"; else echo "false"; fi)

REGISTRY ?= quay.io/confidential-containers
Expand Down Expand Up @@ -64,10 +64,26 @@ image:
rm -rf resources/build*Image
rm -rf ./build
@echo "Building image..."
ifeq ($(ARCH),s390x)
ifeq ($(SE_BOOT),true)
touch resources/buildS390xImage
sudo mkosi --profile production.conf --image system
sudo -E ../hack/build-s390x-se-image.sh
@echo "Building docker image..."
docker buildx build \
-t $(PODVM_NAME)-se:$(PODVM_TAG) \
-t $(PODVM_NAME)-se:latest \
--load \
-f ../podvm/Dockerfile.podvm.fedora .
else ifeq ($(ARCH),s390x)
touch resources/buildS390xImage
sudo mkosi --profile production.conf --image system
sudo -E ../hack/build-s390x-image.sh
@echo "Building docker image..."
docker buildx build \
-t $(PODVM_NAME):$(PODVM_TAG) \
-t $(PODVM_NAME):latest \
--load \
-f ../podvm/Dockerfile.podvm.fedora .
else
touch resources/buildBootableImage
nix develop ..#podvm-mkosi --command mkosi --environment=VARIANT_ID=production
Expand All @@ -80,14 +96,26 @@ image-debug:
touch resources/buildDebugImage
rm -rf ./build
@echo "Building debug image..."
ifeq ($(SEDEBUG),true)
ifeq ($(SE_BOOT),true)
touch resources/buildS390xImage
sudo mkosi --profile debug.conf
sudo -E ../hack/build-s390x-se-image.sh
@echo "Building docker image..."
docker buildx build \
-t $(PODVM_NAME)-se:$(PODVM_TAG) \
-t $(PODVM_NAME)-se:latest \
--load \
-f ../podvm/Dockerfile.podvm.fedora .
else ifeq ($(ARCH),s390x)
touch resources/buildS390xImage
sudo mkosi --profile debug.conf
sudo -E ../hack/build-s390x-image.sh
@echo "Building docker image..."
docker buildx build \
-t $(PODVM_NAME):$(PODVM_TAG) \
-t $(PODVM_NAME):latest \
--load \
-f ../podvm/Dockerfile.podvm.fedora .
else
touch resources/buildBootableImage
nix develop ..#podvm-mkosi --command mkosi --environment=VARIANT_ID=debug
Expand All @@ -101,16 +129,15 @@ image-container:
-t $(PODVM_CONTAINER_NAME):latest \
-f Dockerfile.podvm .


PHONY: push-image
push-image:
@echo "Push podvm image to remote repository..."
ifeq ($(ARCH),s390x)
docker buildx build \
-t $(PODVM_NAME):$(PODVM_TAG) \
-t $(PODVM_NAME):latest \
--load \
-f ../podvm/Dockerfile.podvm.fedora .
ifeq ($(SE_BOOT),true)
docker push $(PODVM_NAME)-se:$(PODVM_TAG)
docker push $(PODVM_NAME)-se:latest
else
docker push $(PODVM_NAME):$(PODVM_TAG)
docker push $(PODVM_NAME):latest
endif

PHONY: push-image-container
Expand Down
3 changes: 2 additions & 1 deletion src/cloud-api-adaptor/podvm-mkosi/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ It requires a **s390x host** to build s390x image with make commands:
make fedora-binaries-builder
ATTESTER=se-attester make binaries
make image
# SE_BOOT=true make image
# make image-debug
# SEDEBUG=true make image-debug
# SE_BOOT=true make image-debug
```

The final output is `build/podvm-s390x.qcow2` or `build/podvm-s390x-se.qcow2`, which can be used as the Pod VM image in libvirt environment.
2 changes: 1 addition & 1 deletion src/cloud-api-adaptor/podvm/Dockerfile.podvm.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ ARG ARCH=s390x

ENV ARCH=${ARCH}

COPY build/podvm-${ARCH}.qcow2 /
COPY build/podvm-*.qcow2 /
10 changes: 9 additions & 1 deletion src/cloud-api-adaptor/podvm/hack/download-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,16 @@ fi

[ -z "$container_binary" ] && error "please install docker or podman"

# Check if the image name includes "podvm-generic-fedora-s390x-se"
# The "podvm-generic-fedora-s390x-se" docker image is built on s390x host, so here must use s390x platform
if [[ "$image" == *"podvm-generic-fedora-s390x-se"* ]]; then
platform="s390x"
else
platform="amd64"
fi

# Create a non-running container to extract image
$container_binary create --platform=amd64 --name "$container_name" "$image" /bin/sh >/dev/null 2>&1;
$container_binary create --platform="$platform" --name "$container_name" "$image" /bin/sh >/dev/null 2>&1;
# Destory container after use
rm-container(){
$container_binary rm -f "$container_name" >/dev/null 2>&1;
Expand Down

0 comments on commit 44cecf6

Please sign in to comment.