From e8552e5b8a8854bef1dd060a2f7aff573113f076 Mon Sep 17 00:00:00 2001 From: Kun Lai Date: Thu, 17 Sep 2026 19:23:47 +0800 Subject: [PATCH] test(convert): pin QEMU guest RAM to 4G in CI test_qemu_boot() derived RAM_SIZE from 80% of the CI runner's host memory (~5.6-12.8 GB), which silently masked the UKI SizeOfImage "hole" regression: UEFI LoadImage() must allocate the full SizeOfImage (~2.93 GiB for the mis-built UKI) as contiguous memory up front, so it only fails at low memory. Add a --ram option and QEMU_RAM_SIZE env var (plumbed through the Makefile as QEMU_RAM) and pin all CI test-convert jobs to 4G so this class of regression surfaces in CI. The script default stays at host*0.8 for local development. Signed-off-by: Kun Lai Assisted-by: Claude:glm-5.2[1m] --- .github/workflows/build-rpm.yml | 2 +- Makefile | 2 +- tests/test-convert.sh | 19 +++++++++++++++++-- 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-rpm.yml b/.github/workflows/build-rpm.yml index bffbda1..8f219d6 100644 --- a/.github/workflows/build-rpm.yml +++ b/.github/workflows/build-rpm.yml @@ -290,7 +290,7 @@ jobs: - name: Run convert test run: | docker exec -w /workspace/repo test-container bash -c " - make run-convert-test-case BOOTLOADER=${{ matrix.bootloader }} ROOTFS_ENC=${{ matrix.rootfs_enc }} DELTA_LOCATION=${{ matrix.delta_location }} INPUT_IMAGE=/workspace/test-images/test-image.qcow2 CRYPTPILOT_FDE_RPM=${{ steps.install-rpm.outputs.cryptpilot_fde_rpm_container }} + make run-convert-test-case BOOTLOADER=${{ matrix.bootloader }} ROOTFS_ENC=${{ matrix.rootfs_enc }} DELTA_LOCATION=${{ matrix.delta_location }} INPUT_IMAGE=/workspace/test-images/test-image.qcow2 CRYPTPILOT_FDE_RPM=${{ steps.install-rpm.outputs.cryptpilot_fde_rpm_container }} QEMU_RAM=4G " - name: Print convert diagnostic log diff --git a/Makefile b/Makefile index 8bc2437..3aa53d6 100644 --- a/Makefile +++ b/Makefile @@ -212,7 +212,7 @@ install-convert-test-depend: .PHONY: run-convert-test-case run-convert-test-case: install-convert-test-depend - bash tests/test-convert.sh --rpm $(CRYPTPILOT_FDE_RPM) --bootloader $(BOOTLOADER) --rootfs-$(ROOTFS_ENC) --delta-location $(DELTA_LOCATION) $(if $(INPUT_IMAGE),--input $(INPUT_IMAGE),) + bash tests/test-convert.sh --rpm $(CRYPTPILOT_FDE_RPM) --bootloader $(BOOTLOADER) --rootfs-$(ROOTFS_ENC) --delta-location $(DELTA_LOCATION) $(if $(INPUT_IMAGE),--input $(INPUT_IMAGE),) $(if $(QEMU_RAM),--ram $(QEMU_RAM),) .PHONE: shellcheck shellcheck: diff --git a/tests/test-convert.sh b/tests/test-convert.sh index 58c9224..ffb7c60 100755 --- a/tests/test-convert.sh +++ b/tests/test-convert.sh @@ -8,6 +8,8 @@ # --rootfs-enc (flag) rootfs encryption enabled # --rootfs-noenc (flag) rootfs encryption disabled # --delta-location ram | disk | disk-persist +# --ram Pin QEMU guest RAM (e.g. 4G, 4096M). Defaults to +# 80% of host MemTotal. Also set via QEMU_RAM_SIZE. # # Usage: # ./tests/test-convert.sh --rpm --bootloader --rootfs-enc|--rootfs-noenc --delta-location @@ -562,7 +564,14 @@ test_qemu_boot() { local boot_log="${WORKDIR}/${test_name}-boot.log" - log::info "Starting QEMU container with UEFI boot mode" + # Pin guest RAM when --ram / QEMU_RAM_SIZE is given; otherwise fall back to + # 80% of host MemTotal (read from /proc/meminfo of this privileged runtime + # container, which reflects the CI runner's physical memory). Pinning a + # low value (e.g. 4G) is what surfaces the UKI "SizeOfImage hole" class of + # regressions, since UEFI LoadImage() must allocate SizeOfImage bytes of + # contiguous memory up front. + local ram_size="${QEMU_RAM_SIZE:-$(awk '/MemTotal/{printf "%d", $2 * 0.8 / 1024}' /proc/meminfo)}" + log::info "Starting QEMU container with UEFI boot mode (RAM_SIZE=${ram_size})" # Start QEMU container in background local container_name="qemu-test-${test_name}-$$" @@ -582,7 +591,7 @@ test_qemu_boot() { -e BOOT="" \ -e "KVM=N" \ -e "CPU_CORES=$(nproc)" \ - -e "RAM_SIZE=$(awk '/MemTotal/{printf "%d", $2 * 0.8 / 1024}' /proc/meminfo)" \ + -e "RAM_SIZE=${ram_size}" \ --entrypoint /bin/bash \ --name "${container_name}" \ ghcr.io/qemus/qemu:7.29 \ @@ -751,6 +760,8 @@ Required: Options: --input Use specified qcow2 image instead of downloading + --ram Pin QEMU guest RAM (e.g. 4G, 4096M). Defaults to 80% of + host MemTotal when not given. Overridable via QEMU_RAM_SIZE. --help Show this help message Examples: @@ -792,6 +803,10 @@ main() { custom_input="$2" shift 2 ;; + --ram) + QEMU_RAM_SIZE="$2" + shift 2 + ;; --help|-h) show_help exit 0