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