From 1897f31f81d756fa0c6938a3c01f962eaf64c5c8 Mon Sep 17 00:00:00 2001 From: Billy Olsen Date: Fri, 19 Mar 2021 15:45:05 -0700 Subject: [PATCH] Fix aarch64/arm64 support for MicroStack Fix the builds for MicroStack on aarch64/arm64. To resolve the build issues, the SNAP_ARCH and SNAP_ARCH_TRIPLET variables need to be used in appropriate places to reference the underlying platform rather than the x86_64 platform. Arm64/Aarch64 support requires that EFI support is enabled, which involves adding the EFI packages for arm64. These are also included for x86_64 for ensuring consistency in EFI support between the architectures. The /usr/share/{OVMF,AAVMF} paths need to be bind-mounted to the appropriate locations to avoid having to custom build the packages within the snap. The setup sequence also needs to consider loading the right image into glance. This is done by using the platform to determine which cirros image to import into glance. A new cirros image was not included in this patch for aarch64 platform in order to keep the snap image size lower. The setup sequence has fallback code to attempt to download the image if it is unavailable in the filesystem. Finally, the snapcraft architectures for building microstack are limited to the x86_64 and arm64 platforms. There's no need to build on s390x or other architectures at this point. Change-Id: I26625621fb9895027139ecb895e882e60f2e6502 --- snapcraft.yaml | 41 ++++++++++++++------------- tools/init/init/questions/__init__.py | 5 +++- 2 files changed, 25 insertions(+), 21 deletions(-) diff --git a/snapcraft.yaml b/snapcraft.yaml index d3cedd5..f23926b 100644 --- a/snapcraft.yaml +++ b/snapcraft.yaml @@ -15,7 +15,12 @@ environment: PYTHONPATH: $PYTHONPATH:/usr/lib/python3.8:/usr/lib/python3/dist-packages:$SNAP/usr/lib/python3.8:$SNAP/lib/python3.8/site-packages:$SNAP/usr/lib/python3/dist-packages PYTHONWARNINGS: ignore # Needed by a targetcli dependency. - GI_TYPELIB_PATH: $SNAP/usr/lib/x86_64-linux-gnu/girepository-1.0 + GI_TYPELIB_PATH: $SNAP/usr/lib/$SNAP_ARCH-linux-gnu/girepository-1.0 + +architectures: + - build-on: + - amd64 + - arm64 system-usernames: snap_daemon: shared @@ -35,6 +40,12 @@ layout: bind: $SNAP/usr/share/libvirt /usr/share/qemu: bind: $SNAP/usr/share/qemu + # For UEFI Support, bindmount the OVMF and AAVMF directories + # appropriately. UEFI support is required for aarch64. + /usr/share/OVMF: + bind: $SNAP/usr/share/OVMF + /usr/share/AAVMF: + bind: $SNAP/usr/share/AAVMF # Keystone really wants to look here for its fernet keys for some reason /etc/keystone/fernet-keys: bind: $SNAP_COMMON/fernet-keys @@ -738,20 +749,6 @@ parts: # patch --batch --forward --strip 1 --input ../project/patches/nova/nova_log_error.patch organize: lib/python3.8/site-packages/openstack_dashboard/local/local_settings.py.example: lib/python3.8/site-packages/openstack_dashboard/local/local_settings.py - override-build: | - snapcraftctl build - rm $SNAPCRAFT_PART_INSTALL/pyvenv.cfg - --strip 1 \ - --input "$patch" - echo - done - # Now that everything is built, let's disable user site-packages - # as stated in PEP-0370 - # sed -i usr/lib/python3.8/site.py -e 's/^ENABLE_USER_SITE = None$/ENABLE_USER_SITE = False/' - # Uncomment the below line for better python-libvirt debugging output. - # patch --batch --forward --strip 1 --input ../project/patches/nova/nova_log_error.patch - organize: - lib/python3.8/site-packages/openstack_dashboard/local/local_settings.py.example: lib/python3.8/site-packages/openstack_dashboard/local/local_settings.py override-build: | snapcraftctl build rm $SNAPCRAFT_PART_INSTALL/pyvenv.cfg @@ -771,7 +768,6 @@ parts: etc/*.ini: etc/keystone/ etc/*.json: etc/keystone/ etc/*.templates: etc/keystone/ - filesets: etc: - etc/keystone/* @@ -1087,6 +1083,12 @@ parts: - librtmp1 - libssh-4 - libwind0-heimdal + # UEFI Support, required on arm64 + - on arm64: + - qemu-efi-aarch64 + - qemu-efi-arm + - on amd64: + - ovmf build-packages: - acpica-tools - libaio-dev @@ -1130,7 +1132,7 @@ parts: - --disable-bsd-user - --disable-vhost-user - --enable-system - - --target-list=x86_64-softmmu + - --target-list=x86_64-softmmu,aarch64-softmmu - --disable-xen override-build: | dpkg-source --before-build . @@ -1239,7 +1241,7 @@ parts: # for the child processes they spawn since the environment variables are not passed down to children by default after execve(2). # `readelf -d /snap/microstack/current/usr/libexec/virt-aa-helper` should return something like: # (RUNPATH) Library runpath: [/snap/microstack/current/usr/lib:/snap/microstack/current/usr/lib/x86_64-linux-gnu:...] - - LDFLAGS: '$LDFLAGS -Wl,-rpath=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib -Wl,-rpath=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/x86_64-linux-gnu -Wl,-rpath=/snap/$SNAPCRAFT_PROJECT_NAME/current/lib -Wl,-rpath=/lib/x86_64-linux-gnu -Wl,-rpath=/lib/' + - LDFLAGS: '$LDFLAGS -Wl,-rpath=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib -Wl,-rpath=/snap/$SNAPCRAFT_PROJECT_NAME/current/usr/lib/$SNAPCRAFT_ARCH_TRIPLET -Wl,-rpath=/snap/$SNAPCRAFT_PROJECT_NAME/current/lib -Wl,-rpath=/lib/$SNAPCRAFT_ARCH_TRIPLET -Wl,-rpath=/lib/' override-build: | dpkg-source --before-build . logger `echo -n $PWD` @@ -1441,7 +1443,7 @@ parts: # see LP: #1882994 rm $SNAPCRAFT_PART_INSTALL/bin/python3 rm $SNAPCRAFT_PART_INSTALL/bin/python - rm $SNAPCRAFT_PART_INSTALL/lib/python3.8/site-packages/netifaces.cpython-38-x86_64-linux-gnu.so + rm $SNAPCRAFT_PART_INSTALL/lib/python3.8/site-packages/netifaces.cpython-38-$SNAPCRAFT_ARCH_TRIPLET.so # Launch script launch: @@ -1557,7 +1559,6 @@ parts: lma-build-prep: plugin: nil - source: "" build-packages: - dirmngr override-build: | diff --git a/tools/init/init/questions/__init__.py b/tools/init/init/questions/__init__.py index 7b2555d..88e6ab0 100644 --- a/tools/init/init/questions/__init__.py +++ b/tools/init/init/questions/__init__.py @@ -24,6 +24,8 @@ limitations under the License. """ import json +import platform + from time import sleep from os import path @@ -828,7 +830,8 @@ class GlanceSetup(Question): env = dict(**_env) env['VER'] = '0.4.0' - env['IMG'] = 'cirros-{VER}-x86_64-disk.img'.format(**env) + env['ARCH'] = platform.machine() + env['IMG'] = 'cirros-{VER}-{ARCH}-disk.img'.format(**env) cirros_path = '{SNAP_COMMON}/images/{IMG}'.format(**env)