diff --git a/scripts/vagrant/Vagrantfile b/scripts/vagrant/Vagrantfile index 68728204ca..9127861092 100644 --- a/scripts/vagrant/Vagrantfile +++ b/scripts/vagrant/Vagrantfile @@ -130,6 +130,7 @@ def setup_nvme_disk(libvirt, disk, index) nvme_namespaces=(ENV['NVME_DISKS_NAMESPACES'] || "").split(',') nvme_cmbs=(ENV['NVME_CMB'] || "").split(',') + nvme_pmrs=(ENV['NVME_PMR'] || "").split(',') libvirt.qemuargs :value => "-drive" libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}" @@ -139,11 +140,33 @@ def setup_nvme_disk(libvirt, disk, index) nvme_drive << ",namespaces=#{nvme_namespaces[index]}" end + cmb_set = "false" + pmr_cmdline = + if !nvme_cmbs[index].nil? && nvme_cmbs[index] == "true" # Fix the size of the buffer to 128M nvme_drive << ",cmb_size_mb=128" + cmb_set = "true" + end + if !nvme_pmrs[index].nil? + if cmb_set == "true" + abort("CMB and PMR are mutually exclusive, aborting (#{nvme_disk})") + end + pmr_path, pmr_size = nvme_pmrs[index].split(':') + if !File.exist?(pmr_path) + abort("#{pmr_path} does not exist, aborting") + end + if pmr_size.nil? + pmr_size = "16M" + end + nvme_drive << ",pmrdev=pmr#{index}" + pmr_cmdline = "memory-backend-file,id=pmr#{index},share=on,mem-path=#{pmr_path},size=#{pmr_size}" end libvirt.qemuargs :value => nvme_drive + if !pmr_cmdline.nil? + libvirt.qemuargs :value => "-object" + libvirt.qemuargs :value => pmr_cmdline + end end def setup_ocssd_disk(libvirt, disk, index) diff --git a/scripts/vagrant/create_vbox.sh b/scripts/vagrant/create_vbox.sh index 4cc0d1183d..88f29f2639 100755 --- a/scripts/vagrant/create_vbox.sh +++ b/scripts/vagrant/create_vbox.sh @@ -30,8 +30,10 @@ 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 " Default pmr size: 16M" + echo " Default cmb: false" echo " -c Create all above disk, default 0" echo " -H Use hugepages for allocating VM memory. Only for libvirt provider. Default: false." echo " -u Use password authentication to the VM instead of SSH keys." @@ -178,13 +180,16 @@ if [ -z "$NVME_FILE" ]; then else TMP="" for args in $NVME_FILE; do - while IFS=, read -r path type namespace cmb; do + while IFS=, read -r path type namespace cmb pmr; do TMP+="$path," if [ -z "$type" ]; then type="nvme" fi if [[ -n $cmb ]]; then - NVME_CMB=${NVME_CMB:+$NVME_CMB,}true + NVME_CMB=${NVME_CMB:+$NVME_CMB,}$cmb + fi + if [[ -n $pmr ]]; then + NVME_PMR=${NVME_PMR:+$NVME_PMR,}$pmr fi NVME_DISKS_TYPE+="$type," if [ -z "$namespace" ] && [ -n "$SPDK_QEMU_EMULATOR" ]; then @@ -211,6 +216,7 @@ if [ ${VERBOSE} = 1 ]; then echo NVME_AUTO_CREATE=$NVME_AUTO_CREATE echo NVME_DISKS_NAMESPACES=$NVME_DISKS_NAMESPACES echo NVME_CMB=$NVME_CMB + echo NVME_PMR=$NVME_PMR echo SPDK_VAGRANT_DISTRO=$SPDK_VAGRANT_DISTRO echo SPDK_VAGRANT_VMCPU=$SPDK_VAGRANT_VMCPU echo SPDK_VAGRANT_VMRAM=$SPDK_VAGRANT_VMRAM @@ -232,6 +238,7 @@ export COPY_SPDK_DIR export COPY_SPDK_ARTIFACTS export DEPLOY_TEST_VM export NVME_CMB +export NVME_PMR export NVME_DISKS_TYPE export NVME_DISKS_NAMESPACES export NVME_FILE