test/vhost: Simplify disk image check for virtio

Signed-off-by: Michal Berger <michal.berger@intel.com>
Change-Id: I23b206b026dec0cb9e91226aa2ee2de91eebde6e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/13904
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
This commit is contained in:
Michal Berger 2022-08-08 16:25:27 +02:00 committed by Tomasz Zawadzki
parent 87c8a57e6f
commit bf93cbdfc5

View File

@ -701,26 +701,13 @@ function vm_setup() {
local raw_name="RAWSCSI"
local raw_disk=$vm_dir/test.img
if [[ -n $disk ]]; then
[[ ! -b $disk ]] && touch $disk
local raw_disk
raw_disk=$(readlink -f $disk)
fi
# Create disk file if it not exist or it is smaller than 1G
if { [[ -f $raw_disk ]] && [[ $(stat --printf="%s" $raw_disk) -lt $((1024 * 1024 * 1024)) ]]; } \
|| [[ ! -e $raw_disk ]]; then
if [[ $raw_disk =~ /dev/.* ]]; then
error \
"ERROR: Virtio disk point to missing device ($raw_disk) -\n" \
" this is probably not what you want."
return 1
fi
if [[ -f $disk && $(stat --printf="%s" $disk) -ge $((1024 * 1024 * 1024)) ]]; then
raw_disk=$disk
notice "Using existing image $raw_disk"
else
notice "Creating Virtio disc $raw_disk"
dd if=/dev/zero of=$raw_disk bs=1024k count=1024
else
notice "Using existing image $raw_disk"
fi
cmd+=(-device "virtio-scsi-pci,num_queues=$queue_number")