Name
Date
Size
#Lines
LOC

..--

README.mdH A D12-Jan-20248.8 KiB249184

VagrantfileH A D25-Mar-202413.2 KiB402326

autorun-spdk.confH A D03-Mar-2023753 3428

create_nvme_img.shH A D21-Oct-20221.5 KiB7255

create_vbox.shH A D08-Nov-202311.3 KiB387346

local.confH A D04-Jan-2022968 4638

run-autorun.shH A D02-Nov-20224.9 KiB217163

update.shH A D12-Jan-20243.2 KiB10275

README.md

1# SPDK Vagrant and VirtualBox
2
3The following guide explains how to use the scripts in the `spdk/scripts/vagrant`. Mac, Windows, and Linux platforms are supported.
4
51. Install and configure [Git](https://git-scm.com/) on your platform.
62. Install [VirtualBox 5.1](https://www.virtualbox.org/wiki/Downloads) or newer
73. Install* [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads)
84. Install and configure [Vagrant 1.9.4](https://www.vagrantup.com) or newer
9
10* Note: The extension pack has different licensing than main VirtualBox, please
11  review them carefully as the evaluation license is for personal use only.
12
13## Mac OSX Setup (High Sierra)
14
15Quick start instructions for OSX:
16
171. Install Homebrew
182. Install Virtual Box Cask
193. Install Virtual Box Extension Pack*
204. Install Vagrant Cask
21
22* Note: The extension pack has different licensing than main VirtualBox, please
23  review them carefully as the evaluation license is for personal use only.
24
25```bash
26   /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
27   brew doctor
28   brew update
29   brew cask install virtualbox
30   brew cask install virtualbox-extension-pack
31   brew cask install vagrant
32```
33
34## Windows 10 Setup
35
361. Windows platforms should install some form of git.
372. Install [VirtualBox 5.1](https://www.virtualbox.org/wiki/Downloads) or newer
383. Install* [VirtualBox Extension Pack](https://www.virtualbox.org/wiki/Downloads)
394. Install and configure [Vagrant 1.9.4](https://www.vagrantup.com) or newer
40
41* Note: The extension pack has different licensing than main VirtualBox, please
42  review them carefully as the evaluation license is for personal use only.
43
44- Note: VirtualBox requires virtualization to be enabled in the BIOS.
45- Note: You should disable Hyper-V in Windows RS 3 laptop. Search `windows features` un-check Hyper-V, restart laptop
46
47## Linux Setup
48
49Following the generic instructions should be sufficient for most Linux distributions. For more thorough instructions on installing
50VirtualBox on your distribution of choice, please see the following [guide](https://www.virtualbox.org/wiki/Linux_Downloads).
51
52 Examples on Fedora26/Fedora27/Fedora28
53
541. yum check-update
552. yum update -y
563. yum install qt*
574. yum install libsdl*
585. rpm -ivh VirtualBox-5.2-5.2.16_123759_fedora26-1.x86_64.rpm (select the right version in https://www.virtualbox.org/wiki/Linux_Downloads)
596. VBoxManage extpack install Oracle_VM_VirtualBox_Extension_Pack-5.2.16.vbox-extpack(install the same pack* as your installed version of VirtualBox)
607. rpm -ivh vagrant_2.1.2_x86_64.rpm
61
62* Note: The extension pack has different licensing than main VirtualBox, please
63  review them carefully as the evaluation license is for personal use only.
64
65## Configure Vagrant
66
67If you are behind a corporate firewall, configure the following proxy settings.
68
691. Set the http_proxy and https_proxy
702. Install the proxyconf plugin
71
72```bash
73  $ export http_proxy=....
74  $ export https_proxy=....
75  $ vagrant plugin install vagrant-proxyconf
76```
77
78## Download SPDK from GitHub
79
80Use git to clone a new spdk repository. GerritHub can also be used. See the instructions at
81[spdk.io](http://www.spdk.io/development/#gerrithub) to setup your GerritHub account. Note that this spdk
82repository will be rsync'd into your VM, so you can use this repository to continue development within the VM.
83
84## Create a Virtual Box
85
86Use the `spdk/scripts/vagrant/create_vbox.sh` script to create a VM of your choice.  Supported VM platforms are:
87
88- centos7
89- ubuntu16
90- ubuntu18
91- fedora26
92- fedora27
93- fedora28
94- freebsd11
95
96```bash
97$ spdk/scripts/vagrant/create_vbox.sh -h
98 Usage: create_vbox.sh [-n <num-cpus>] [-s <ram-size>] [-x <http-proxy>] [-hvrld] <distro>
99
100  distro = <centos7 | ubuntu16 | ubuntu18 | fedora26 | fedora27 | fedora28 | freebsd11>
101
102  -s <ram-size> in kb       default: 4096
103  -n <num-cpus> 1 to 4      default: 4
104  -x <http-proxy>           default: ""
105  -p <provider>             libvirt or virtualbox
106  --vhost-host-dir=<path>   directory path with vhost test dependencies
107                            (test VM qcow image, fio binary, ssh keys)
108  --vhost-vm-dir=<path>     directory where to put vhost dependencies in VM
109  -r dry-run
110  -l use a local copy of spdk, don't try to rsync from the host.
111  -d deploy a test vm by provisioning all prerequisites for spdk autotest
112  -h help
113  -v verbose
114
115 Examples:
116
117  ./scripts/vagrant/create_vbox.sh -x http://user:password@host:port fedora27
118  ./scripts/vagrant/create_vbox.sh -s 2048 -n 2 ubuntu16
119  ./scripts/vagrant/create_vbox.sh -rv freebsd
120  ./scripts/vagrant/create_vbox.sh fedora26
121```
122
123It is recommended that you call the `create_vbox.sh` script from outside of the spdk repository.
124Call this script from a parent directory. This will allow the creation of multiple VMs in separate
125<distro> directories, all using the same spdk repository.  For example:
126
127```bash
128   $ spdk/scripts/vagrant/create_vbox.sh -s 2048 -n 2 fedora26
129```
130
131This script will:
132
1331. create a subdirectory named <distro> in your $PWD
1342. copy the needed files from `spdk/scripts/vagrant/` into the <distro> directory
1353. create a working virtual box in the <distro> directory
1364. rsync the `~/.gitconfig` file to `/home/vagrant/` in the newly provisioned virtual box
1375. rsync a copy of the source `spdk` repository to `/home/vagrant/spdk_repo/spdk` (optional)
1386. rsync a copy of the `~/vagrant_tools` directory to `/home/vagrant/tools` (optional)
1397. execute autotest_setup.sh on the guest to install all spdk dependencies (optional)
140
141This arrangement allows the provisioning of multiple, different VMs within that same directory hierarchy using the same
142spdk repository. Following the creation of the vm you'll need to ssh into your virtual box and finish the VM initialization.
143
144```bash
145  $ cd <distro>
146  $ vagrant ssh
147```
148
149## Finish VM Initialization
150
151A copy of the `spdk` repository you cloned will exist in the `spdk_repo` directory of the `/home/vagrant` user
152account. After using `vagrant ssh` to enter your VM you must complete the initialization of your VM by running
153the `scripts/vagrant/update.sh` script. For example:
154
155```bash
156   $ script -c 'sudo spdk_repo/spdk/scripts/vagrant/update.sh' update.log
157```
158
159The `update.sh` script completes initialization of the VM by automating the following steps.
160
1611. Runs yum/apt-get update (Linux)
1622. Runs the scripts/pdkdep.sh script
1633. Installs the FreeBSD source in /usr/sys (FreeBSD only)
164
165This only needs to be done once. This is also not necessary for Fedora VMs provisioned with the -d flag. The `vm_setup`
166script performs these operations instead.
167
168## Post VM Initialization
169
170Following VM initialization you must:
171
1721. Verify you have an emulated NVMe device
1732. Compile your spdk source tree
1743. Run the hello_world example to validate the environment is set up correctly
175
176### Verify you have an emulated NVMe device
177
178```bash
179  $ lspci | grep "Non-Volatile"
180  00:0e.0 Non-Volatile memory controller: InnoTek Systemberatung GmbH Device 4e56
181```
182
183### Compile SPDK
184
185```bash
186  $ cd spdk_repo/spdk
187  $ git submodule update --init
188  $ ./configure --enable-debug
189  $ make
190```
191
192### Run the hello_world example script
193
194```bash
195  $ sudo scripts/setup.sh
196  $ sudo scripts/gen_nvme.sh --json-with-subsystems > ./build/examples/hello_bdev.json
197  $ sudo ./build/examples/hello_bdev --json ./build/examples/hello_bdev.json -b Nvme0n1
198```
199
200### Running autorun.sh with vagrant
201
202After running autotest_setup.sh the `run-autorun.sh` can be used to run `spdk/autorun.sh` on a Fedora vagrant machine.
203Note that the `spdk/scripts/vagrant/autorun-spdk.conf` should be copied to `~/autorun-spdk.conf` before starting your tests.
204
205```bash
206   $ cp spdk/scripts/vagrant/autorun-spdk.conf ~/
207   $ spdk/scripts/vagrant/run-autorun.sh -h
208     Usage: scripts/vagrant/run-autorun.sh -d <path_to_spdk_tree> [-h] | [-q] | [-n]
209       -d : Specify a path to an SPDK source tree
210       -q : No output to screen
211       -n : Noop - dry-run
212       -h : This help
213
214     Examples:
215         run-spdk-autotest.sh -d . -q
216         run-spdk-autotest.sh -d /home/vagrant/spdk_repo/spdk
217```
218
219## FreeBSD Appendix
220
221---
222**NOTE:** As of this writing the FreeBSD Virtualbox instance does not correctly support the vagrant-proxyconf feature.
223---
224
225The following steps are done by the `update.sh` script. It is recommended that you capture the output of `update.sh` with a typescript. E.g.:
226
227```bash
228  $ script update.log sudo spdk_repo/spdk/scripts/vagrant/update.sh
229```
230
2311. Updates the pkg catalog
2321. Installs the needed FreeBSD packages on the system by calling pkgdep.sh
2332. Installs the FreeBSD source in /usr/src
234
235```bash
236   $ sudo pkg upgrade -f
237   $ sudo spdk_repo/spdk/scripts/pkgdep.sh --all
238   $ sudo git clone --depth 10 -b releases/11.1.0 https://github.com/freebsd/freebsd.git /usr/src
239```
240
241To build spdk on FreeBSD use `gmake MAKE=gmake`.  E.g.:
242
243```bash
244    $ cd spdk_repo/spdk
245    $ git submodule update --init
246    $ ./configure --enable-debug
247    $ gmake MAKE=gmake
248```
249