Skip to content

Development environment set up using Vagrant

Zeyuan Hu edited this page Jul 2, 2019 · 6 revisions

NOTE: Follow Vagrant setup from SPDK official for SPDK-related setup

Creating the VM

$ mkdir vagr
$ cd vagr
$ ../spdk/scripts/vagrant/create_vbox.sh -s 512 -n 1 -v ubuntu16
$ cd ubuntu16

Add this line to VagrantFile:

config.vm.synced_folder "/home/zeyuanhu/rustfs", "/home/vagrant/rustfs"

Finish the VM

$ vagrant reload
$ vagrant ssh
$ script -c 'sudo spdk_repo/spdk/scripts/vagrant/update.sh' update.log

Install spdk

$ cd spdk_repo/spdk/
$ git submodule update --init
$ mkdir ~/spdk_install
$ ./configure --prefix=~/spdk_install
$ make

Set Environmental Variables

$ export SPDK_INSTALL_DIR=/home/vagrant/spdk_install
$ export SPDK_LIB_DIR=$HOME/spdk_repo/spdk
$ export RUSTFLAGS="-C link-arg=$SPDK_LIB_DIR/build/lib/libspdk.so"

Change hard coded path on line 221 in hello_nvme_bdev_rust/src/main.rs to:

        let owned_config_file = CString::new("/home/vagrant/rustfs/examples/hello_nvme_bdev/bdev.conf").unwrap();

Install Rust

$ curl https://sh.rustup.rs -sSf | sh
$ source $HOME/.cargo/env

Configure NVMe

$ sudo ./scripts/setup.sh
$ ./scripts/gen_nvme.sh
$ vim ~/rustfs/examples/hello_nvme_bdev/bdev.conf
  Replacing last two lines with output from ./scripts/gen_nvme.sh
    [Nvme]
        TransportID "trtype:PCIe traddr:0000:00:0e.0" Nvme0

Run!

$ sudo -E /home/vagrant/.cargo/bin/cargo run

Tail of my output:

   Writing to the bdev
   bdev io write completed successfully
   Reading io
   string buffer size without nul terminator: 14
   Read string from bdev: Hello World!
Clone this wiki locally