1function install_spdk() { 2 mkdir -p "$GIT_REPOS/spdk_repo/output" || echo "Can not create spdk_repo/output directory." 3 4 if [[ -d $GIT_REPOS/spdk_repo/spdk ]]; then 5 echo "spdk source already present, not cloning" 6 else 7 git -C "$GIT_REPOS/spdk_repo" clone "${GIT_REPO_SPDK}" 8 fi 9 git -C "$GIT_REPOS/spdk_repo/spdk" config submodule.dpdk.url "${GIT_REPO_DPDK}" 10 git -C "$GIT_REPOS/spdk_repo/spdk" config submodule.intel-ipsec-mb.url "${GIT_REPO_INTEL_IPSEC_MB}" 11 git -C "$GIT_REPOS/spdk_repo/spdk" submodule update --init --recursive 12} 13 14function install_refspdk() { 15 local release 16 local output_dir 17 local config_params 18 local rootdir 19 local version 20 21 version=$1 22 23 # Create a reference SPDK build for ABI tests 24 git -C "$GIT_REPOS/spdk_repo/spdk" fetch --tags --force 25 26 if [[ "$version" == "latest" ]]; then 27 release=$(git -C "$GIT_REPOS/spdk_repo/spdk" tag | sort --version-sort | grep -v rc | tail -n 1) 28 output_dir="$GIT_REPOS/spdk_abi_latest" 29 elif [[ "$version" == "LTS" ]]; then 30 release=$(git -C "$GIT_REPOS/spdk_repo/spdk" describe LTS) 31 output_dir="$GIT_REPOS/spdk_abi_lts" 32 fi 33 34 rm -rf "$output_dir" 35 36 if [[ ! -d $output_dir ]]; then 37 cp -R "$GIT_REPOS/spdk_repo/spdk" "$output_dir" 38 fi 39 40 lts_2001_fallback=false 41 if [[ "$release" == v20.01* ]]; then 42 # We switch to a .x branch in order to slurp all the backports which fix spdk_abi_lts 43 # build for this particular release. Fetch the branch explicitly as in case of our CI, 44 # jenkins will set remote.*.fetch to a particular ref the build run against, so plain 45 # git fetch won't include any branches from the repo. FIXME: This could be removed 46 # after new LTS is in place. 47 release=${release%%-*}.x 48 git -C "$output_dir" fetch origin "+refs/heads/$release:refs/heads/$release" 49 lts_2001_fallback=true 50 fi 51 git -C "$output_dir" checkout "$release" 52 git -C "$output_dir" submodule update --init 53 54 if [[ "$release" == v20.01* ]]; then 55 makefiles=( 56 "$output_dir/dpdk/drivers/crypto/aesni_gcm/Makefile" 57 "$output_dir/dpdk/drivers/crypto/aesni_mb/Makefile" 58 "$output_dir/dpdk/drivers/crypto/kasumi/Makefile" 59 "$output_dir/dpdk/drivers/crypto/snow3g/Makefile" 60 ) 61 # Attempt to replicate dpdk's 2a860943b8 commit which fixes builds under make 4.3 62 # FIXME: Remove this when LTS changes! 63 for makefile in "${makefiles[@]}"; do 64 # This sed call is meant to be compatible with its FreeBSD implementation 65 echo "$(sed -e 's/\\#/\$H/g' -e '/IMB_HDR =/i\ 66 H := \\#' "$makefile")" > "$makefile" 67 done 68 fi 69 cat > $HOME/autorun-spdk.conf <<- EOF 70 SPDK_BUILD_SHARED_OBJECT=1 71 SPDK_TEST_AUTOBUILD=1 72 SPDK_TEST_UNITTEST=1 73 SPDK_TEST_BLOCKDEV=1 74 SPDK_TEST_PMDK=1 75 SPDK_TEST_ISAL=1 76 SPDK_TEST_REDUCE=1 77 SPDK_TEST_CRYPTO=1 78 SPDK_TEST_FTL=1 79 SPDK_TEST_OCF=1 80 SPDK_TEST_RAID5=1 81 SPDK_TEST_RBD=1 82 SPDK_RUN_ASAN=1 83 SPDK_RUN_UBSAN=1 84 SPDK_TEST_NVME_CUSE=1 85 SPDK_TEST_BLOBFS=1 86 SPDK_TEST_URING=1 87 EOF 88 89 mkdir -p $HOME/output 90 91 ( 92 rootdir="$output_dir" 93 source $HOME/autorun-spdk.conf 94 source $output_dir/test/common/autotest_common.sh 95 96 # Prepare separate, fixed, cmdline for the FreeBSD, Issue #1397. 97 if [[ $OSID == freebsd ]]; then 98 config_params="--enable-debug --enable-werror" 99 config_params+=" --without-isal --with-fio=/usr/src/fio" 100 101 # TODO: Remove this if-block after 21.01 LTS is released and 20.01 LTS is deprecated. 102 if ! "$lts_2001_fallback"; then 103 config_params+=" --with-idxd --disable-unit-tests" 104 fi 105 106 MAKE=gmake 107 else 108 # TODO: "get_config_params" was not available in 20.01 LTS release. 109 # Remove this if-block after 21.01 release. 110 if "$lts_2001_fallback"; then 111 config_params="--enable-debug --enable-werror --with-rdma" 112 config_params+=" --with-fio=/usr/src/fio --with-iscsi-initiator" 113 config_params+=" --with-nvme-cuse --with-pmdk --with-reduce" 114 config_params+=" --with-rbd --with-crypto --with-ocf --enable-ubsan" 115 config_params+=" --enable-asan --with-fuse --with-uring" 116 else 117 config_params="$(get_config_params)" 118 fi 119 fi 120 $output_dir/configure $(echo $config_params | sed 's/--enable-coverage//g') 121 if [[ $OSID != freebsd ]]; then 122 $MAKE -C $output_dir $MAKEFLAGS include/spdk/config.h 123 CONFIG_OCF_PATH="$output_dir/ocf" $MAKE -C $output_dir/lib/env_ocf $MAKEFLAGS exportlib O=$output_dir/build/ocf.a 124 $output_dir/configure $config_params --with-ocf=$output_dir/build/ocf.a --with-shared 125 fi 126 $MAKE -C $output_dir $MAKEFLAGS 127 ) 128} 129 130function install_qat() { 131 # Disect the kernel version into maj, min, release and local version 132 local kernel_maj kernel_min kernel_rel kernel_loc 133 local kernel_ver 134 135 in_syms() { 136 local syms 137 if [[ -e /proc/kallsyms ]]; then 138 syms=/proc/kallsyms 139 elif [[ -e /boot/System.map-$(< /proc/sys/kernel/osrelease) ]]; then 140 syms=/boot/System.map-$(< /proc/sys/kernel/osrelease) 141 else 142 return 0 143 fi 144 145 grep -q "$1" "$syms" 146 } 147 148 IFS=".-" read -r kernel_{maj,min,rel,loc} < /proc/sys/kernel/osrelease 149 kernel_ver=$((kernel_maj << 16 | kernel_min << 8 | kernel_rel)) 150 151 if [[ -e /sys/module/qat_c62x ]]; then 152 sudo modprobe -r qat_c62x || : 153 fi 154 if [[ -d $GIT_REPOS/QAT ]]; then 155 sudo rm -rf "$GIT_REPOS/QAT" 156 fi 157 158 mkdir "$GIT_REPOS/QAT" 159 160 tar -C "$GIT_REPOS/QAT" -xzof - < <(wget -O- "$DRIVER_LOCATION_QAT") 161 162 # Patch use of hidden types in kernels >= 5.6.3. See .patch for details 163 if ((kernel_ver >= 0x050603)); then 164 # Patch only the driver version that was tested 165 [[ ${DRIVER_LOCATION_QAT##*/} == qat1.7.l.4.9.0-00008.tar.gz ]] && patch --dir="$GIT_REPOS/QAT" -p1 166 fi < "$rootdir/test/common/config/pkgdep/patches/qat/0001-timespec.patch" 167 168 # Patch name of the pci_aer function which was renamed in kernels >= 5.7.1. See .patch for details 169 if ((kernel_ver >= 0x050701)) || ! in_syms pci_cleanup_aer_uncorrect_error_status; then 170 # Patch only the driver version that was tested 171 [[ ${DRIVER_LOCATION_QAT##*/} == qat1.7.l.4.9.0-00008.tar.gz ]] && patch --dir="$GIT_REPOS/QAT" -p1 172 fi < "$rootdir/test/common/config/pkgdep/patches/qat/0001-pci_aer.patch" 173 174 # Patch use of cryptohash.h which was removed in favor of crypto/sha.h in kernels >= 5.8. See .patch for details 175 if ((kernel_ver >= 0x050800)); then 176 # Patch only the driver version that was tested 177 [[ ${DRIVER_LOCATION_QAT##*/} == qat1.7.l.4.9.0-00008.tar.gz ]] && patch --dir="$GIT_REPOS/QAT" -p1 178 fi < "$rootdir/test/common/config/pkgdep/patches/qat/0001-cryptohash.patch" 179 180 (cd "$GIT_REPOS/QAT" && sudo ./configure --enable-icp-sriov=host && sudo make install) 181 182 if ! sudo service qat_service start; then 183 echo "failed to start the qat service. Something may be wrong with your device or package." 184 fi 185} 186 187function install_rocksdb() { 188 # Rocksdb is installed for use with the blobfs tests. 189 if [ ! -d /usr/src/rocksdb ]; then 190 git clone "${GIT_REPO_ROCKSDB}" "$GIT_REPOS/rocksdb" 191 git -C "$GIT_REPOS/rocksdb" checkout spdk-v5.6.1 192 sudo mv "$GIT_REPOS/rocksdb" /usr/src/ 193 else 194 sudo git -C /usr/src/rocksdb checkout spdk-v5.6.1 195 echo "rocksdb already in /usr/src. Not checking out again" 196 fi 197} 198 199function install_fio() { 200 # This version of fio is installed in /usr/src/fio to enable 201 # building the spdk fio plugin. 202 local fio_version="fio-3.19" 203 204 if [ ! -d /usr/src/fio ]; then 205 if [ ! -d fio ]; then 206 git clone "${GIT_REPO_FIO}" "$GIT_REPOS/fio" 207 sudo mv "$GIT_REPOS/fio" /usr/src/ 208 else 209 sudo mv "$GIT_REPOS/fio" /usr/src/ 210 fi 211 ( 212 git -C /usr/src/fio checkout master \ 213 && git -C /usr/src/fio pull \ 214 && git -C /usr/src/fio checkout $fio_version \ 215 && if [ $OSID == 'freebsd' ]; then 216 gmake -C /usr/src/fio -j${jobs} \ 217 && sudo gmake -C /usr/src/fio install 218 else 219 make -C /usr/src/fio -j${jobs} \ 220 && sudo make -C /usr/src/fio install 221 fi 222 ) 223 else 224 echo "fio already in /usr/src/fio. Not installing" 225 fi 226} 227 228function install_flamegraph() { 229 # Flamegraph is used when printing out timing graphs for the tests. 230 if [ ! -d /usr/local/FlameGraph ]; then 231 git clone "${GIT_REPO_FLAMEGRAPH}" "$GIT_REPOS/FlameGraph" 232 mkdir -p /usr/local 233 sudo mv "$GIT_REPOS/FlameGraph" /usr/local/FlameGraph 234 else 235 echo "flamegraph already installed. Skipping" 236 fi 237} 238 239function install_qemu() { 240 # Two versions of QEMU are used in the tests. 241 # Stock QEMU is used for vhost. A special fork 242 # is used to test OCSSDs. Install both. 243 244 # Forked QEMU 245 SPDK_QEMU_BRANCH=spdk-5.0.0 246 mkdir -p "$GIT_REPOS/qemu" 247 if [[ ! -d $GIT_REPOS/qemu/$SPDK_QEMU_BRANCH ]]; then 248 git clone "${GIT_REPO_QEMU}" -b "$SPDK_QEMU_BRANCH" "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH" 249 else 250 echo "qemu already checked out. Skipping" 251 fi 252 253 declare -a opt_params=("--prefix=/usr/local/qemu/$SPDK_QEMU_BRANCH") 254 declare -a extra_cflags=() 255 256 opt_params+=("--disable-docs") 257 if ((gcc_version >= 9)); then 258 # GCC 9 fails to compile Qemu due to some old warnings which were not detected by older versions. 259 extra_cflags+=("-Wno-error=stringop-truncation" "-Wno-error=deprecated-declarations") 260 extra_cflags+=("-Wno-error=incompatible-pointer-types" "-Wno-error=format-truncation") 261 extra_cflags+=("-Wno-error=address-of-packed-member") 262 opt_params+=("--disable-glusterfs") 263 fi 264 265 # Most tsocks proxies rely on a configuration file in /etc/tsocks.conf. 266 # If using tsocks, please make sure to complete this config before trying to build qemu. 267 if [[ $INSTALL_TSOCKS == true && $NO_TSOCKS != true ]]; then 268 if hash tsocks 2> /dev/null; then 269 opt_params+=("--with-git='tsocks git'") 270 fi 271 fi 272 opt_params+=("--extra-cflags=${extra_cflags[*]}") 273 274 sed -i s@git://git.qemu.org/@https://github.com/qemu/@g "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH/.gitmodules" 275 sed -i s@git://git.qemu.org/@https://github.com/qemu/@g "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH/.git/config" 276 sed -i s@git://git.qemu-project.org/@https://github.com/qemu/@g "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH/.gitmodules" 277 sed -i s@git://git.qemu-project.org/@https://github.com/qemu/@g "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH/.git/config" 278 # The qemu configure script places several output files in the CWD. 279 (cd "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH" && ./configure "${opt_params[@]}" --target-list="x86_64-softmmu" --enable-kvm --enable-linux-aio --enable-numa) 280 281 make -C "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH" -j${jobs} 282 sudo make -C "$GIT_REPOS/qemu/$SPDK_QEMU_BRANCH" install 283} 284 285function install_nvmecli() { 286 if [ ! -d "/usr/local/src/nvme-cli" ]; then 287 # Changes required for SPDK are already merged on top of 288 # nvme-cli, however not released yet. 289 # Support for SPDK should be released in nvme-cli >1.11.1 290 if [[ ! -d $GIT_REPOS/nvme-cli-cuse ]]; then 291 git clone "https://github.com/linux-nvme/nvme-cli.git" "$GIT_REPOS/nvme-cli-cuse" 292 fi 293 git -C "$GIT_REPOS/nvme-cli-cuse" checkout "e770466615096a6d41f038a28819b00bc3078e1d" 294 make -C "$GIT_REPOS/nvme-cli-cuse" CPPFLAGS="-Wno-error=maybe-uninitialized" 295 sudo mv "$GIT_REPOS/nvme-cli-cuse" /usr/local/src/nvme-cli 296 fi 297} 298 299function install_libiscsi() { 300 # We currently don't make any changes to the libiscsi repository for our tests, but it is possible that we will need 301 # to later. Cloning from git is just future proofing the machines. 302 if [[ ! -d $GIT_REPOS/libiscsi ]]; then 303 git clone "${GIT_REPO_LIBISCSI}" "$GIT_REPOS/libiscsi" 304 else 305 echo "libiscsi already checked out. Skipping" 306 fi 307 (cd "$GIT_REPOS/libiscsi" && ./autogen.sh && ./configure --prefix=/usr/local/libiscsi) 308 make -C "$GIT_REPOS/libiscsi" -j${jobs} WARN_CFLAGS= 309 sudo make -C "$GIT_REPOS/libiscsi" install 310} 311 312function install_git() { 313 if type -P git; then 314 if ge "$(git --version | awk '{print $3}')" "$GIT_VERSION"; then 315 return 0 316 fi 317 fi >/dev/null 318 319 install zlib-devel curl-devel 320 tar -C "$GIT_REPOS" -xzof <(wget -qO- "$GIT_REPO_GIT") 321 (cd "$GIT_REPOS/git-$GIT_VERSION" \ 322 && make configure \ 323 && ./configure --prefix=/usr/local/git \ 324 && sudo make -j${jobs} install) 325 sudo sh -c "echo 'export PATH=/usr/local/git/bin:$PATH' >> /etc/bashrc" 326 export "PATH=/usr/local/git/bin:$PATH" 327 # Be nice for vagrant-proxyconf setup 328 mkdir -p "/usr/local/git/etc" 329} 330 331function install_extra_pkgs() { 332 if [[ $INSTALL_QAT == true ]]; then 333 install libudev-devel || install libudev-dev || : 334 fi 335 336 if [[ $INSTALL_QEMU == true ]]; then 337 install qemu-system-x86 qemu-img \ 338 || install qemu-system-x86 qemu-utils \ 339 || install qemu \ 340 || : 341 fi 342} 343 344function install_vagrant() { 345 local vagrant_version="2.2.7" 346 local vagrant_installer="vagrant_${vagrant_version}_x86_64.deb" 347 local vagrant_plugins=(vagrant-libvirt vagrant-sshfs vagrant-cachier vagrant-proxyconf) 348 349 if [[ $OSID != ubuntu ]]; then 350 echo "Currently, Vagrant installation is supported only on ubuntu" 351 return 0 352 fi 353 354 # Install vagrant and it's plugins dependencies 355 # function should be defined in pkgdep/$package_manager file 356 install_vagrant_dependencies 357 358 # Download and install vagrant 359 if hash vagrant &> /dev/null; then 360 echo "Vagrant is already installed" 361 else 362 wget "https://releases.hashicorp.com/vagrant/${vagrant_version}/${vagrant_installer}" 363 sudo dpkg -i "${vagrant_installer}" 364 fi 365 vagrant --version 366 367 # Install vagrant plugins 368 local vagrant_plugin_list 369 vagrant_plugin_list=$(vagrant plugin list) 370 371 local plugin 372 for plugin in "${vagrant_plugins[@]}"; do 373 if grep -Fq "$plugin" <<< "$vagrant_plugin_list"; then 374 echo "$plugin already installed" 375 else 376 vagrant plugin install "$plugin" 377 fi 378 done 379} 380 381GIT_VERSION=2.25.1 382: ${GIT_REPO_SPDK=https://github.com/spdk/spdk.git} 383export GIT_REPO_SPDK 384: ${GIT_REPO_DPDK=https://github.com/spdk/dpdk.git} 385export GIT_REPO_DPDK 386: ${GIT_REPO_ROCKSDB=https://review.spdk.io/spdk/rocksdb} 387export GIT_REPO_ROCKSDB 388: ${GIT_REPO_FIO=https://github.com/axboe/fio.git} 389export GIT_REPO_FIO 390: ${GIT_REPO_FLAMEGRAPH=https://github.com/brendangregg/FlameGraph.git} 391export GIT_REPO_FLAMEGRAPH 392: ${GIT_REPO_QEMU=https://github.com/spdk/qemu} 393export GIT_REPO_QEMU 394: ${GIT_REPO_LIBISCSI=https://github.com/sahlberg/libiscsi} 395export GIT_REPO_LIBISCSI 396: ${GIT_REPO_INTEL_IPSEC_MB=https://github.com/spdk/intel-ipsec-mb.git} 397export GIT_REPO_INTEL_IPSEC_MB 398: ${DRIVER_LOCATION_QAT=https://01.org/sites/default/files/downloads//qat1.7.l.4.9.0-00008.tar.gz} 399export DRIVER_LOCATION_QAT 400: ${GIT_REPO_GIT=https://github.com/git/git/archive/v${GIT_VERSION}.tar.gz} 401export GIT_REPO_GIT 402GIT_REPOS=${GIT_REPOS:-$HOME} 403 404gcc_version=$(gcc -dumpversion) gcc_version=${gcc_version%%.*} 405if [[ $ID == centos ]] && (( VERSION_ID == 7 )); then 406 # install proper version of the git first 407 install_git 408fi 409 410IFS="," read -ra conf_env <<< "$CONF" 411for conf in "${conf_env[@]}"; do 412 export "INSTALL_${conf^^}=true" 413done 414 415if [[ $OSID == freebsd ]]; then 416 jobs=$(($(sysctl -n hw.ncpu) * 2)) 417else 418 jobs=$(($(nproc) * 2)) 419 sources+=( 420 install_libiscsi 421 install_nvmecli 422 install_qat 423 install_rocksdb 424 install_flamegraph 425 install_qemu 426 ) 427 install_extra_pkgs 428fi 429sources+=(install_fio) 430sources+=(install_vagrant) 431sources+=(install_spdk) 432 433sudo mkdir -p /usr/{,local}/src 434sudo mkdir -p "$GIT_REPOS" 435 436for source in "${sources[@]}"; do 437 source_conf=${source^^} 438 if [[ ${!source_conf} == true ]]; then 439 "$source" 440 fi 441done 442 443if [[ $INSTALL_REFSPDK == true ]]; then 444 # Serialize builds as refspdk depends on spdk 445 [[ $INSTALL_SPDK != true ]] && install_spdk 446 install_refspdk latest 447 install_refspdk LTS 448fi 449