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