1function install_qat() { 2 if ! hash yasm; then 3 install yasm 4 fi 5 6 in_syms() { 7 local syms 8 if [[ -e /proc/kallsyms ]]; then 9 syms=/proc/kallsyms 10 elif [[ -e /boot/System.map-$kernel_ver ]]; then 11 syms=/boot/System.map-$kernel_ver 12 else 13 return 0 14 fi 15 16 grep -q "$1" "$syms" 17 } 18 19 if [[ -e /sys/module/qat_c62x ]]; then 20 sudo modprobe -r qat_c62x || : 21 fi 22 if [[ -d $GIT_REPOS/QAT ]]; then 23 sudo rm -rf "$GIT_REPOS/QAT" 24 fi 25 26 mkdir "$GIT_REPOS/QAT" 27 28 tar -C "$GIT_REPOS/QAT" -xzof - < <(wget -O- "$DRIVER_LOCATION_QAT") 29 30 if ge "$kernel_ver" 6.3.0; then 31 patch --dir="$GIT_REPOS/QAT" -p1 32 fi < "$rootdir/test/common/config/pkgdep/patches/qat/0001-iommu_map.patch" 33 34 (cd "$GIT_REPOS/QAT" && sudo ./configure --enable-icp-sriov=host && sudo make install) 35 36 if ! sudo service qat_service start; then 37 echo "failed to start the qat service. Something may be wrong with your device or package." 38 fi 39} 40 41function install_rocksdb() { 42 # Rocksdb is installed for use with the blobfs tests. 43 if [ ! -d /usr/src/rocksdb ]; then 44 git clone "${GIT_REPO_ROCKSDB}" "$GIT_REPOS/rocksdb" 45 git -C "$GIT_REPOS/rocksdb" checkout 6.15.fb 46 sudo mv "$GIT_REPOS/rocksdb" /usr/src/ 47 else 48 sudo git -C /usr/src/rocksdb checkout 6.15.fb 49 echo "rocksdb already in /usr/src. Not checking out again" 50 fi 51} 52 53function install_fio() { 54 # This version of fio is installed in /usr/src/fio to enable 55 # building the spdk fio plugin. 56 local fio_version="fio-3.35" 57 58 if [ ! -d /usr/src/fio ]; then 59 if [ ! -d fio ]; then 60 git clone "${GIT_REPO_FIO}" "$GIT_REPOS/fio" 61 sudo mv "$GIT_REPOS/fio" /usr/src/ 62 else 63 sudo mv "$GIT_REPOS/fio" /usr/src/ 64 fi 65 ( 66 git -C /usr/src/fio checkout master \ 67 && git -C /usr/src/fio pull \ 68 && git -C /usr/src/fio checkout $fio_version \ 69 && if [ $OSID == 'freebsd' ]; then 70 gmake -C /usr/src/fio -j${jobs} \ 71 && sudo gmake -C /usr/src/fio install 72 else 73 make -C /usr/src/fio -j${jobs} \ 74 && sudo make -C /usr/src/fio install 75 fi 76 ) 77 else 78 echo "fio already in /usr/src/fio. Not installing" 79 fi 80} 81 82function install_flamegraph() { 83 # Flamegraph is used when printing out timing graphs for the tests. 84 if [ ! -d /usr/local/FlameGraph ]; then 85 git clone "${GIT_REPO_FLAMEGRAPH}" "$GIT_REPOS/FlameGraph" 86 mkdir -p /usr/local 87 sudo mv "$GIT_REPOS/FlameGraph" /usr/local/FlameGraph 88 else 89 echo "flamegraph already installed. Skipping" 90 fi 91} 92 93function _install_qemu() { 94 local repo=$1 95 local branch=$2 96 local prefix=${3:-} 97 98 mkdir -p "$GIT_REPOS/qemu" 99 100 local repo_dir=$GIT_REPOS/qemu/$branch 101 if [[ -n $prefix ]]; then 102 repo_dir=$GIT_REPOS/qemu/$prefix-$branch 103 fi 104 105 if [[ ! -d $repo_dir ]]; then 106 git clone "$repo" -b "$branch" "$repo_dir" 107 else 108 echo "qemu already checked out. Skipping" 109 fi 110 111 declare -a opt_params=("--prefix=/usr/local/qemu/${repo_dir##*/}") 112 declare -a extra_cflags=() 113 114 opt_params+=("--disable-docs") 115 if ((gcc_version >= 9)); then 116 opt_params+=("--disable-glusterfs") 117 fi 118 119 extra_cflags+=("-Wno-error") 120 121 # Most tsocks proxies rely on a configuration file in /etc/tsocks.conf. 122 # If using tsocks, please make sure to complete this config before trying to build qemu. 123 if [[ $INSTALL_TSOCKS == true && $NO_TSOCKS != true ]]; then 124 if hash tsocks 2> /dev/null; then 125 opt_params+=("--with-git='tsocks git'") 126 fi 127 fi 128 opt_params+=("--extra-cflags=${extra_cflags[*]}") 129 130 if [[ $prefix == vanilla ]]; then 131 # Latest qemu seems to take sysconfdir from the prefix and instead of checking /etc 132 # it looks under /usr/local/qemu/vanilla*/bin/../etc which is a bit peculiar. Fix it. 133 opt_params+=("--sysconfdir=/etc/") 134 fi 135 136 # The qemu configure script places several output files in the CWD. 137 (cd "$repo_dir" && ./configure "${opt_params[@]}" --target-list="x86_64-softmmu" --enable-kvm --enable-linux-aio --enable-numa) 138 139 make -C "$repo_dir" -j${jobs} 140 sudo make -C "$repo_dir" install 141} 142 143function install_qemu() { 144 # Four versions of QEMU are used in the tests, three are installed 145 # directly from the source. Each QEMU is dedicated for different 146 # use-cases: 147 # - Packed QEMU: version provided by given distro. Used to boot VMs 148 # from within vhost tests. 149 # - vfio-user QEMU: A special fork to test libvfio-user components. 150 # - Vanilla QEMU: Used by the CI to boot the testing VMs. 151 152 _install_qemu $GIT_REPO_QEMU_VFIO $VFIO_QEMU_BRANCH 153 _install_qemu "$GIT_REPO_QEMU" "$VANILLA_QEMU_BRANCH" vanilla 154} 155 156function install_nvmecli() { 157 # nvme-cli >1.11.1 should be used. 158 if [[ ! -d $GIT_REPOS/nvme-cli-cuse ]]; then 159 git clone "https://github.com/linux-nvme/nvme-cli.git" "$GIT_REPOS/nvme-cli-cuse" 160 fi 161 git -C "$GIT_REPOS/nvme-cli-cuse" checkout v2.0 162 163 cflags=("-Wno-error") 164 165 make -C "$GIT_REPOS/nvme-cli-cuse" CFLAGS="${cflags[*]}" 166 if [ -d "/usr/local/src/nvme-cli" ]; then 167 sudo rm -rf /usr/local/src/nvme-cli 168 fi 169 sudo mv "$GIT_REPOS/nvme-cli-cuse" /usr/local/src/nvme-cli 170 # Make sure binary is available for the cuse tests 171 if [[ -e /usr/local/src/nvme-cli/.build/nvme ]]; then 172 sudo ln -s .build/nvme /usr/local/src/nvme-cli/ 173 fi 174} 175 176function install_libiscsi() { 177 # We currently don't make any changes to the libiscsi repository for our tests, but it is possible that we will need 178 # to later. Cloning from git is just future proofing the machines. 179 if [[ ! -d $GIT_REPOS/libiscsi ]]; then 180 git clone "${GIT_REPO_LIBISCSI}" "$GIT_REPOS/libiscsi" 181 else 182 echo "libiscsi already checked out. Skipping" 183 fi 184 (cd "$GIT_REPOS/libiscsi" && ./autogen.sh && ./configure --prefix=/usr/local/libiscsi) 185 make -C "$GIT_REPOS/libiscsi" -j${jobs} WARN_CFLAGS= 186 sudo make -C "$GIT_REPOS/libiscsi" install 187} 188 189function install_git() { 190 if type -P git; then 191 if ge "$(git --version | awk '{print $3}')" "$GIT_VERSION"; then 192 return 0 193 fi 194 fi >/dev/null 195 196 install zlib-devel curl-devel 197 tar -C "$GIT_REPOS" -xzof <(wget -qO- "$GIT_REPO_GIT") 198 (cd "$GIT_REPOS/git-$GIT_VERSION" \ 199 && make configure \ 200 && ./configure \ 201 && sudo make -j${jobs} install) 202} 203 204function install_extra_pkgs() { 205 if [[ $INSTALL_QAT == true ]]; then 206 install libudev-devel || install libudev-dev || : 207 fi 208 209 if [[ $INSTALL_QEMU == true ]]; then 210 install qemu-system-x86 qemu-img \ 211 || install qemu-system-x86 qemu-utils \ 212 || install qemu 213 214 # Install extra dependency which was removed from Qemu 7.2 source tree 215 install libslirp-devel \ 216 || install libslirp-dev 217 fi || : 218} 219 220function install_vagrant() { 221 local vagrant_version="2.2.7" 222 local vagrant_installer="vagrant_${vagrant_version}_x86_64.deb" 223 local vagrant_plugins=(vagrant-libvirt vagrant-sshfs vagrant-cachier vagrant-proxyconf) 224 225 if [[ $OSID != ubuntu ]]; then 226 echo "Currently, Vagrant installation is supported only on ubuntu" 227 return 0 228 fi 229 230 # Install vagrant and it's plugins dependencies 231 # function should be defined in pkgdep/$package_manager file 232 install_vagrant_dependencies 233 234 # Download and install vagrant 235 if hash vagrant &> /dev/null; then 236 echo "Vagrant is already installed" 237 else 238 wget "https://releases.hashicorp.com/vagrant/${vagrant_version}/${vagrant_installer}" 239 sudo dpkg -i "${vagrant_installer}" 240 fi 241 vagrant --version 242 243 # Install vagrant plugins 244 local vagrant_plugin_list 245 vagrant_plugin_list=$(vagrant plugin list) 246 247 local plugin 248 for plugin in "${vagrant_plugins[@]}"; do 249 if grep -Fq "$plugin" <<< "$vagrant_plugin_list"; then 250 echo "$plugin already installed" 251 else 252 vagrant plugin install "$plugin" 253 fi 254 done 255} 256 257function install_igb_uio() { 258 git clone "${GIT_REPO_DPDK_KMODS}" "$GIT_REPOS/dpdk-kmods" 259 260 (cd "$GIT_REPOS/dpdk-kmods/linux/igb_uio" && make -j ${jobs}) 261 sudo mkdir -p "/lib/modules/$(uname -r)/extra/dpdk" 262 sudo cp "$GIT_REPOS/dpdk-kmods/linux/igb_uio/igb_uio.ko" "/lib/modules/$(uname -r)/extra/dpdk" 263 sudo depmod 264} 265 266function install_irdma() { 267 local RDMA_CORE_VERSION=42.0 268 local RDMA_CORE=https://github.com/linux-rdma/rdma-core/releases/download/v$RDMA_CORE_VERSION/rdma-core-$RDMA_CORE_VERSION.tar.gz 269 270 if [[ $ID != fedora ]]; then 271 echo "Installation of the irdma can be attempted only on Fedora" 272 return 0 273 fi 274 275 # Install extra dependencies needed by the rdma-core 276 install ninja-build pandoc perl-generators valgrind-devel python-docutils libnl3 libnl3-devel python3-Cython 277 278 rm -rf "$GIT_REPOS/irdma-$IRDMA_VERSION" 279 rm -rf "$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION" 280 281 curl -L -o- "$IRDMA_DRIVER" | tar -C "$GIT_REPOS" -xzf - 282 [[ -e $GIT_REPOS/irdma-$IRDMA_VERSION/build.sh ]] 283 284 ( 285 cd "$GIT_REPOS/irdma-$IRDMA_VERSION" 286 sed -i "s/IRDMA_FLUSH_DELAY_MS 1500/IRDMA_FLUSH_DELAY_MS 50/" \ 287 "$GIT_REPOS/irdma-$IRDMA_VERSION/src/irdma/verbs.h" 288 "$GIT_REPOS/irdma-$IRDMA_VERSION/build.sh" 289 ) 290 291 # Fetch and build the rdma-core irdma depends on 292 curl -L -o- "$RDMA_CORE" | tar -C "$GIT_REPOS" -xzf - 293 [[ -e $GIT_REPOS/irdma-$IRDMA_VERSION/libirdma-$RDMA_CORE_VERSION.patch ]] 294 295 patch --dir="$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION" -p2 \ 296 < "$GIT_REPOS/irdma-$IRDMA_VERSION/libirdma-$RDMA_CORE_VERSION.patch" 297 298 # Note that paths and the name of the package are hardcoded into .spec, hence they need to stay like this. 299 [[ -e $GIT_REPOS/rdma-core-$RDMA_CORE_VERSION/redhat/rdma-core.spec ]] 300 mkdir -p "$HOME/rpmbuild/"{SOURCES,SPECS} 301 cp "$GIT_REPOS/rdma-core-$RDMA_CORE_VERSION/redhat/rdma-core.spec" "$HOME/rpmbuild/SPECS" 302 303 # Re-package the source 304 tar -czf "$HOME/rpmbuild/SOURCES/rdma-core-$RDMA_CORE_VERSION.tgz" -C "$GIT_REPOS" "rdma-core-$RDMA_CORE_VERSION" 305 306 # Build the rpms 307 ( 308 cd "$HOME/rpmbuild/SPECS" 309 # Make sure stock ninja-build is used 310 PATH="/usr/bin:$PATH" rpmbuild -ba rdma-core.spec 311 ) 312 313 # Now, don't install the packages since this will, most likely, conflict with packages already installed 314 # in the system. Instead, simply inform user what the next step is and note what potential issues it may 315 # have with the installation. 316 317 shopt -s nullglob 318 local rpms=("$HOME/rpmbuild/RPMS/x86_64/"*.rpm) 319 shopt -u nullglob 320 ((${#rpms[@]} > 0)) 321 322 cat <<-EOF 323 324 INFO: rdma-core-$RDMA_CORE_VERSION was successfully built, following packages are 325 available for installation: 326 327 $(printf ' - %s\n' "${rpms[@]##*/}") 328 329 Note that installing the above packages may raise conflicts with their 330 potentially newer versions already installed on the system. Dependent 331 packages may be uninstalled during the process as well. Please, run the 332 following command to finish the installation: 333 334 $package_manager install [--allowerasing] $HOME/rpmbuild/RPMS/x86_64/*.rpm 335 336 EOF 337} 338 339function install_ice() { 340 rm -rf "$GIT_REPOS/ice-$ICE_VERSION" 341 342 curl -L -o- "$ICE_DRIVER" | tar -C "$GIT_REPOS" -xzf - 343 344 if ge "$kernel_ver" 6.2.0; then 345 patch --dir="$GIT_REPOS/ice-$ICE_VERSION" -p1 346 fi < "$rootdir/test/common/config/pkgdep/patches/ice/0001-devlink-info-driver.patch" 347 348 if ge "$kernel_ver" 6.3.0; then 349 patch --dir="$GIT_REPOS/ice-$ICE_VERSION" -p1 \ 350 < "$rootdir/test/common/config/pkgdep/patches/ice/0001-devlink-set-features.patch" 351 patch --dir="$GIT_REPOS/ice-$ICE_VERSION" -p1 \ 352 < "$rootdir/test/common/config/pkgdep/patches/ice/0001-stats-fetch_*_irq.patch" 353 fi 354 355 ( 356 cd "$GIT_REPOS/ice-$ICE_VERSION/src" 357 sudo make -j"$(nproc)" install 358 ) 359} 360 361function install_lcov() { 362 local lcov_version=v1.15 363 364 rm -rf /usr/src/lcov 365 sudo git clone "$GIT_REPO_LCOV" --branch "$lcov_version" /usr/src/lcov 366 (cd /usr/src/lcov; sudo make install) 367} 368 369function install_bpftrace() { 370 local deps=() bcc_rev 371 372 deps+=(cereal-devel) 373 deps+=(clang-devel) 374 deps+=(cmake) 375 deps+=(dwarves) 376 deps+=(gmock-devel) 377 deps+=(gtest-devel) 378 deps+=(llvm-devel) 379 380 install "${deps[@]}" 381 382 rm -rf $GIT_REPOS/bpftrace 383 384 git clone $GIT_REPO_BPFTRACE $GIT_REPOS/bpftrace --recurse-submodules 385 git -C $GIT_REPOS/bpftrace checkout $BPFTRACE_VERSION 386 mkdir -p $GIT_REPOS/bpftrace/build 387 mkdir -p "$GIT_REPOS/bpftrace/build/build-libs/bcc" 388 389 if ge "$(clang -dumpversion)" 16.0.0; then 390 # Make sure LLVM-Config.cmake does not trip when it's touched through bcc's find_package() 391 # calls. Do so by manually "initializing" cmake's cache dedicated for the bcc build. The 392 # "UNDEFINED" is the type cmake would select via cmake_policy(). 393 echo "CMAKE_POLICY_DEFAULT_CMP0057:UNDEFINED=NEW" > \ 394 "$GIT_REPOS/bpftrace/build/build-libs/bcc/CMakeCache.txt" 395 396 # Make sure bpftrace builds bcc at a revision which supports llvm >= 16.0.0 397 # https://github.com/iovisor/bcc/commit/daf35cdbeaeba649509d88cf1674302affa263e3 398 git -C "$GIT_REPOS/bpftrace/bcc" checkout daf35cdbeaeba649509d88cf1674302affa263e3 399 400 # As of now, the latest bpftrace revision does not support LLVM >= 16 as it hardcodes 401 # the MAJOR version inside its CMakeLists.txt. Override it. 402 sed -i -e 's/set(MAX_LLVM_MAJOR 15)/set(MAX_LLVM_MAJOR 16)/g' \ 403 "$GIT_REPOS/bpftrace/CMakeLists.txt" 404 fi 405 406 bcc_rev=$(git -C "$GIT_REPOS/bpftrace/bcc" describe --tags --abbrev=0) bcc_rev=${bcc_rev#v} 407 echo "REVISION:STRING=$bcc_rev" >> "$GIT_REPOS/bpftrace/build/build-libs/bcc/CMakeCache.txt" 408 409 410 # Use build-libs.sh to build necessary libraries in the bpftrace tree 411 (cd $GIT_REPOS/bpftrace/build && ../build-libs.sh) 412 413 cmake \ 414 -Wno-dev \ 415 -DCMAKE_BUILD_TYPE=Release \ 416 -B "$GIT_REPOS/bpftrace/build" \ 417 -S "$GIT_REPOS/bpftrace" 418 419 make -C $GIT_REPOS/bpftrace/build -j$(nproc) 420 sudo make -C $GIT_REPOS/bpftrace/build install 421} 422 423function install_sources() { 424 if [[ $ID == centos ]] && (( VERSION_ID == 7 )); then 425 # install proper version of the git first 426 install_git 427 fi 428 429 IFS="," read -ra conf_env <<< "$CONF" 430 for conf in "${conf_env[@]}"; do 431 export "INSTALL_${conf^^}=true" 432 done 433 434 if [[ $OSID == freebsd ]]; then 435 jobs=$(($(sysctl -n hw.ncpu) * 2)) 436 else 437 jobs=$(($(nproc) * 2)) 438 sources+=( 439 install_irdma 440 install_libiscsi 441 install_nvmecli 442 install_qat 443 install_rocksdb 444 install_flamegraph 445 install_qemu 446 install_igb_uio 447 install_ice 448 install_lcov 449 install_bpftrace 450 ) 451 install_extra_pkgs 452 fi 453 sources+=(install_fio) 454 sources+=(install_vagrant) 455 456 sudo mkdir -p /usr/{,local}/src 457 sudo mkdir -p "$GIT_REPOS" 458 459 for source in "${sources[@]}"; do 460 source_conf=${source^^} 461 if [[ ${!source_conf} == true ]]; then 462 "$source" 463 fi 464 done 465} 466 467GIT_VERSION=2.25.1 468IRDMA_VERSION=1.11.16.6 469ICE_VERSION=1.11.14 470 471BPFTRACE_VERSION=${BPFTRACE_VERSION:-42d55a0} 472VFIO_QEMU_BRANCH=${VFIO_QEMU_BRANCH:-vfio-user-p3.0} 473VANILLA_QEMU_BRANCH=${VANILLA_QEMU_BRANCH:-v8.0.0} 474 475: ${GIT_REPO_ROCKSDB=https://review.spdk.io/spdk/rocksdb} 476export GIT_REPO_ROCKSDB 477: ${GIT_REPO_FIO=https://github.com/axboe/fio.git} 478export GIT_REPO_FIO 479: ${GIT_REPO_FLAMEGRAPH=https://github.com/brendangregg/FlameGraph.git} 480export GIT_REPO_FLAMEGRAPH 481: ${GIT_REPO_QEMU=https://github.com/qemu/qemu} 482export GIT_REPO_QEMU 483: ${GIT_REPO_QEMU_VFIO=https://github.com/oracle/qemu} 484export GIT_REPO_QEMU_VFIO 485: ${GIT_REPO_LIBISCSI=https://github.com/sahlberg/libiscsi} 486export GIT_REPO_LIBISCSI 487: ${DRIVER_LOCATION_QAT=https://downloadmirror.intel.com/773821/QAT.L.4.21.0-00001.tar.gz} 488export DRIVER_LOCATION_QAT 489: ${GIT_REPO_GIT=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz} 490export GIT_REPO_GIT 491: ${GIT_REPO_DPDK_KMODS=http://dpdk.org/git/dpdk-kmods} 492export GIT_REPO_DPDK_KMODS 493: ${IRDMA_DRIVER=https://downloadmirror.intel.com/763932/irdma-$IRDMA_VERSION.tgz} 494export IRDMA_DRIVER 495: ${ICE_DRIVER="https://sourceforge.net/projects/e1000/files/ice%20stable/$ICE_VERSION/ice-$ICE_VERSION.tar.gz"} 496export ICE_DRIVER 497: ${GIT_REPO_LCOV=https://github.com/linux-test-project/lcov} 498export GIT_REPO_LCOV 499: ${GIT_REPO_BCC=https://github.com/iovisor/bcc.git} 500export GIT_REPO_BCC 501: ${GIT_REPO_BPFTRACE=https://github.com/iovisor/bpftrace.git} 502export GIT_REPO_BPFTRACE 503 504GIT_REPOS=${GIT_REPOS:-$HOME} 505 506gcc_version=$(gcc -dumpversion) gcc_version=${gcc_version%%.*} 507if [[ -e /proc/sys/kernel/osrelease ]]; then 508 kernel_ver=$(< /proc/sys/kernel/osrelease) 509fi 510