Commit db739e15 authored by Pawel Niedzwiecki's avatar Pawel Niedzwiecki Committed by Daniel Verkamp
Browse files

test/virtio: Add vhost initiator tests for pci mode



New tests are performed on guest vm where vhost scsi
controllers are presented as a virtual pci device.
Some changes in common.sh had to be made to allow to build
spdk on vm and to set queue number.

Change-Id: I8289d6aede6020e958c9e5aae893591d844cdbcf
Signed-off-by: default avatarPawel Niedzwiecki <pawelx.niedzwiecki@intel.com>
Reviewed-on: https://review.gerrithub.io/394248


Reviewed-by: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-by: default avatarKarol Latecki <karol.latecki@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
parent 4667c5cb
Loading
Loading
Loading
Loading
+13 −4
Original line number Diff line number Diff line
@@ -420,6 +420,8 @@ function vm_setup()
	local disks=""
	local raw_cache=""
	local force_vm=""
	local guest_memory=1024
	local queue_number=""
	while getopts ':-:' optchar; do
		case "$optchar" in
			-)
@@ -431,6 +433,8 @@ function vm_setup()
				disks=*) local disks="${OPTARG#*=}" ;;
				raw-cache=*) local raw_cache=",cache${OPTARG#*=}" ;;
				force=*) local force_vm=${OPTARG#*=} ;;
				memory=*) local guest_memory=${OPTARG#*=} ;;
				queue_num=*) local queue_number=${OPTARG#*=} ;;
				*)
					error "unknown argument $OPTARG"
					return 1
@@ -509,13 +513,18 @@ function vm_setup()
	do
		(($task_mask&1<<$cpu)) && ((cpu_num++)) || :
	done

	if [ -z $queue_number ]; then
		queue_number=$cpu_num
	fi

	$shell_restore_x

	#-cpu host
	local node_num=${!qemu_numa_node_param}
	notice "NUMA NODE: $node_num"
	cmd+="-m 1024 --enable-kvm -smp $cpu_num -vga std -vnc :$vnc_socket -daemonize -snapshot ${eol}"
	cmd+="-object memory-backend-file,id=mem,size=1G,mem-path=/dev/hugepages,share=on,prealloc=yes,host-nodes=$node_num,policy=bind ${eol}"
	cmd+="-m $guest_memory --enable-kvm -cpu host -smp $cpu_num -vga std -vnc :$vnc_socket -daemonize -snapshot ${eol}"
	cmd+="-object memory-backend-file,id=mem,size=${guest_memory}M,mem-path=/dev/hugepages,share=on,prealloc=yes,host-nodes=$node_num,policy=bind ${eol}"
	cmd+="-numa node,memdev=mem ${eol}"
	cmd+="-pidfile $qemu_pid_file ${eol}"
	cmd+="-serial file:$vm_dir/serial.log ${eol}"
@@ -564,7 +573,7 @@ function vm_setup()
			spdk_vhost_scsi)
				notice "using socket $SPDK_VHOST_SCSI_TEST_DIR/naa.$disk.$vm_num"
				cmd+="-chardev socket,id=char_$disk,path=$SPDK_VHOST_SCSI_TEST_DIR/naa.$disk.$vm_num ${eol}"
				cmd+="-device vhost-user-scsi-pci,id=scsi_$disk,num_queues=$cpu_num,chardev=char_$disk ${eol}"
				cmd+="-device vhost-user-scsi-pci,id=scsi_$disk,num_queues=$queue_number,chardev=char_$disk ${eol}"
				;;
			spdk_vhost_blk)
				[[ $disk =~ _size_([0-9]+[MG]?) ]] || true
@@ -575,7 +584,7 @@ function vm_setup()
				disk=${disk%%_*}
				notice "using socket $SPDK_VHOST_SCSI_TEST_DIR/naa.$disk.$vm_num"
				cmd+="-chardev socket,id=char_$disk,path=$SPDK_VHOST_SCSI_TEST_DIR/naa.$disk.$vm_num ${eol}"
				cmd+="-device vhost-user-blk-pci,num_queues=$cpu_num,chardev=char_$disk,"
				cmd+="-device vhost-user-blk-pci,num_queues=$queue_number,chardev=char_$disk,"
				cmd+="logical_block_size=4096,size=$size ${eol}"
				;;
			kernel_vhost)
+2 −2
Original line number Diff line number Diff line
@@ -3,11 +3,11 @@
  Queues 18

[VirtioUser1]
  Path naa.Malloc0.1
  Path naa.Malloc0.0
  Queues 18

[VirtioUser2]
  Path naa.Malloc1.2
  Path naa.Malloc1.0
  Queues 18

[Ioat]
+5 −0
Original line number Diff line number Diff line
[VirtioPci]
  Enable Yes

[Ioat]
  Disable Yes
