From efb72886b345f00078c77a0ee8e51a87f58345ed Mon Sep 17 00:00:00 2001 From: Vitaliy Mysak Date: Fri, 3 Apr 2020 10:48:52 +0200 Subject: [PATCH] scripts/vagrant: add fedora31 to create_vhost_vm script Adding fedora31 to the list of available choices in create_vhost_vm script. This requires some changes in Vagrant_vhost_vm because fedora is configured differently than ubuntu. Fedora VMs will very useful for vhost tests because they run on fedora. Change-Id: Iad2820a9c3fe2621a368be34d9a72b80ad3f4941 Signed-off-by: Vitaliy Mysak Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1677 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins Reviewed-by: Karol Latecki Reviewed-by: Shuhei Matsumoto Reviewed-by: Tomasz Zawadzki --- scripts/vagrant/Vagrantfile_vhost_vm | 41 +++++++++++++++++++++++----- scripts/vagrant/create_vhost_vm.sh | 5 +++- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/scripts/vagrant/Vagrantfile_vhost_vm b/scripts/vagrant/Vagrantfile_vhost_vm index b12e8db34..4daeb105f 100644 --- a/scripts/vagrant/Vagrantfile_vhost_vm +++ b/scripts/vagrant/Vagrantfile_vhost_vm @@ -14,6 +14,10 @@ Vagrant.configure(2) do |config| # 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!") @@ -63,7 +67,20 @@ Vagrant.configure(2) do |config| 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 - config.vm.provision "shell", inline: $apt_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 @@ -72,13 +89,23 @@ Vagrant.configure(2) do |config| # 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 update-grub' + 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' - # 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"' + 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 diff --git a/scripts/vagrant/create_vhost_vm.sh b/scripts/vagrant/create_vhost_vm.sh index 5895639cf..5ad416c3b 100755 --- a/scripts/vagrant/create_vhost_vm.sh +++ b/scripts/vagrant/create_vhost_vm.sh @@ -19,7 +19,7 @@ display_help() { echo echo " Usage: ${0##*/} " echo - echo " distro = " + echo " distro = " echo echo " --use-ssh-dir= Use existing spdk_vhost_id_rsa keys from specified directory" echo " for setting up SSH key pair on VM" @@ -79,6 +79,9 @@ case "${SPDK_VAGRANT_DISTRO}" in ubuntu18) export SPDK_VAGRANT_DISTRO ;; + fedora31) + export SPDK_VAGRANT_DISTRO + ;; *) echo " Invalid argument \"${SPDK_VAGRANT_DISTRO}\"" echo " Try: \"$0 -h\"" >&2