scripts/vagrant: Remove unused vhost stuff

We don't use this script to create qcow2 images for our tests in CI.
Also this script is using random vagrant box images, and we don't know
what is inside them.
Script maintenance is a tedious affair because fedora boxes use xfs file
system, and we can not shrink them virtual disk to minimal size, and this
will caused fails in tests in future.

Signed-off-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Change-Id: I7b35f16bbfd6135377995f7b20e1402d14b2b1b1
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/4738
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Maciej Wawryk 2020-10-16 14:15:52 +02:00 committed by Jim Harris
parent 30f9feca2a
commit 1d03a9baf4
4 changed files with 16 additions and 306 deletions

View File

@ -256,7 +256,6 @@ _spdk_apps() {
spdk_trace_record
vhost
create_vbox.sh
create_vhost_vm.sh
pkgdep.sh
run-autorun.sh
vm_setup.sh

View File

@ -1,138 +0,0 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
# Pick the right distro and bootstrap, default is ubuntu1604
distro = ( ENV['SPDK_VAGRANT_DISTRO'] || "ubuntu16")
case distro
when "ubuntu16"
# See: https://app.vagrantup.com/puppetlabs/boxes/ubuntu-16.04-64-nocm
config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
config.vm.box_version = "1.0.0"
when "ubuntu18"
# See: https://app.vagrantup.com/bento/boxes/ubuntu-18.04
config.vm.box = "bento/ubuntu-18.04"
config.vm.box_version = "201808.24.0"
when "fedora31"
# See: https://app.vagrantup.com/generic/boxes/fedora31
config.vm.box = "generic/fedora31"
config.vm.box_version = "2.0.6"
else
"Invalid argument #{distro}"
abort("Invalid argument!")
end
config.vm.box_check_update = false
# vagrant-cachier caches apt/yum etc to speed subsequent
# vagrant up
# to enable, run
# vagrant plugin install vagrant-cachier
#
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
# use http proxy if avaiable
if ENV['http_proxy'] && Vagrant.has_plugin?("vagrant-proxyconf")
config.proxy.http = ENV['http_proxy']
config.proxy.https = ENV['https_proxy']
config.proxy.no_proxy = "localhost,127.0.0.1"
end
vmcpu=(ENV['SPDK_VAGRANT_VMCPU'] || 2)
vmram=(ENV['SPDK_VAGRANT_VMRAM'] || 4096)
ssh_key_dir=(ENV['SPDK_VAGRANT_SSH_KEY'])
spdk_dir=(ENV['SPDK_DIR'] || "none")
install_deps=(ENV['INSTALL_DEPS'] || "false")
config.ssh.forward_agent = true
config.ssh.forward_x11 = true
# Change root passwd and allow root SSH
config.vm.provision "shell", inline: 'echo -e "root\nroot" | sudo passwd root'
config.vm.provision "shell", inline: 'sudo sh -c "echo \"PermitRootLogin yes\" >> /etc/ssh/sshd_config"'
# Use previously generated SSH keys for setting up a key pair
$ssh_key_gen_script = <<-SCRIPT
sudo mkdir -p /root/.ssh
cat /vagrant/ssh_keys/spdk_vhost_id_rsa.pub > /root/.ssh/authorized_keys
sudo chmod 644 /root/.ssh/authorized_keys
SCRIPT
config.vm.provision "shell", inline: $ssh_key_gen_script
# Install needed deps
$apt_script = <<-SCRIPT
sudo apt -y update
sudo DEBIAN_FRONTEND=noninteractive apt -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confold" upgrade
sudo apt -y install -y fio sg3-utils bc
SCRIPT
$dnf_script = <<-SCRIPT
sudo dnf -y update
sudo dnf -y install fio sg3_utils bc
SCRIPT
$install_script = case distro
when "ubuntu16" then $apt_script
when "ubuntu18" then $apt_script
when "fedora31" then $dnf_script
else abort("#{distro} distribution is not supported yet")
end
config.vm.provision "shell", inline: $install_script
# Modify GRUB options
# console=ttyS0 earlyprintk=ttyS0 - reroute output to serial dev, so that QEMU can write output to file
# scsi_mod.use_blk_mq=1 - for multiqueue use
# net.ifnames=0 biosdevname=0 - do not rename NICs on boot. That way we ensure that addded NIC is always eth0.
# Reason for these options is that NIC can have different udev name during provisioning with Vagrant
# and then some other name while running SPDK tests which use Qemu without any hypervisor like vbox or libvirt
# so no corresponding configuration for this NIC name will be present in /etc.
config.vm.provision "shell", inline: 'sudo sed -ir s#GRUB_CMDLINE_LINUX=#GRUB_CMDLINE_LINUX=\"console=ttyS0\ earlyprintk=ttyS0\ scsi_mod.use_blk_mq=1\ net.ifnames=0\ biosdevname=0\"#g /etc/default/grub'
config.vm.provision "shell", inline: 'sudo sed -ir s#\"\"#\ #g /etc/default/grub'
update_grub_command = case distro
when "ubuntu16" then 'sudo update-grub'
when "ubuntu18" then 'sudo update-grub'
when "fedora31" then 'sudo grub2-mkconfig -o /boot/grub2/grub.cfg ; sudo grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg'
else abort("#{distro} distribution is not supported yet")
end
config.vm.provision "shell", inline: update_grub_command
if distro.include? "ubuntu"
# TODO: Next 2 lines break any future ssh communication via "vagrant ssh"
# I'd be good to check NIC names in ifconfig and then sed them in /etc/network/interfaces to eht0, eht1, and so on
config.vm.provision "shell", inline: 'sudo sh -c "echo \"auto eth0\" >> /etc/network/interfaces"'
config.vm.provision "shell", inline: 'sudo sh -c "echo \"iface eth0 inet dhcp\" >> /etc/network/interfaces"'
end
if distro.include? "ubuntu18"
# This is to avoid annoying "Start job is running for wait for network to be configured" 2 minute timeout
# in case of not-so-perfect NIC and virtual network configuration for the VM
config.vm.provision "shell", inline: 'systemctl disable systemd-networkd-wait-online.service'
config.vm.provision "shell", inline: 'systemctl mask systemd-networkd-wait-online.service'
end
config.vm.provider "virtualbox" do |vb|
vb.customize ["modifyvm", :id, "--ioapic", "on"]
vb.memory = "#{vmram}"
vb.cpus = "#{vmcpu}"
#support for the SSE4.x instruction is required in some versions of VB.
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"]
vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"]
end
if spdk_dir != "none"
config.vm.synced_folder "#{spdk_dir}", "/home/vagrant/spdk_repo/spdk", type: "rsync", rsync__auto: false
if install_deps.include? "true"
config.vm.provision "shell", inline: 'sudo /home/vagrant/spdk_repo/spdk/scripts/pkgdep.sh --all'
end
end
# 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
end
end

View File

@ -1,132 +0,0 @@
#!/usr/bin/env bash
# create_vhost_vm.sh
#
# Creates a virtual machine image used as a dependency for running vhost tests
set -e
VAGRANT_TARGET="$PWD"
DIR="$(cd "$(dirname $0)" && pwd)"
SPDK_DIR="$(cd "${DIR}/../../" && pwd)"
USE_SSH_DIR=""
MOVE_TO_DEFAULT_DIR=false
INSTALL_DEPS=false
# The command line help
display_help() {
echo
echo " Usage: ${0##*/} <distro>"
echo
echo " distro = <ubuntu16 | ubuntu18 | fedora31> "
echo
echo " --use-ssh-dir=<dir path> Use existing spdk_vhost_id_rsa keys from specified directory"
echo " for setting up SSH key pair on VM"
echo " --install-deps Install SPDK build dependencies on VM. Needed by some of the"
echo " vhost and vhost initiator tests. Default: false."
echo " --move-to-default-dir Move generated files to default directories used by vhost test scripts."
echo " Default: false."
echo " --http-proxy Default: \"${SPDK_VAGRANT_HTTP_PROXY}\""
echo " -h help"
echo
echo " Examples:"
echo
}
while getopts ":h-:" opt; do
case "${opt}" in
-)
case "${OPTARG}" in
use-ssh-dir=*) USE_SSH_DIR="${OPTARG#*=}" ;;
move-to-default-dir) MOVE_TO_DEFAULT_DIR=true ;;
install-deps) INSTALL_DEPS=true ;;
http-proxy=*)
http_proxy=$OPTARG
https_proxy=$http_proxy
SPDK_VAGRANT_HTTP_PROXY="${http_proxy}"
;;
*)
echo " Invalid argument -$OPTARG" >&2
echo " Try \"$0 -h\"" >&2
exit 1
;;
esac
;;
h)
display_help >&2
exit 0
;;
*)
echo " Invalid argument: -$OPTARG" >&2
echo " Try: \"$0 -h\"" >&2
exit 1
;;
esac
done
export SPDK_DIR
export SPDK_VAGRANT_HTTP_PROXY
export INSTALL_DEPS
shift "$((OPTIND - 1))" # Discard the options and sentinel --
SPDK_VAGRANT_DISTRO="$*"
case "${SPDK_VAGRANT_DISTRO}" in
ubuntu16)
export SPDK_VAGRANT_DISTRO
;;
ubuntu18)
export SPDK_VAGRANT_DISTRO
;;
fedora31)
export SPDK_VAGRANT_DISTRO
;;
*)
echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\""
echo " Try: \"$0 -h\"" >&2
exit 1
;;
esac
mkdir -vp "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}"
cp ${DIR}/Vagrantfile_vhost_vm ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/Vagrantfile
# Copy or generate SSH keys to the VM
mkdir -vp "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys"
if [[ -n $USE_SSH_DIR ]]; then
cp ${USE_SSH_DIR}/spdk_vhost_id_rsa* "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys"
else
ssh-keygen -f "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa" -N "" -q
fi
export SPDK_VAGRANT_SSH_KEY="${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa"
pushd "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}"
if [ -n "${http_proxy}" ]; then
export http_proxy
export https_proxy
if vagrant plugin list | grep -q vagrant-proxyconf; then
echo "vagrant-proxyconf already installed... skipping"
else
vagrant plugin install vagrant-proxyconf
fi
fi
VBoxManage setproperty machinefolder "${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}"
vagrant up
vagrant halt
VBoxManage setproperty machinefolder default
# Convert Vbox .vmkd image to qcow2
vmdk_img=$(find ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO} -name "*.vmdk")
qemu-img convert -f vmdk -O qcow2 ${vmdk_img} ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/vhost_vm_image.qcow2
if $MOVE_TO_DEFAULT_DIR; then
sudo mkdir -p /home/sys_sgsw
sudo mv -f ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/vhost_vm_image.qcow2 /home/sys_sgsw/vhost_vm_image.qcow2
sudo mv -f ${VAGRANT_TARGET}/${SPDK_VAGRANT_DISTRO}/ssh_keys/spdk_vhost_id_rsa* ~/.ssh/
fi
echo ""
echo " SUCCESS!"
echo ""