+41 −6
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ RPC_PY="$ROOT_DIR/scripts/rpc.py"
FIO_BIN="/usr/src/fio/fio"
virtio_bdevs=""
virtio_with_unmap=""
os_image="/home/sys_sgsw/vhost_vm_image.qcow2"

function usage()
{
@@ -17,6 +18,7 @@ function usage()
	echo "Script for running vhost initiator tests."
	echo "Usage: $(basename $1) [-h|--help] [--fiobin=PATH]"
	echo "-h, --help            Print help and exit"
	echo "    --vm_image=PATH   Path to VM image used in these tests [default=/home/sys_sgsw/vhost_vm_image.qcow2]"
	echo "    --fiobin=PATH     Path to fio binary on host [default=/usr/src/fio/fio]"
}

@@ -26,6 +28,7 @@ while getopts 'h-:' optchar; do
		case "$OPTARG" in
			help) usage $0 && exit 0 ;;
			fiobin=*) FIO_BIN="${OPTARG#*=}" ;;
			vm_image=*) os_image="${OPTARG#*=}" ;;
			*) usage $0 echo "Invalid argument '$OPTARG'" && exit 1 ;;
		esac
		;;
@@ -68,12 +71,12 @@ function create_bdev_config()
	$RPC_PY add_vhost_scsi_lun naa.Nvme0n1.0 5 Nvme0n1p5

	$RPC_PY construct_malloc_bdev 128 512 --name Malloc0
	$RPC_PY construct_vhost_scsi_controller naa.Malloc0.1
	$RPC_PY add_vhost_scsi_lun naa.Malloc0.1 0 Malloc0
	$RPC_PY construct_vhost_scsi_controller naa.Malloc0.0
	$RPC_PY add_vhost_scsi_lun naa.Malloc0.0 0 Malloc0

	$RPC_PY construct_malloc_bdev 128 4096 --name Malloc1
	$RPC_PY construct_vhost_scsi_controller naa.Malloc1.2
	$RPC_PY add_vhost_scsi_lun naa.Malloc1.2 0 Malloc1
	$RPC_PY construct_vhost_scsi_controller naa.Malloc1.0
	$RPC_PY add_vhost_scsi_lun naa.Malloc1.0 0 Malloc1

	vbdevs=$(discover_bdevs $ROOT_DIR $BASE_DIR/bdev.conf)
	virtio_bdevs=$(jq -r '[.[].name] | join(":")' <<< $vbdevs)
@@ -99,6 +102,38 @@ run_spdk_fio $BASE_DIR/bdev.fio --filename=$virtio_with_unmap --spdk_conf=$BASE_
	--spdk_conf=$BASE_DIR/bdev.conf
timing_exit run_spdk_fio_unmap

timing_enter setup_vm
vm_no="0"
vm_setup --disk-type=spdk_vhost_scsi --force=$vm_no --os=$os_image --disks="Nvme0n1:Malloc0:Malloc1" --queue_num=18 --memory=6144
vm_run $vm_no
vm_wait_for_boot 600 $vm_no
vm_scp $vm_num -r $ROOT_DIR "127.0.0.1:/root/spdk"
vm_ssh $vm_num " cd spdk ; make clean ; ./configure --with-fio=/root/fio_src ; make -j2"
vm_ssh $vm_num "/root/spdk/scripts/setup.sh"
vbdevs=$(vm_ssh $vm_num ". /root/spdk/scripts/autotest_common.sh && discover_bdevs /root/spdk \
 /root/spdk/test/vhost/initiator/bdev_pci.conf")
virtio_bdevs=$(jq -r '[.[].name] | join(":")' <<< $vbdevs)
virtio_with_unmap=$(jq -r '[.[] | select(.supported_io_types.unmap==true).name]
 | join(":")' <<< $vbdevs)
timing_exit setup_vm

timing_enter run_spdk_fio_pci
vm_ssh $vm_num "LD_PRELOAD=/root/spdk/examples/bdev/fio_plugin/fio_plugin /root/fio_src/fio --ioengine=spdk_bdev \
 /root/spdk/test/vhost/initiator/bdev.fio --filename=$virtio_bdevs --section=job_randwrite \
 --section=job_randrw --section=job_write --section=job_rw \
 --spdk_conf=/root/spdk/test/vhost/initiator/bdev_pci.conf --spdk_mem=1024"
timing_exit run_spdk_fio_pci

timing_enter run_spdk_fio_pci_unmap
vm_ssh $vm_num "LD_PRELOAD=/root/spdk/examples/bdev/fio_plugin/fio_plugin /root/fio_src/fio --ioengine=spdk_bdev \
 /root/spdk/test/vhost/initiator/bdev.fio --filename=$virtio_with_unmap \
 --spdk_conf=/root/spdk/test/vhost/initiator/bdev_pci.conf --spdk_mem=1024"
timing_exit run_spdk_fio_pci_unmap

timing_enter vm_shutdown_all
vm_shutdown_all
timing_exit vm_shutdown_all

rm -f *.state
timing_enter spdk_vhost_kill
spdk_vhost_kill