From 5327de1ffab951510073997f3079e984ee73b33d Mon Sep 17 00:00:00 2001 From: Michal Berger Date: Mon, 1 Jun 2020 14:54:15 +0200 Subject: [PATCH] scripts/vagrant: [nvme] Enable CMB buffer on demand Allow to specify additional argument which will tell Vagrant to enable CMB on given nvme drive. The format of the argument is any string which is then simply converted to plain "true". E.g. ./create_vbox.sh -b "/path_to_nvme_img,nvme,3,true" Change-Id: I7de55e46491318b082bf4e2165260091b44d60f0 Signed-off-by: Michal Berger Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/2725 Tested-by: SPDK CI Jenkins Community-CI: Mellanox Build Bot Reviewed-by: Changpeng Liu Reviewed-by: Jim Harris --- scripts/vagrant/Vagrantfile | 13 +++++++++---- scripts/vagrant/create_vbox.sh | 9 +++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 5e5f806f5..92d0f2985 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -128,6 +128,7 @@ Vagrant.configure(2) do |config| emulated_nvme_types=(ENV['NVME_DISKS_TYPE'] || "nvme").split(',') nvme_namespaces=(ENV['NVME_DISKS_NAMESPACES'] || "").split(',') nvme_file=(ENV['NVME_FILE'] || "").split(',') + nvme_cmbs=(ENV['NVME_CMB'] || "").split(',') vagrantfile_dir=(ENV['VAGRANTFILE_DIR'] || "none") config.ssh.forward_agent = true @@ -192,11 +193,15 @@ Vagrant.configure(2) do |config| libvirt.qemuargs :value => "-drive" libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}" libvirt.qemuargs :value => "-device" - if nvme_namespaces["#{index}".to_i].nil? || nvme_namespaces["#{index}".to_i] == "1" - libvirt.qemuargs :value => "nvme,drive=#{nvme_disk_id},serial=1234#{index}" - else - libvirt.qemuargs :value => "nvme,drive=#{nvme_disk_id},serial=1234#{index},namespaces=#{nvme_namespaces["#{index}".to_i]}" + nvme_drive = "nvme,drive#{nvme_disk_id},serial=1234#{index}" + if !nvme_namespaces["#{index}".to_i].nil? && nvme_namespaces["#{index}".to_i] != 1 + nvme_drive << ",namespaces=#{nvme_namespaces["#{index}".to_i]}" end + if !nvme_cmbs["#{index}".to_i].nil? && nvme_cmbs["#{index}".to_i] == "true" + # Fix the size of the buffer to 128M + nvme_drive << ",cmb_size_mb=128" + end + libvirt.qemuargs :value => nvme_drive elsif disk == "ocssd" libvirt.qemuargs :value => "-drive" libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}" diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index 60242aa66..055a73e39 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -30,7 +30,7 @@ display_help() { echo " If no -b option is specified then this option defaults to emulating single" echo " NVMe with 1 namespace and assumes path: /var/lib/libvirt/images/nvme_disk.img" echo " -b option can be used multiple times for attaching multiple files to the VM" - echo " Parameters for -b option: ,,." + echo " Parameters for -b option: ,,," echo " Available types: nvme, ocssd." echo " -c Create all above disk, default 0" echo " -H Use hugepages for allocating VM memory. Only for libvirt provider. Default: false." @@ -197,11 +197,14 @@ if [ -z "$NVME_FILE" ]; then else TMP="" for args in $NVME_FILE; do - while IFS=, read -r path type namespace; do + while IFS=, read -r path type namespace cmb; do TMP+="$path," if [ -z "$type" ]; then type="nvme" fi + if [[ -n $cmb ]]; then + NVME_CMB=${NVME_CMB:+$NVME_CMB,}true + fi NVME_DISKS_TYPE+="$type," if [ -z "$namespace" ] && [ -n "$SPDK_QEMU_EMULATOR" ]; then namespace="1" @@ -226,6 +229,7 @@ if [ ${VERBOSE} = 1 ]; then echo NVME_DISKS_TYPE=$NVME_DISKS_TYPE echo NVME_AUTO_CREATE=$NVME_AUTO_CREATE echo NVME_DISKS_NAMESPACES=$NVME_DISKS_NAMESPACES + echo NVME_CMB=$NVME_CMB echo SPDK_VAGRANT_DISTRO=$SPDK_VAGRANT_DISTRO echo SPDK_VAGRANT_VMCPU=$SPDK_VAGRANT_VMCPU echo SPDK_VAGRANT_VMRAM=$SPDK_VAGRANT_VMRAM @@ -243,6 +247,7 @@ export SPDK_DIR export COPY_SPDK_DIR export COPY_SPDK_ARTIFACTS export DEPLOY_TEST_VM +export NVME_CMB export NVME_DISKS_TYPE export NVME_DISKS_NAMESPACES export NVME_FILE