2019-05-23 15:45:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
set -x
|
|
|
|
|
|
|
|
source $HOME/.cargo/env
|
2020-11-18 00:37:27 +00:00
|
|
|
source $(dirname "$0")/test-util.sh
|
2019-05-23 15:45:13 +00:00
|
|
|
|
2020-04-21 06:02:58 +00:00
|
|
|
export BUILD_TARGET=${BUILD_TARGET-x86_64-unknown-linux-gnu}
|
|
|
|
|
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 "$@"
|
|
|
|
|
|
|
|
# For now these values are deafult for kvm
|
|
|
|
features_build=""
|
|
|
|
features_test="--features integration_tests"
|
|
|
|
|
2020-06-17 07:43:10 +00:00
|
|
|
cp scripts/sha1sums-x86_64 $WORKLOADS_DIR
|
2020-03-03 08:48:32 +00:00
|
|
|
|
2019-11-21 10:05:30 +00:00
|
|
|
FW_URL=$(curl --silent https://api.github.com/repos/cloud-hypervisor/rust-hypervisor-firmware/releases/latest | grep "browser_download_url" | grep -o 'https://.*[^ "]')
|
2019-05-23 15:45:13 +00:00
|
|
|
FW="$WORKLOADS_DIR/hypervisor-fw"
|
|
|
|
if [ ! -f "$FW" ]; then
|
|
|
|
pushd $WORKLOADS_DIR
|
2020-03-05 14:42:40 +00:00
|
|
|
time wget --quiet $FW_URL || exit 1
|
2019-05-23 15:45:13 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-06-30 16:59:25 +00:00
|
|
|
BIONIC_OS_IMAGE_NAME="bionic-server-cloudimg-amd64.qcow2"
|
2019-08-15 17:27:14 +00:00
|
|
|
BIONIC_OS_IMAGE_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$BIONIC_OS_IMAGE_NAME"
|
2019-07-30 16:41:05 +00:00
|
|
|
BIONIC_OS_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_IMAGE_NAME"
|
|
|
|
if [ ! -f "$BIONIC_OS_IMAGE" ]; then
|
|
|
|
pushd $WORKLOADS_DIR
|
2020-03-05 14:42:40 +00:00
|
|
|
time wget --quiet $BIONIC_OS_IMAGE_URL || exit 1
|
2019-07-30 16:41:05 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-06-30 16:59:25 +00:00
|
|
|
BIONIC_OS_RAW_IMAGE_NAME="bionic-server-cloudimg-amd64.raw"
|
2019-07-30 16:41:05 +00:00
|
|
|
BIONIC_OS_RAW_IMAGE="$WORKLOADS_DIR/$BIONIC_OS_RAW_IMAGE_NAME"
|
|
|
|
if [ ! -f "$BIONIC_OS_RAW_IMAGE" ]; then
|
|
|
|
pushd $WORKLOADS_DIR
|
2020-03-05 14:42:40 +00:00
|
|
|
time qemu-img convert -p -f qcow2 -O raw $BIONIC_OS_IMAGE_NAME $BIONIC_OS_RAW_IMAGE_NAME || exit 1
|
2019-06-20 20:26:11 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2019-07-16 10:12:53 +00:00
|
|
|
|
2021-04-07 08:43:39 +00:00
|
|
|
FOCAL_OS_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210407-0.qcow2"
|
2020-04-23 09:14:43 +00:00
|
|
|
FOCAL_OS_IMAGE_URL="https://cloudhypervisorstorage.blob.core.windows.net/images/$FOCAL_OS_IMAGE_NAME"
|
|
|
|
FOCAL_OS_IMAGE="$WORKLOADS_DIR/$FOCAL_OS_IMAGE_NAME"
|
|
|
|
if [ ! -f "$FOCAL_OS_IMAGE" ]; then
|
2019-10-01 15:57:41 +00:00
|
|
|
pushd $WORKLOADS_DIR
|
2020-04-23 09:14:43 +00:00
|
|
|
time wget --quiet $FOCAL_OS_IMAGE_URL || exit 1
|
2019-10-01 15:57:41 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2021-04-07 08:43:39 +00:00
|
|
|
FOCAL_OS_RAW_IMAGE_NAME="focal-server-cloudimg-amd64-custom-20210407-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
|
2019-10-01 15:57:41 +00:00
|
|
|
pushd $WORKLOADS_DIR
|
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
|
2019-10-01 15:57:41 +00:00
|
|
|
popd
|
|
|
|
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
|
|
|
|
pushd $WORKLOADS_DIR
|
|
|
|
time wget --quiet $ALPINE_MINIROOTFS_URL -O $ALPINE_MINIROOTFS_TARBALL || exit 1
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
ALPINE_INITRAMFS_IMAGE="$WORKLOADS_DIR/alpine_initramfs.img"
|
|
|
|
if [ ! -f "$ALPINE_INITRAMFS_IMAGE" ]; then
|
|
|
|
pushd $WORKLOADS_DIR
|
|
|
|
mkdir alpine-minirootfs
|
|
|
|
tar xf "$ALPINE_MINIROOTFS_TARBALL" -C alpine-minirootfs
|
|
|
|
cat > alpine-minirootfs/init <<-EOF
|
|
|
|
#! /bin/sh
|
|
|
|
mount -t devtmpfs dev /dev
|
|
|
|
echo \$TEST_STRING > /dev/console
|
|
|
|
poweroff -f
|
|
|
|
EOF
|
|
|
|
chmod +x alpine-minirootfs/init
|
|
|
|
cd alpine-minirootfs
|
|
|
|
find . -print0 |
|
|
|
|
cpio --null --create --verbose --owner root:root --format=newc > "$ALPINE_INITRAMFS_IMAGE"
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2020-01-23 15:35:00 +00:00
|
|
|
pushd $WORKLOADS_DIR
|
2020-06-17 07:43:10 +00:00
|
|
|
sha1sum sha1sums-x86_64 --check
|
2020-01-23 15:35:00 +00:00
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "sha1sum validation of images failed, remove invalid images to fix the issue."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
popd
|
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"
|
|
|
|
|
2020-03-11 05:11:15 +00:00
|
|
|
LINUX_CUSTOM_DIR="$WORKLOADS_DIR/linux-custom"
|
2019-06-15 00:41:13 +00:00
|
|
|
|
2021-04-28 07:38:27 +00:00
|
|
|
if [ ! -f "$VMLINUX_IMAGE" ]; then
|
2019-06-15 00:41:13 +00:00
|
|
|
SRCDIR=$PWD
|
|
|
|
pushd $WORKLOADS_DIR
|
2021-04-27 07:39:46 +00:00
|
|
|
time git clone --depth 1 "https://github.com/cloud-hypervisor/linux.git" -b "ch-5.12" $LINUX_CUSTOM_DIR
|
2020-06-17 07:43:10 +00:00
|
|
|
cp $SRCDIR/resources/linux-config-x86_64 $LINUX_CUSTOM_DIR/.config
|
2020-03-11 05:11:15 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$VMLINUX_IMAGE" ]; then
|
2019-06-15 00:41:13 +00:00
|
|
|
pushd $LINUX_CUSTOM_DIR
|
2019-12-13 12:39:14 +00:00
|
|
|
time make bzImage -j `nproc`
|
2020-03-05 14:42:40 +00:00
|
|
|
cp vmlinux $VMLINUX_IMAGE || exit 1
|
2019-06-15 00:41:13 +00:00
|
|
|
popd
|
2020-03-11 05:11:15 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$LINUX_CUSTOM_DIR" ]; then
|
|
|
|
rm -rf $LINUX_CUSTOM_DIR
|
|
|
|
fi
|
|
|
|
|
2021-05-07 08:35:55 +00:00
|
|
|
VIRTIOFSD="$WORKLOADS_DIR/virtiofsd"
|
|
|
|
QEMU_DIR="qemu_build"
|
|
|
|
if [ ! -f "$VIRTIOFSD" ]; then
|
|
|
|
pushd $WORKLOADS_DIR
|
|
|
|
git clone --depth 1 "https://gitlab.com/virtio-fs/qemu.git" -b "qemu5.0-virtiofs-dax" $QEMU_DIR
|
|
|
|
pushd $QEMU_DIR
|
|
|
|
time ./configure --prefix=$PWD --target-list=x86_64-softmmu
|
|
|
|
time make virtiofsd -j `nproc`
|
|
|
|
cp virtiofsd $VIRTIOFSD || exit 1
|
|
|
|
popd
|
|
|
|
rm -rf $QEMU_DIR
|
|
|
|
popd
|
|
|
|
fi
|
2019-06-15 00:41:13 +00:00
|
|
|
|
2020-11-27 15:04:01 +00:00
|
|
|
VIRTIOFSD_RS="$WORKLOADS_DIR/virtiofsd-rs"
|
|
|
|
VIRTIOFSD_RS_DIR="virtiofsd_rs_build"
|
|
|
|
if [ ! -f "$VIRTIOFSD_RS" ]; then
|
|
|
|
pushd $WORKLOADS_DIR
|
|
|
|
git clone --depth 1 "https://gitlab.com/virtio-fs/virtiofsd-rs.git" $VIRTIOFSD_RS_DIR
|
|
|
|
pushd $VIRTIOFSD_RS_DIR
|
|
|
|
time cargo build --release
|
|
|
|
cp target/release/virtiofsd-rs $VIRTIOFSD_RS || exit 1
|
|
|
|
popd
|
|
|
|
rm -rf $VIRTIOFSD_RS_DIR
|
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
2019-09-18 20:23:02 +00:00
|
|
|
BLK_IMAGE="$WORKLOADS_DIR/blk.img"
|
|
|
|
MNT_DIR="mount_image"
|
|
|
|
if [ ! -f "$BLK_IMAGE" ]; then
|
2019-09-18 02:47:33 +00:00
|
|
|
pushd $WORKLOADS_DIR
|
2019-09-18 20:23:02 +00:00
|
|
|
fallocate -l 16M $BLK_IMAGE
|
|
|
|
mkfs.ext4 -j $BLK_IMAGE
|
|
|
|
mkdir $MNT_DIR
|
|
|
|
sudo mount -t ext4 $BLK_IMAGE $MNT_DIR
|
2020-03-05 14:42:40 +00:00
|
|
|
sudo bash -c "echo bar > $MNT_DIR/foo" || exit 1
|
2019-09-18 20:23:02 +00:00
|
|
|
sudo umount $BLK_IMAGE
|
|
|
|
rm -r $MNT_DIR
|
2019-09-18 02:47:33 +00:00
|
|
|
popd
|
|
|
|
fi
|
|
|
|
|
2019-06-15 00:41:13 +00:00
|
|
|
SHARED_DIR="$WORKLOADS_DIR/shared_dir"
|
|
|
|
if [ ! -d "$SHARED_DIR" ]; then
|
|
|
|
mkdir -p $SHARED_DIR
|
|
|
|
echo "foo" > "$SHARED_DIR/file1"
|
2020-03-05 14:42:40 +00:00
|
|
|
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"
|
|
|
|
rm -rf $VFIO_DIR $VFIO_DISK_IMAGE
|
2020-02-13 15:26:35 +00:00
|
|
|
mkdir -p $VFIO_DIR
|
2020-06-30 16:59:25 +00:00
|
|
|
cp $FOCAL_OS_IMAGE $VFIO_DIR
|
2020-02-13 15:26:35 +00:00
|
|
|
cp $FW $VFIO_DIR
|
2020-03-05 14:42:40 +00:00
|
|
|
cp $VMLINUX_IMAGE $VFIO_DIR || exit 1
|
2019-07-19 08:26:13 +00:00
|
|
|
|
2020-06-10 08:45:12 +00:00
|
|
|
BUILD_TARGET="$(uname -m)-unknown-linux-${CH_LIBC}"
|
|
|
|
CFLAGS=""
|
|
|
|
TARGET_CC=""
|
2020-06-10 14:14:51 +00:00
|
|
|
if [[ "${BUILD_TARGET}" == "x86_64-unknown-linux-musl" ]]; then
|
2020-06-10 08:45:12 +00:00
|
|
|
TARGET_CC="musl-gcc"
|
|
|
|
CFLAGS="-I /usr/include/x86_64-linux-musl/ -idirafter /usr/include/"
|
|
|
|
fi
|
2020-06-05 13:54:37 +00:00
|
|
|
|
2020-11-18 00:37:27 +00:00
|
|
|
cargo build --all --release $features_build --target $BUILD_TARGET
|
2020-05-07 09:35:57 +00:00
|
|
|
strip target/$BUILD_TARGET/release/cloud-hypervisor
|
|
|
|
strip target/$BUILD_TARGET/release/vhost_user_net
|
|
|
|
strip target/$BUILD_TARGET/release/ch-remote
|
|
|
|
|
2019-07-19 08:26:13 +00:00
|
|
|
# We always copy a fresh version of our binary for our L2 guest.
|
2020-04-21 06:02:58 +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"
|
|
|
|
|
2020-02-13 14:32:24 +00:00
|
|
|
# test_vfio relies on hugepages
|
|
|
|
echo 4096 | sudo tee /proc/sys/vm/nr_hugepages
|
|
|
|
sudo chmod a+rwX /dev/hugepages
|
|
|
|
|
2019-08-16 15:08:16 +00:00
|
|
|
export RUST_BACKTRACE=1
|
2021-01-25 15:55:34 +00:00
|
|
|
time cargo test $features_test "tests::parallel::$test_filter"
|
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
|
2021-01-25 15:55:34 +00:00
|
|
|
time cargo test $features_test "tests::sequential::$test_filter" -- --test-threads=1
|
2020-07-03 08:00:12 +00:00
|
|
|
RES=$?
|
|
|
|
fi
|
|
|
|
|
2019-08-07 08:36:37 +00:00
|
|
|
exit $RES
|