script/vagrant: split into functions - setup disks functions
Signed-off-by: Pawel Piatek <pawelx.piatek@intel.com> Change-Id: Ibbb6ab720dc8a95bcb1daebc3f8f555c3fce69c4 Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3715 Community-CI: Mellanox Build Bot Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Karol Latecki <karol.latecki@intel.com> Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>
This commit is contained in:
parent
dc7f3206a1
commit
221c5b5ee2
86
scripts/vagrant/Vagrantfile
vendored
86
scripts/vagrant/Vagrantfile
vendored
@ -124,6 +124,58 @@ def clear_cflags(config)
|
||||
config.vm.provision "shell", inline: $clearcflags_cmd, run: "always"
|
||||
end
|
||||
|
||||
def get_nvme_disk(disk, index)
|
||||
if ENV['NVME_FILE']
|
||||
nvme_file = ENV['NVME_FILE'].split(',')
|
||||
nvme_disk = nvme_file[index]
|
||||
else
|
||||
nvme_disk = '/var/lib/libvirt/images/nvme_disk.img'
|
||||
end
|
||||
|
||||
unless File.exist? (nvme_disk)
|
||||
puts 'If run with libvirt provider please execute create_nvme_img.sh'
|
||||
end
|
||||
|
||||
return nvme_disk
|
||||
end
|
||||
|
||||
def setup_nvme_disk(libvirt, disk, index)
|
||||
nvme_disk_id = disk + '-' + index.to_s
|
||||
nvme_disk = get_nvme_disk(disk, index)
|
||||
|
||||
nvme_namespaces=(ENV['NVME_DISKS_NAMESPACES'] || "").split(',')
|
||||
nvme_cmbs=(ENV['NVME_CMB'] || "").split(',')
|
||||
|
||||
libvirt.qemuargs :value => "-drive"
|
||||
libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}"
|
||||
libvirt.qemuargs :value => "-device"
|
||||
nvme_drive = "nvme,drive=#{nvme_disk_id},serial=1234#{index}"
|
||||
if !nvme_namespaces[index].nil? && nvme_namespaces[index] != 1
|
||||
nvme_drive << ",namespaces=#{nvme_namespaces[index]}"
|
||||
end
|
||||
|
||||
if !nvme_cmbs[index].nil? && nvme_cmbs[index] == "true"
|
||||
# Fix the size of the buffer to 128M
|
||||
nvme_drive << ",cmb_size_mb=128"
|
||||
end
|
||||
libvirt.qemuargs :value => nvme_drive
|
||||
end
|
||||
|
||||
def setup_ocssd_disk(libvirt, disk, index)
|
||||
nvme_disk_id = disk + '-' + index.to_s
|
||||
nvme_disk = get_nvme_disk(disk, index)
|
||||
|
||||
libvirt.qemuargs :value => "-drive"
|
||||
libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}"
|
||||
libvirt.qemuargs :value => "-device"
|
||||
# create ocssd drive with special parameters
|
||||
# lba_index=4 it is LBA namespace format, 4 means that block size is 4K and have 64B metadata
|
||||
# lnum_lun, lnum_pln, lpgs_per_blk, lsecs_per_pg, lblks_per_pln this are parameters describing the device geometry
|
||||
# we need to multiply these parameters by ourselves to have backend file minimal size:
|
||||
# in our case: 4K * 8 * 2 * 1536 * 2 * 45 = 8640 MB
|
||||
libvirt.qemuargs :value => "nvme,drive=#{nvme_disk_id},serial=deadbeef,oacs=0,namespaces=1,lver=2,lba_index=4,mdts=10,lnum_lun=8,lnum_pln=2,lpgs_per_blk=1536,lsecs_per_pg=2,lblks_per_pln=45,metadata=#{nvme_disk}_ocssd_md,nsdatafile=#{nvme_disk}_ocssd_blknvme.ns,laer_thread_sleep=3000,stride=4"
|
||||
end
|
||||
|
||||
Vagrant.configure(2) do |config|
|
||||
|
||||
# Pick the right distro and bootstrap, default is fedora30
|
||||
@ -252,40 +304,10 @@ Vagrant.configure(2) do |config|
|
||||
|
||||
# Loop to create all emulated disks set
|
||||
emulated_nvme_types.each_with_index { |disk, index|
|
||||
if ENV['NVME_FILE']
|
||||
nvme_disk_id = disk + "-" + index.to_s
|
||||
nvme_disk = nvme_file[index]
|
||||
else
|
||||
nvme_disk = "/var/lib/libvirt/images/nvme_disk.img"
|
||||
end
|
||||
|
||||
unless File.exist? (nvme_disk)
|
||||
puts "If run with libvirt provider please execute create_nvme_img.sh"
|
||||
end
|
||||
|
||||
if disk == "nvme"
|
||||
libvirt.qemuargs :value => "-drive"
|
||||
libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}"
|
||||
libvirt.qemuargs :value => "-device"
|
||||
nvme_drive = "nvme,drive=#{nvme_disk_id},serial=1234#{index}"
|
||||
if !nvme_namespaces[index].nil? && nvme_namespaces[index] != 1
|
||||
nvme_drive << ",namespaces=#{nvme_namespaces[index]}"
|
||||
end
|
||||
if !nvme_cmbs[index].nil? && nvme_cmbs[index] == "true"
|
||||
# Fix the size of the buffer to 128M
|
||||
nvme_drive << ",cmb_size_mb=128"
|
||||
end
|
||||
libvirt.qemuargs :value => nvme_drive
|
||||
setup_nvme_disk(libvirt, disk, index)
|
||||
elsif disk == "ocssd"
|
||||
libvirt.qemuargs :value => "-drive"
|
||||
libvirt.qemuargs :value => "format=raw,file=#{nvme_disk},if=none,id=#{nvme_disk_id}"
|
||||
libvirt.qemuargs :value => "-device"
|
||||
# create ocssd drive with special parameters
|
||||
# lba_index=4 it is LBA namespace format, 4 means that block size is 4K and have 64B metadata
|
||||
# lnum_lun, lnum_pln, lpgs_per_blk, lsecs_per_pg, lblks_per_pln this are parameters describing the device geometry
|
||||
# we need to multiply these parameters by ourselves to have backend file minimal size:
|
||||
# in our case: 4K * 8 * 2 * 1536 * 2 * 45 = 8640 MB
|
||||
libvirt.qemuargs :value => "nvme,drive=#{nvme_disk_id},serial=deadbeef,oacs=0,namespaces=1,lver=2,lba_index=4,mdts=10,lnum_lun=8,lnum_pln=2,lpgs_per_blk=1536,lsecs_per_pg=2,lblks_per_pln=45,metadata=#{nvme_disk}_ocssd_md,nsdatafile=#{nvme_disk}_ocssd_blknvme.ns,laer_thread_sleep=3000,stride=4"
|
||||
setup_ocssd_disk(libvirt, disk, index)
|
||||
end
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user