From 955294ee4bb3270ea1b476b9d13585765c95defe Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Sun, 22 Oct 2023 11:57:07 +0200 Subject: [PATCH] [WIP] Proof of concept: dual-arch x86_64/aarch64 ironic image --- Dockerfile | 13 ++++++------- build-ipxe.sh | 13 +++++++++++++ ironic-config/dnsmasq.conf.j2 | 10 ++++++---- prepare-efi.sh | 8 +++++--- 4 files changed, 30 insertions(+), 14 deletions(-) create mode 100755 build-ipxe.sh diff --git a/Dockerfile b/Dockerfile index a23338edf..a2af900f1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -10,13 +10,10 @@ RUN dnf install -y gcc git make xz-devel WORKDIR /tmp -RUN git clone --depth 1 --branch v1.21.1 https://github.com/ipxe/ipxe.git && \ - cd ipxe/src && \ - ARCH=$(uname -m | sed 's/aarch/arm/') && \ - # NOTE(elfosardo): warning should not be treated as errors by default - NO_WERROR=1 make bin/undionly.kpxe "bin-$ARCH-efi/snponly.efi" - -COPY prepare-efi.sh /bin/ +RUN git clone --depth 1 --branch v1.21.1 https://github.com/ipxe/ipxe.git +RUN dnf install -y epel-release +COPY build-ipxe.sh prepare-efi.sh /bin/ +RUN build-ipxe.sh RUN prepare-efi.sh centos FROM $BASE_IMAGE @@ -44,6 +41,8 @@ COPY scripts/ /bin/ # IRONIC # COPY --from=ironic-builder /tmp/ipxe/src/bin/undionly.kpxe /tmp/ipxe/src/bin-x86_64-efi/snponly.efi /tftpboot/ +COPY --from=ironic-builder /tmp/ipxe/src/bin-x86_64-efi/snponly.efi /tftpboot/snponly-x86_64.efi +COPY --from=ironic-builder /tmp/ipxe/src/bin-arm64-efi/snponly.efi /tftpboot/snponly-aarch64.efi COPY --from=ironic-builder /tmp/esp.img /tmp/uefi_esp.img COPY ironic-config/ironic.conf.j2 /etc/ironic/ diff --git a/build-ipxe.sh b/build-ipxe.sh new file mode 100755 index 000000000..d63cc4fb7 --- /dev/null +++ b/build-ipxe.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +set -eux -o pipefail + +dnf install -y gcc-aarch64-linux-gnu gcc-x86_64-linux-gnu + +cd ipxe/src +# NOTE(elfosardo): warning should not be treated as errors by default +export NO_WERROR=1 + +CROSS_COMPILE=aarch64-linux-gnu- make bin-arm64-efi/snponly.efi +CROSS_COMPILE=x86_64-linux-gnu- make bin-x86_64-efi/snponly.efi +make bin/undionly.kpxe diff --git a/ironic-config/dnsmasq.conf.j2 b/ironic-config/dnsmasq.conf.j2 index 9d3f59259..d44e204ad 100644 --- a/ironic-config/dnsmasq.conf.j2 +++ b/ironic-config/dnsmasq.conf.j2 @@ -32,11 +32,12 @@ dhcp-match=ipxe,175 dhcp-boot=tag:ipxe,http://{{ env.IRONIC_URL_HOST }}:{{ env.HTTP_PORT }}/boot.ipxe # Note: Need to test EFI booting -dhcp-match=set:efi,option:client-arch,7 -dhcp-match=set:efi,option:client-arch,9 -dhcp-match=set:efi,option:client-arch,11 +dhcp-match=set:x86_64-efi,option:client-arch,7 +dhcp-match=set:x86_64-efi,option:client-arch,9 +dhcp-match=set:aarch64-efi,option:client-arch,11 # Client is PXE booting over EFI without iPXE ROM; send EFI version of iPXE chainloader -dhcp-boot=tag:efi,tag:!ipxe,snponly.efi +dhcp-boot=tag:x86_64-efi,tag:!ipxe,snponly-x86_64.efi +dhcp-boot=tag:aarch64-efi,tag:!ipxe,snponly-aarch64.efi # Client is running PXE over BIOS; send BIOS version of iPXE chainloader dhcp-boot=/undionly.kpxe,{{ env.IRONIC_IP }} @@ -49,6 +50,7 @@ ra-param={{ env.PROVISIONING_INTERFACE }},0,0 dhcp-vendorclass=set:pxe6,enterprise:343,PXEClient dhcp-userclass=set:ipxe6,iPXE +# TODO(dtantsur): multiarch dhcp-option=tag:pxe6,option6:bootfile-url,tftp://{{ env.IRONIC_URL_HOST }}/snponly.efi dhcp-option=tag:ipxe6,option6:bootfile-url,http://{{ env.IRONIC_URL_HOST }}:{{ env.HTTP_PORT }}/boot.ipxe diff --git a/prepare-efi.sh b/prepare-efi.sh index 574d90b9e..7e0ad1a66 100755 --- a/prepare-efi.sh +++ b/prepare-efi.sh @@ -29,7 +29,7 @@ fi # ``Cannot initialize '::'`` # This is due to the conversion table missing codepage 850, included in glibc-gconv-extra # shellcheck disable=SC2086 -dnf install -y grub2 shim dosfstools mtools glibc-gconv-extra $PACKAGES +dnf install -y grub2 shim dosfstools mtools glibc-gconv-extra grub2-efi-x64 grub2-efi-aa64 ## TODO(TheJulia): At some point we may want to try and make the size ## of the ESP image file to be sized smaller for the files that need to @@ -40,6 +40,8 @@ mkfs.msdos -F 12 -n 'ESP_IMAGE' "$DEST" mmd -i "$DEST" EFI mmd -i "$DEST" EFI/BOOT -mcopy -i "$DEST" -v "/boot/efi/EFI/BOOT/$BOOTEFI" ::EFI/BOOT -mcopy -i "$DEST" -v "/boot/efi/EFI/$OS/$GRUBEFI" ::EFI/BOOT +mcopy -i "$DEST" -v "/boot/efi/EFI/BOOT/BOOTX64.EFI" ::EFI/BOOT +mcopy -i "$DEST" -v "/boot/efi/EFI/BOOT/BOOTAA64.EFI" ::EFI/BOOT +mcopy -i "$DEST" -v "/boot/efi/EFI/$OS/grubx64.efi" ::EFI/BOOT +mcopy -i "$DEST" -v "/boot/efi/EFI/$OS/grubaa64.efi" ::EFI/BOOT mdir -i "$DEST" ::EFI/BOOT