scripts/vagrant: Add support for setting a PMR device

Available in qemu >= 5.1.0. Note that since CMB and PMR share the same
BAR they cannot be used together. If both are specified, PMR setup is
skipped.

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Ia0c6681b5ac7563efc6c32d2fff1808814196676
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/7018
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
Michal Berger 2021-03-23 20:09:50 +01:00 committed by Jim Harris
parent 505b507234
commit 45fc211e5f
2 changed files with 33 additions and 3 deletions

View File

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

View File

@ -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: <path>,<type>,<namespaces>,<cmb>"
echo " Parameters for -b option: <path>,<type>,<namespaces>,<cmb>,<pmr_file[:pmr_size]>"
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