1#!/bin/bash 2set -x 3 4source $HOME/.cargo/env 5source $(dirname "$0")/test-util.sh 6 7export TEST_ARCH=$(uname -m) 8export BUILD_TARGET=${BUILD_TARGET-${TEST_ARCH}-unknown-linux-gnu} 9 10 11WORKLOADS_DIR="$HOME/workloads" 12mkdir -p "$WORKLOADS_DIR" 13 14build_fio() { 15 FIO_DIR="$WORKLOADS_DIR/fio_build" 16 FIO_REPO="https://github.com/axboe/fio.git" 17 18 checkout_repo "$FIO_DIR" "$FIO_REPO" master "1953e1adb5a28ed21370e85991d7f5c3cdc699f3" 19 if [ ! -f "$FIO_DIR/.built" ]; then 20 pushd $FIO_DIR 21 ./configure 22 make -j `nproc` 23 cp fio "$WORKLOADS_DIR/fio" 24 touch .built 25 popd 26 fi 27} 28 29process_common_args "$@" 30 31cp scripts/sha1sums-${TEST_ARCH} $WORKLOADS_DIR 32 33if [ ${TEST_ARCH} == "aarch64" ]; then 34 FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-arm64-custom-20210929-0.qcow2" 35else 36 FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.qcow2" 37fi 38 39FOCAL_OS_IMAGE_URL="https://cloud-hypervisor.azureedge.net/$FOCAL_OS_IMAGE_NAME" 40FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME" 41if [ ! -f "$FOCAL_OS_IMAGE" ]; then 42 pushd $WORKLOADS_DIR 43 time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1 44 popd 45fi 46 47if [ ${TEST_ARCH} == "aarch64" ]; then 48 FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-arm64-custom-20210929-0.raw" 49else 50 FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw" 51fi 52 53FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME" 54if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then 55 pushd $WORKLOADS_DIR 56 time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1 57 popd 58fi 59 60pushd $WORKLOADS_DIR 61grep focal sha1sums-${TEST_ARCH} | sha1sum --check 62if [ $? -ne 0 ]; then 63 echo "sha1sum validation of images failed, remove invalid images to fix the issue." 64 exit 1 65fi 66popd 67 68if [ ${TEST_ARCH} == "aarch64" ]; then 69 build_fio 70 71 # Update the fio in the cloud image to use io_uring on AArch64 72 FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME="focal-server-cloudimg-arm64-custom-20210929-0-update-tool.raw" 73 cp "$FOCAL_OS_RAW_IMAGE" "$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME" 74 FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR="$WORKLOADS_DIR/focal-server-cloudimg-root" 75 if [ ! -d "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" ]; then 76 mkdir -p "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" 77 fi 78 # Mount the 'raw' image, replace the fio and umount the working folder 79 guestmount -a "$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_NAME" -m /dev/sda1 "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" || exit 1 80 cp "$WORKLOADS_DIR"/fio "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR"/usr/bin/fio 81 guestunmount "$FOCAL_OS_RAW_IMAGE_UPDATE_TOOL_ROOT_DIR" 82fi 83 84# Build custom kernel based on virtio-pmem and virtio-fs upstream patches 85build_custom_linux 86 87BUILD_TARGET="${TEST_ARCH}-unknown-linux-${CH_LIBC}" 88CFLAGS="" 89TARGET_CC="" 90if [[ "${BUILD_TARGET}" == "${TEST_ARCH}-unknown-linux-musl" ]]; then 91 TARGET_CC="musl-gcc" 92 CFLAGS="-I /usr/include/${TEST_ARCH}-linux-musl/ -idirafter /usr/include/" 93fi 94 95cargo build --no-default-features --features "kvm,mshv" --all --release --target $BUILD_TARGET 96 97# setup hugepages 98echo 6144 | sudo tee /proc/sys/vm/nr_hugepages 99sudo chmod a+rwX /dev/hugepages 100 101if [ -n "$test_filter" ]; then 102 test_binary_args+=("--test-filter $test_filter") 103fi 104 105# Ensure that git commands can be run in this directory (for metrics report) 106git config --global --add safe.directory $PWD 107 108export RUST_BACKTRACE=1 109time target/$BUILD_TARGET/release/performance-metrics ${test_binary_args[*]} 110RES=$? 111 112exit $RES 113