2023-12-15 20:33:46 +00:00
|
|
|
#!/usr/bin/env bash
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck disable=SC2048,SC2086
|
2019-05-23 15:45:13 +00:00
|
|
|
set -x
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
# shellcheck source=/dev/null
|
|
|
|
source "$HOME"/.cargo/env
|
|
|
|
source "$(dirname "$0")"/test-util.sh
|
2019-05-23 15:45:13 +00:00
|
|
|
|
|
|
|
WORKLOADS_DIR="$HOME/workloads"
|
|
|
|
mkdir -p "$WORKLOADS_DIR"
|
|
|
|
|
2020-11-18 00:37:27 +00:00
|
|
|
process_common_args "$@"
|
|
|
|
|
2022-01-06 22:36:24 +00:00
|
|
|
# For now these values are default for kvm
|
2023-06-06 19:36:36 +00:00
|
|
|
test_features=""
|
2020-11-18 00:37:27 +00:00
|
|
|
|
2024-01-26 15:30:32 +00:00
|
|
|
if [ "$hypervisor" = "mshv" ]; then
|
2023-08-04 02:33:09 +00:00
|
|
|
test_features="--features mshv"
|
2021-09-23 21:56:15 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
cp scripts/sha1sums-x86_64 "$WORKLOADS_DIR"
|
2020-03-03 08:48:32 +00:00
|
|
|
|
2023-11-07 13:42:55 +00:00
|
|
|
download_hypervisor_fw
|
2019-05-23 15:45:13 +00:00
|
|
|
|
2024-01-18 18:50:11 +00:00
|
|
|
download_ovmf
|
2021-12-06 17:45:17 +00:00
|
|
|
|
2021-06-09 08:35:51 +00:00
|
|
|
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.qcow2"
|
2024-02-28 09:51:10 +00:00
|
|
|
FOCAL_OS_IMAGE_URL="https://ch-images.azureedge.net/$FOCAL_OS_IMAGE_NAME"
|
2020-04-23 09:14:43 +00:00
|
|
|
FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME"
|
|
|
|
if [ ! -f "$FOCAL_OS_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2020-04-23 09:14:43 +00:00
|
|
|
time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2019-10-01 15:57:41 +00:00
|
|
|
fi
|
|
|
|
|
2021-06-09 08:35:51 +00:00
|
|
|
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0.raw"
|
2020-04-23 09:14:43 +00:00
|
|
|
FOCAL_OS_RAW_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_RAW_IMAGE_NAME"
|
|
|
|
if [ ! -f "$FOCAL_OS_RAW_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2020-04-23 09:14:43 +00:00
|
|
|
time qemu-img convert -p -f qcow2 -O raw $FOCAL_OS_IMAGE_NAME $FOCAL_OS_RAW_IMAGE_NAME || exit 1
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2019-10-01 15:57:41 +00:00
|
|
|
fi
|
|
|
|
|
2023-07-05 07:14:38 +00:00
|
|
|
FOCAL_OS_QCOW_BACKING_FILE_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210609-0-backing.qcow2"
|
|
|
|
FOCAL_OS_QCOW_BACKING_FILE_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_QCOW_BACKING_FILE_IMAGE_NAME"
|
|
|
|
if [ ! -f "$FOCAL_OS_QCOW_BACKING_FILE_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
|
|
|
time qemu-img create -f qcow2 -b "$FOCAL_OS_IMAGE" -F qcow2 $FOCAL_OS_QCOW_BACKING_FILE_IMAGE_NAME
|
|
|
|
popd || exit
|
2023-07-05 07:14:38 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-19 17:33:06 +00:00
|
|
|
JAMMY_OS_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20230119-0.qcow2"
|
2024-02-28 09:51:10 +00:00
|
|
|
JAMMY_OS_IMAGE_URL="https://ch-images.azureedge.net/$JAMMY_OS_IMAGE_NAME"
|
2022-03-28 21:17:43 +00:00
|
|
|
JAMMY_OS_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_IMAGE_NAME"
|
|
|
|
if [ ! -f "$JAMMY_OS_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2022-03-28 21:17:43 +00:00
|
|
|
time wget --quiet $JAMMY_OS_IMAGE_URL || exit 1
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2022-03-28 21:17:43 +00:00
|
|
|
fi
|
|
|
|
|
2023-01-19 17:33:06 +00:00
|
|
|
JAMMY_OS_RAW_IMAGE_NAME="jammy-server-cloudimg-amd64-custom-20230119-0.raw"
|
2022-03-28 21:17:43 +00:00
|
|
|
JAMMY_OS_RAW_IMAGE="$WORKLOADS_DIR/$JAMMY_OS_RAW_IMAGE_NAME"
|
|
|
|
if [ ! -f "$JAMMY_OS_RAW_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2022-03-28 21:17:43 +00:00
|
|
|
time qemu-img convert -p -f qcow2 -O raw $JAMMY_OS_IMAGE_NAME $JAMMY_OS_RAW_IMAGE_NAME || exit 1
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2022-03-28 21:17:43 +00:00
|
|
|
fi
|
|
|
|
|
2020-03-22 23:38:00 +00:00
|
|
|
ALPINE_MINIROOTFS_URL="http://dl-cdn.alpinelinux.org/alpine/v3.11/releases/x86_64/alpine-minirootfs-3.11.3-x86_64.tar.gz"
|
|
|
|
ALPINE_MINIROOTFS_TARBALL="$WORKLOADS_DIR/alpine-minirootfs-x86_64.tar.gz"
|
|
|
|
if [ ! -f "$ALPINE_MINIROOTFS_TARBALL" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
|
|
|
time wget --quiet $ALPINE_MINIROOTFS_URL -O "$ALPINE_MINIROOTFS_TARBALL" || exit 1
|
|
|
|
popd || exit
|
2020-03-22 23:38:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
ALPINE_INITRAMFS_IMAGE="$WORKLOADS_DIR/alpine_initramfs.img"
|
|
|
|
if [ ! -f "$ALPINE_INITRAMFS_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2020-03-22 23:38:00 +00:00
|
|
|
mkdir alpine-minirootfs
|
|
|
|
tar xf "$ALPINE_MINIROOTFS_TARBALL" -C alpine-minirootfs
|
2024-01-26 15:30:32 +00:00
|
|
|
cat >alpine-minirootfs/init <<-EOF
|
2020-03-22 23:38:00 +00:00
|
|
|
#! /bin/sh
|
|
|
|
mount -t devtmpfs dev /dev
|
|
|
|
echo \$TEST_STRING > /dev/console
|
|
|
|
poweroff -f
|
|
|
|
EOF
|
|
|
|
chmod +x alpine-minirootfs/init
|
2024-01-29 15:38:44 +00:00
|
|
|
cd alpine-minirootfs || exit
|
2020-03-22 23:38:00 +00:00
|
|
|
find . -print0 |
|
2024-01-26 15:30:32 +00:00
|
|
|
cpio --null --create --verbose --owner root:root --format=newc >"$ALPINE_INITRAMFS_IMAGE"
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2020-03-22 23:38:00 +00:00
|
|
|
fi
|
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
|
|
|
if ! sha1sum sha1sums-x86_64 --check; then
|
2020-01-23 15:35:00 +00:00
|
|
|
echo "sha1sum validation of images failed, remove invalid images to fix the issue."
|
|
|
|
exit 1
|
|
|
|
fi
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2019-10-01 15:57:41 +00:00
|
|
|
|
2019-07-16 10:12:53 +00:00
|
|
|
# Build custom kernel based on virtio-pmem and virtio-fs upstream patches
|
2019-06-10 14:02:53 +00:00
|
|
|
VMLINUX_IMAGE="$WORKLOADS_DIR/vmlinux"
|
2022-11-01 10:30:40 +00:00
|
|
|
if [ ! -f "$VMLINUX_IMAGE" ]; then
|
|
|
|
build_custom_linux
|
|
|
|
fi
|
2020-03-11 05:11:15 +00:00
|
|
|
|
2022-02-21 10:00:34 +00:00
|
|
|
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
|
|
|
|
VIRTIOFSD_DIR="virtiofsd_build"
|
|
|
|
if [ ! -f "$VIRTIOFSD" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
2022-02-21 10:00:34 +00:00
|
|
|
git clone "https://gitlab.com/virtio-fs/virtiofsd.git" $VIRTIOFSD_DIR
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd $VIRTIOFSD_DIR || exit
|
2023-10-23 12:54:13 +00:00
|
|
|
git checkout v1.8.0
|
2020-11-27 15:04:01 +00:00
|
|
|
time cargo build --release
|
2024-01-29 15:38:44 +00:00
|
|
|
cp target/release/virtiofsd "$VIRTIOFSD" || exit 1
|
|
|
|
popd || exit
|
2022-02-21 10:00:34 +00:00
|
|
|
rm -rf $VIRTIOFSD_DIR
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2020-11-27 15:04:01 +00:00
|
|
|
fi
|
|
|
|
|
2019-09-18 20:23:02 +00:00
|
|
|
BLK_IMAGE="$WORKLOADS_DIR/blk.img"
|
|
|
|
MNT_DIR="mount_image"
|
|
|
|
if [ ! -f "$BLK_IMAGE" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
pushd "$WORKLOADS_DIR" || exit
|
|
|
|
fallocate -l 16M "$BLK_IMAGE"
|
|
|
|
mkfs.ext4 -j "$BLK_IMAGE"
|
2024-01-26 15:30:32 +00:00
|
|
|
mkdir $MNT_DIR
|
2024-01-29 15:38:44 +00:00
|
|
|
sudo mount -t ext4 "$BLK_IMAGE" $MNT_DIR
|
2024-01-26 15:30:32 +00:00
|
|
|
sudo bash -c "echo bar > $MNT_DIR/foo" || exit 1
|
2024-01-29 15:38:44 +00:00
|
|
|
sudo umount "$BLK_IMAGE"
|
2024-01-26 15:30:32 +00:00
|
|
|
rm -r $MNT_DIR
|
2024-01-29 15:38:44 +00:00
|
|
|
popd || exit
|
2019-09-18 02:47:33 +00:00
|
|
|
fi
|
|
|
|
|
2019-06-15 00:41:13 +00:00
|
|
|
SHARED_DIR="$WORKLOADS_DIR/shared_dir"
|
|
|
|
if [ ! -d "$SHARED_DIR" ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
mkdir -p "$SHARED_DIR"
|
2024-01-26 15:30:32 +00:00
|
|
|
echo "foo" >"$SHARED_DIR/file1"
|
|
|
|
echo "bar" >"$SHARED_DIR/file3" || exit 1
|
2019-06-15 00:41:13 +00:00
|
|
|
fi
|
2019-06-10 14:02:53 +00:00
|
|
|
|
2019-07-19 08:26:13 +00:00
|
|
|
VFIO_DIR="$WORKLOADS_DIR/vfio"
|
2020-08-11 15:52:56 +00:00
|
|
|
VFIO_DISK_IMAGE="$WORKLOADS_DIR/vfio.img"
|
2024-01-29 15:38:44 +00:00
|
|
|
rm -rf "$VFIO_DIR" "$VFIO_DISK_IMAGE"
|
|
|
|
mkdir -p "$VFIO_DIR"
|
|
|
|
cp "$FOCAL_OS_RAW_IMAGE" "$VFIO_DIR"
|
|
|
|
cp "$FW" "$VFIO_DIR"
|
|
|
|
cp "$VMLINUX_IMAGE" "$VFIO_DIR" || exit 1
|
2019-07-19 08:26:13 +00:00
|
|
|
|
2024-01-29 15:38:44 +00:00
|
|
|
cargo build --features mshv --all --release --target "$BUILD_TARGET"
|
2020-05-07 09:35:57 +00:00
|
|
|
|
2019-07-19 08:26:13 +00:00
|
|
|
# We always copy a fresh version of our binary for our L2 guest.
|
2024-01-29 15:38:44 +00:00
|
|
|
cp target/"$BUILD_TARGET"/release/cloud-hypervisor "$VFIO_DIR"
|
|
|
|
cp target/"$BUILD_TARGET"/release/ch-remote "$VFIO_DIR"
|
2019-07-19 08:26:13 +00:00
|
|
|
|
2019-11-20 04:34:42 +00:00
|
|
|
# Enable KSM with some reasonable parameters so that it won't take too long
|
|
|
|
# for the memory to be merged between two processes.
|
2019-12-20 13:06:09 +00:00
|
|
|
sudo bash -c "echo 1000000 > /sys/kernel/mm/ksm/pages_to_scan"
|
2019-11-20 04:34:42 +00:00
|
|
|
sudo bash -c "echo 10 > /sys/kernel/mm/ksm/sleep_millisecs"
|
|
|
|
sudo bash -c "echo 1 > /sys/kernel/mm/ksm/run"
|
|
|
|
|
2022-03-15 17:02:11 +00:00
|
|
|
# Both test_vfio, ovs-dpdk and vDPA tests rely on hugepages
|
2024-01-26 15:30:32 +00:00
|
|
|
HUGEPAGESIZE=$(grep Hugepagesize /proc/meminfo | awk '{print $2}')
|
2024-01-29 15:38:44 +00:00
|
|
|
PAGE_NUM=$((12288 * 1024 / HUGEPAGESIZE))
|
|
|
|
echo "$PAGE_NUM" | sudo tee /proc/sys/vm/nr_hugepages
|
2020-02-13 14:32:24 +00:00
|
|
|
sudo chmod a+rwX /dev/hugepages
|
|
|
|
|
2022-03-15 17:02:11 +00:00
|
|
|
# Update max locked memory to 'unlimited' to avoid issues with vDPA
|
|
|
|
ulimit -l unlimited
|
|
|
|
|
2023-07-31 14:15:21 +00:00
|
|
|
# Set number of open descriptors high enough for VFIO tests to run
|
|
|
|
ulimit -n 4096
|
|
|
|
|
2019-08-16 15:08:16 +00:00
|
|
|
export RUST_BACKTRACE=1
|
2022-11-24 13:06:53 +00:00
|
|
|
time cargo test $test_features "common_parallel::$test_filter" -- ${test_binary_args[*]}
|
2019-08-07 08:36:37 +00:00
|
|
|
RES=$?
|
2019-07-19 08:26:13 +00:00
|
|
|
|
2020-07-03 08:00:12 +00:00
|
|
|
# Run some tests in sequence since the result could be affected by other tests
|
|
|
|
# running in parallel.
|
|
|
|
if [ $RES -eq 0 ]; then
|
2020-10-07 09:01:58 +00:00
|
|
|
export RUST_BACKTRACE=1
|
2022-11-24 13:06:53 +00:00
|
|
|
time cargo test $test_features "common_sequential::$test_filter" -- --test-threads=1 ${test_binary_args[*]}
|
2020-07-03 08:00:12 +00:00
|
|
|
RES=$?
|
|
|
|
fi
|
|
|
|
|
2023-06-06 19:36:36 +00:00
|
|
|
# Run tests on dbus_api
|
|
|
|
if [ $RES -eq 0 ]; then
|
2024-01-29 15:38:44 +00:00
|
|
|
cargo build --features "mshv,dbus_api" --all --release --target "$BUILD_TARGET"
|
2023-06-06 19:36:36 +00:00
|
|
|
export RUST_BACKTRACE=1
|
|
|
|
# integration tests now do not reply on build feature "dbus_api"
|
|
|
|
time cargo test $test_features "dbus_api::$test_filter" -- ${test_binary_args[*]}
|
|
|
|
RES=$?
|
|
|
|
fi
|
|
|
|
|
2019-08-07 08:36:37 +00:00
|
|
|
exit $RES
|