test/vhost: simplify autotest.config

Convert autotest.config to a sourceable file. This enables direct or
indirect usage of variables and a chance to remove error prone
statements like '$(cat | grep | awk')'

Change-Id: I3ae4152fd7548e4b2bfd01c00b614155871b2db3
Signed-off-by: Pawel Wodkowski <pawelx.wodkowski@intel.com>
This commit is contained in:
Pawel Wodkowski 2017-04-27 18:34:55 +02:00 committed by Daniel Verkamp
parent a160dfdf80
commit 6999fc24cc
3 changed files with 26 additions and 14 deletions

View File

@ -1,5 +1,5 @@
vhost_reactor_mask=0x1
vhost_master_core=0
qemu_mask=0x2
qemu_numa_node=0
VM_0_qemu_mask=0x2
VM_0_qemu_numa_node=0

View File

@ -155,11 +155,9 @@ for vm_conf in ${vms[@]}; do
echo "INFO: Adding device via RPC ..."
echo ""
eval $(grep "^vhost_reactor_mask=" $BASE_DIR/autotest.config)
while IFS=':' read -ra disks; do
for disk in "${disks[@]}"; do
$rpc_py construct_vhost_scsi_controller naa.$disk.${conf[0]} \
--cpumask $vhost_reactor_mask
$rpc_py construct_vhost_scsi_controller naa.$disk.${conf[0]}
$rpc_py add_vhost_scsi_lun naa.$disk.${conf[0]} 0 $disk
done
done <<< "${conf[2]}"
@ -197,7 +195,10 @@ DISK=""
for vm_num in $used_vms; do
vm_dir=$VM_BASE_DIR/$vm_num
host_name="VM-$vm_num-$(cat $BASE_DIR/autotest.config|grep qemu_mask|awk -F'=' '{print $2}'|sed "$(($vm_num+1))q;d")"
qemu_mask_param="VM_${vm_num}_qemu_mask"
host_name="VM-$vm_num-${!qemu_mask_param}"
echo "INFO: Setting up hostname: $host_name"
vm_ssh $vm_num "hostname $host_name"
vm_start_fio_server $fio_bin $readonly $vm_num

View File

@ -38,9 +38,7 @@ INSTALL_DIR="$TEST_DIR/root"
mkdir -p $TEST_DIR
###
# Building functions
###
. $BASE_DIR/autotest.config
function error()
{
@ -131,12 +129,15 @@ function spdk_vhost_run()
return 1
fi
if [[ -z "$vhost_reactor_mask" ]] || [[ -z "$vhost_master_core" ]]; then
error "Parameters vhost_reactor_mask or vhost_master_core not found in autotest.config file"
return 1
fi
cp $vhost_conf_template $vhost_conf_file
$BASE_DIR/../../../scripts/gen_nvme.sh >> $vhost_conf_file
local cmd="$vhost_app -m $(cat $BASE_DIR/autotest.config|grep vhost_reactor_mask|awk -F'=' '{print $2}') \
-p $(cat $BASE_DIR/autotest.config|grep vhost_master_core|awk -F'=' '{print $2}') \
-c $vhost_conf_file"
local cmd="$vhost_app -m $vhost_reactor_mask -p $vhost_master_core -c $vhost_conf_file"
echo "INFO: Loging to: $vhost_log_file"
echo "INFO: Config file: $vhost_conf_file"
@ -433,11 +434,21 @@ function vm_setup()
error "file not found: $os"
return 1
fi
# WARNING:
# each cmd+= must contain ' ${eol}' at the end
#
local eol="\\\\\n "
local task_mask=$(cat $BASE_DIR/autotest.config|grep qemu_mask|awk -F'=' '{print $2}'|sed "$(($vm_num+1))q;d")
local qemu_mask_param="VM_${vm_num}_qemu_mask"
local qemu_numa_node_param="VM_${vm_num}_qemu_numa_node"
if [[ -z "${!qemu_mask_param}" ]] || [[ -z "${!qemu_numa_node_param}" ]]; then
error "Parameters ${qemu_mask_param} or ${qemu_numa_node_param} not found in autotest.config file"
return 1
fi
local task_mask=${!qemu_mask_param}
echo "INFO: TASK MASK: $task_mask"
local cmd="taskset -a $task_mask $INSTALL_DIR/bin/qemu-system-x86_64 ${eol}"
@ -458,7 +469,7 @@ function vm_setup()
done
#-cpu host
local node_num=$(cat $BASE_DIR/autotest.config|grep qemu_numa_node|awk -F'=' '{print $2}'|sed "$(($vm_num+1))q;d")
local node_num=${!qemu_numa_node_param}
echo "INFO: 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}"