View File

@ -41,64 +41,45 @@ configuration file. For a full list of the variable declarations available for a
## Additional Steps for Preparing the Vhost Tests
The Vhost tests also require the creation of a second virtual machine nested inside of the test VM.
The Vhost tests require the creation of a virtual guest machine to be run in the host system.
Please follow the directions below to complete that installation. Note that host refers to the Fedora VM
created above and guest or VM refer to the Ubuntu VM created in this section.
created above and guest or VM refer to the Fedora VM created in this section, which are meant to be used in Vhost tests.
1. Follow instructions from spdk/scripts/vagrant/README.md
- install all needed packages mentioned in "Mac OSX Setup" or "Windows 10 Setup" sections
- follow steps from "Configure Vagrant" section
2. Use Vagrant scripts located in spdk/scripts/vagrant to automatically generate
VM image to use in SPDK vhost tests.
Example command:
~~~{.sh}
spdk/scripts/vagrant/create_vhost_vm.sh --move-to-def-dirs ubuntu16
~~~
This command will:
- Download a Ubuntu 16.04 image file
- upgrade the system and install needed dependencies (fio, sg3-utils, bc)
- add entry to VM's ~/.ssh/autorized_keys
- add appropriate options to GRUB command line and update grub
- convert the image to .qcow2 format
- move .qcow2 file and ssh keys to default locations used by vhost test scripts
Alternatively it is possible to create the VM image manually using following steps:
To create the VM image manually use following steps:
1. Create an image file for the VM. It does not have to be large, about 3.5G should suffice.
2. Create an ssh keypair for host-guest communications (performed on the host):
- Generate an ssh keypair with the name spdk_vhost_id_rsa and save it in `/root/.ssh`.
- Make sure that only root has read access to the private key.
3. Install the OS in the VM image (performed on guest):
- Use the latest Ubuntu server (Currently 16.04 LTS).
- Use the latest Fedora Cloud (Currently Fedora 32).
- When partitioning the disk, make one partion that consumes the whole disk mounted at /. Do not encrypt the disk or enable LVM.
- Choose the OpenSSH server packages during install.
4. Post installation configuration (performed on guest):
- Run the following commands to enable all necessary dependencies:
~~~{.sh}
sudo apt update
sudo apt upgrade
sudo apt install fio sg3-utils bc
sudo dnf update
sudo dnf upgrade
sudo dnf -y install git sg3_utils bc wget libubsan libasan xfsprogs btrfs-progs ntfsprogs ntfs-3g
git clone https://github.com/spdk/spdk.git
./spdk/scripts/pkgdep.sh -p -f -r -u
~~~
- Enable the root user: "sudo passwd root -> root".
- Enable root login over ssh: vim `/etc/ssh/sshd_config` -> PermitRootLogin=yes.
- Disable DNS for ssh: `/etc/ssh/sshd_config` -> UseDNS=no.
- Add the spdk_vhost key to root's known hosts: `/root/.ssh/authorized_keys` -> add spdk_vhost_id_rsa.pub key to authorized keys.
Remember to save the private key in `~/.ssh/spdk_vhost_id_rsa` on the host.
- Change the grub boot options for the guest as follows:
- Add "console=ttyS0 earlyprintk=ttyS0" to the boot options in `/etc/default/grub` (for serial output redirect).
- Add "scsi_mod.use_blk_mq=1" to boot options in `/etc/default/grub`.
~~~{.sh}
sudo update-grub
sudo grub2-mkconfig -o /boot/grub2/grub.cfg
~~~
- Reboot the VM.
- Remove any unnecessary packages (this is to make booting the VM faster):
~~~{.sh}
apt purge snapd
apt purge Ubuntu-core-launcher
apt purge squashfs-tools
apt purge unattended-upgrades
sudo dnf clean all
~~~
5. Copy the fio binary from the guest location `/usr/bin/fio` to the host location `/home/sys_sgsw/fio_ubuntu`.
6. Place the guest VM in the host at the following location: `/home/sys_sgsw/vhost_vm_image.qcow2`.
5. Install fio:
~~~
./spdk/test/common/config/vm_setup.sh -t 'fio'
~~~
6. Place the guest VM in the host at the following location: `/home/sys_sgci/spdk_test_image.qcow2`.
7. On the host, edit the `~/autorun-spdk.conf` file to include the following line: SPDK_TEST_VHOST=1.