Commit 11fa5403 authored by Jim Harris's avatar Jim Harris
Browse files

scripts: add a vagrant setup



Signed-off-by: default avatarJim Harris <james.r.harris@intel.com>
Change-Id: I074c779d1736733b6864dfbcab529151e01fa4b7
parent f7d8a869
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -84,6 +84,29 @@ FreeBSD:
    ./configure --with-dpdk=./dpdk/x86_64-native-bsdapp-clang
    gmake

Vagrant
=======

A [Vagrant](https://www.vagrantup.com/downloads.html) setup is also provided
to create a Linux VM with a virtual NVMe controller to get up and running
quickly.  Currently this has only been tested on MacOS with the
[VirtualBox](https://www.virtualbox.org/wiki/Downloads) provider.  The
[VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads) must
also be installed for NVMe support.

Download DPDK as a subdirectory in the SPDK repository as described above.
You do *not* need to build DPDK - the Vagrant scripts will do this for you.
If you are behind a corporate firewall, set http_proxy and https_proxy in
your environment before running the following steps.

    1) vagrant up
    2) vagrant ssh
    3) cd /spdk
    4) sudo examples/nvme/hello_world/hello_world

Additional details on the Vagrant setup can be found in
[scripts/vagrant/README.md](scripts/vagrant/README.md).

Advanced Build Options
======================

+26 −0
Original line number Diff line number Diff line
Introduction
============

This is a vagrant environment for SPDK with support
for Ubuntu 16.04 and Centos 7.2.

The VM builds SPDK and DPDK from source which can be located at /spdk and /dpdk.

VM Configuration
================

This vagrant environment creates a VM based on environment variables found in ./env.sh
To use, edit env.sh then
  source ./env.sh
  vagrant up

By default, the VM created is/has:
- Ubuntu 16.04
- 2 vCPUs
- 4G of RAM
- 2 NICs (1 x NAT - host access, 1 x private network)

Providers
=========

Currently only the Virtualbox provider is supported.
+70 −0
Original line number Diff line number Diff line
# -*- 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'] || "ubuntu1604")
  if distro == 'centos7'
    config.vm.box = "puppetlabs/centos-7.2-64-nocm"
    config.ssh.insert_key = false
  else
    config.vm.box = "puppetlabs/ubuntu-16.04-64-nocm"
  end
  config.vm.box_check_update = false

  config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"update.sh")
  config.vm.provision :shell, :path => File.join(File.dirname(__FILE__),"build.sh")
  config.vm.provision :shell, inline: "/spdk/scripts/setup.sh", run: "always"

  # Copy in the .gitconfig if it exists
  if File.file?(File.expand_path("~/.gitconfig"))
    config.vm.provision  "file", source: "~/.gitconfig", destination: ".gitconfig"
  end

  # 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

  config.vm.network "private_network", type: "dhcp"

  # 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)

  config.ssh.forward_agent = true
  config.ssh.forward_x11 = true

  config.vm.provider "virtualbox" do |vb|
      vb.customize ["modifyvm", :id, "--ioapic", "on"]
      vb.memory = "#{vmram}"
      vb.cpus = "#{vmcpu}"

      # rsync the vpp directory if provision hasn't happened yet
      unless File.exist? (".vagrant/machines/default/virtualbox/action_provision")
        config.vm.synced_folder "../../", "/spdk", type: "rsync", rsync__auto: false
      end

      nvme_disk = 'nvme.vdi'
      unless File.exist? (nvme_disk)
        vb.customize ["createhd", "--filename", nvme_disk, "--variant", "Fixed", "--size", "1024"]
        vb.customize ["storagectl", :id, "--name", "nvme", "--add", "pcie", "--controller", "NVMe", "--portcount", "1", "--bootable", "off"]
        vb.customize ["storageattach", :id, "--storagectl", "nvme", "--type", "hdd", "--medium", nvme_disk, "--port", "0"]
      end

      #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
end
+51 −0
Original line number Diff line number Diff line
#!/bin/bash

SPDK_DIR=/spdk
DPDK_DIR=$SPDK_DIR/dpdk

SUDOCMD="sudo -H -u vagrant"
echo 0:$0
echo 1:$1
echo 2:$2
echo SUDOCMD: $SUDOCMD

# Figure out what system we are running on
if [ -f /etc/lsb-release ];then
    . /etc/lsb-release
elif [ -f /etc/redhat-release ];then
    sudo yum install -y redhat-lsb
    DISTRIB_ID=`lsb_release -si`
    DISTRIB_RELEASE=`lsb_release -sr`
    DISTRIB_CODENAME=`lsb_release -sc`
    DISTRIB_DESCRIPTION=`lsb_release -sd`
fi
KERNEL_OS=`uname -o`
KERNEL_MACHINE=`uname -m`
KERNEL_RELEASE=`uname -r`
KERNEL_VERSION=`uname -v`

echo KERNEL_OS: $KERNEL_OS
echo KERNEL_MACHINE: $KERNEL_MACHINE
echo KERNEL_RELEASE: $KERNEL_RELEASE
echo KERNEL_VERSION: $KERNEL_VERSION
echo DISTRIB_ID: $DISTRIB_ID
echo DISTRIB_RELEASE: $DISTRIB_RELEASE
echo DISTRIB_CODENAME: $DISTRIB_CODENAME
echo DISTRIB_DESCRIPTION: $DISTRIB_DESCRIPTION

if [ -f /etc/lsb-release ]; then
    apt-get install -y gcc g++ make libcunit1-dev libaio-dev libssl-dev
elif [ -f /etc/redhat-release ]; then
    # Add EPEL repository for CUnit-devel
    yum --enablerepo=extras install epel-release
    yum install -y gcc gcc-c++ CUnit-devel libaio-devel openssl-devel
fi

cd $DPDK_DIR
$SUDOCMD make -j2 install T=x86_64-native-linuxapp-gcc DESTDIR=.

cd $SPDK_DIR
$SUDOCMD ./configure --with-dpdk=$DPDK_DIR/x86_64-native-linuxapp-gcc --enable-debug
$SUDOCMD make -j2
# Bind virtual NVMe controller to uio_pci_generic
sudo scripts/setup.sh

scripts/vagrant/env.sh

0 → 100644
+7 −0
Original line number Diff line number Diff line
#!/usr/bin/env bash

# centos7 also supported
export SPDK_VAGRANT_DISTRO="ubuntu1604"

export SPDK_VAGRANT_VMCPU=4
export SPDK_VAGRANT_VMRAM=4096
Loading