From 7fe1b36a3627ea9b3deddcbc6eca113e1c034912 Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Mon, 30 Mar 2020 12:15:36 +0200 Subject: [PATCH] scripts/vagrant: select tool for synced folders In order to have all the boxes fully functional we need to select the proper tool for synced folders. FreeBSD boxes fail to set proxy properly via vagrant- proxyconf plugin, so they fail to install rsync and sshfs clients. NFS is pre-installed so we can use it. Other boxes, like generic/fedora*, have issues using NFS so we need to use sshfs/rsync instead. Change-Id: Ic191b5a80dbd43479943c1739971abdff39baf41 Signed-off-by: Karol Latecki Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1581 Tested-by: SPDK CI Jenkins Reviewed-by: Tomasz Zawadzki Reviewed-by: Jim Harris --- scripts/vagrant/Vagrantfile | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index f02942f9f..48f6fee11 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -38,6 +38,18 @@ Vagrant.configure(2) do |config| # Pick the right distro and bootstrap, default is fedora30 distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "fedora30") provider = (ENV['SPDK_VAGRANT_PROVIDER'] || "virtualbox") + + # generic/freebsd boxes do not work properly with vagrant-proxyconf and + # have issues installing rsync and sshfs for syncing files. NFS is + # pre-installed, so use it. + # generic/fedora boxes on the other hand have problems running NFS + # service so use sshfs+rsync combo instead. + plugins_sync_backend = {type: :sshfs} + files_sync_backend = {type: "rsync", rsync__auto: false} + if distro.include? "freebsd" + plugins_sync_backend = {type: :nfs, nfs_udp: false} + files_sync_backend = {type: :nfs, nfs_udp: false, mount_options: ['ro']} + end config.vm.box = checkboxtype(distro) config.vm.box_check_update = false @@ -65,6 +77,7 @@ Vagrant.configure(2) do |config| # if Vagrant.has_plugin?("vagrant-cachier") config.cache.scope = :box + config.cache.synced_folder_opts = plugins_sync_backend end # use http proxy if avaiable @@ -90,6 +103,21 @@ Vagrant.configure(2) do |config| end end + # freebsd boxes in order to have spdk sources synced from host properly + # will use NFS with "ro" option enabled to prevent changes on host filesystem. + # To make sources usable in the guest VM we need to unmount them and use + # local copy. + if distro.include?("freebsd") + $freebsd_spdk_repo = <<-SCRIPT + sudo -s + cp -R /home/vagrant/spdk_repo/spdk /tmp/spdk + umount /home/vagrant/spdk_repo/spdk && rm -rf /home/vagrant/spdk_repo/spdk + mv /tmp/spdk /home/vagrant/spdk_repo/spdk + chown -R vagrant:vagrant /home/vagrant/spdk_repo/spdk + SCRIPT + config.vm.provision "shell", inline: $freebsd_spdk_repo + end + vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2) vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096) spdk_dir=(ENV['SPDK_DIR'] || "none") @@ -191,13 +219,13 @@ Vagrant.configure(2) do |config| # rsync the spdk directory if provision hasn't happened yet # Warning: rsync does not work with freebsd boxes, so this step is disabled - if ENV['COPY_SPDK_DIR'] == "1" && spdk_dir != "none" && !distro.include?("freebsd") - config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", owner: "vagrant", group: "vagrant", type: "rsync", rsync__auto: false + if ENV['COPY_SPDK_DIR'] == "1" && spdk_dir != "none" + config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", files_sync_backend end # rsync artifacts from build if ENV['COPY_SPDK_ARTIFACTS'] == "1" - config.vm.synced_folder "#{vagrantfile_dir}", "/home/vagrant/spdk_repo/output", type: "sshfs" + config.vm.synced_folder "#{vagrantfile_dir}/output", "/home/vagrant/spdk_repo/output", plugins_sync_backend end # provision the vm with all of the necessary spdk dependencies for running the autorun.sh tests @@ -211,6 +239,6 @@ Vagrant.configure(2) do |config| # Copy in the user's tools if they exists if File.directory?(File.expand_path("~/vagrant_tools")) - config.vm.synced_folder "~/vagrant_tools", "/home/vagrant/tools", type: "rsync", rsync__auto: false + config.vm.synced_folder "~/vagrant_tools", "/home/vagrant/tools", files_sync_backend end end