test/bdev: Move part_dev_by_gpt() into blockdev.sh

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: I9a888f80148d5fd2eec5feed299b0c81bb78b984
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1282
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Michal Berger 2020-03-16 13:39:35 +01:00 committed by Tomasz Zawadzki
parent 1db267cf0d
commit 004b52fe6c
2 changed files with 55 additions and 54 deletions

View File

@ -61,6 +61,61 @@ function setup_nvme_conf() {
"$rootdir/scripts/gen_nvme.sh" --json | "$rpc_py" load_subsystem_config
}
function part_dev_by_gpt () {
if [ $(uname -s) = Linux ] && hash sgdisk && modprobe nbd; then
conf=$1
devname=$2
rootdir=$3
operation=$4
local nbd_path=/dev/nbd0
local rpc_server=/var/tmp/spdk-gpt-bdevs.sock
if [ ! -e $conf ]; then
return 1
fi
if [ -z "$operation" ]; then
operation="create"
fi
cp $conf ${conf}.gpt
echo "[Gpt]" >> ${conf}.gpt
echo " Disable Yes" >> ${conf}.gpt
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 -c ${conf}.gpt &
nbd_pid=$!
echo "Process nbd pid: $nbd_pid"
waitforlisten $nbd_pid $rpc_server
# Start bdev as an nbd device
nbd_start_disks "$rpc_server" $devname $nbd_path
waitfornbd ${nbd_path:5}
if [ "$operation" = create ]; then
parted -s $nbd_path mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%'
# change the GUID to SPDK GUID value
SPDK_GPT_GUID=$(grep SPDK_GPT_PART_TYPE_GUID $rootdir/module/bdev/gpt/gpt.h \
| awk -F "(" '{ print $2}' | sed 's/)//g' \
| awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g')
sgdisk -t 1:$SPDK_GPT_GUID $nbd_path
sgdisk -t 2:$SPDK_GPT_GUID $nbd_path
elif [ "$operation" = reset ]; then
# clear the partition table
dd if=/dev/zero of=$nbd_path bs=4096 count=8 oflag=direct
fi
nbd_stop_disks "$rpc_server" $nbd_path
killprocess $nbd_pid
rm -f ${conf}.gpt
fi
return 0
}
function setup_gpt_conf() {
# FIXME: Remove this
if [[ $1 == reset ]]; then

View File

@ -758,60 +758,6 @@ function print_backtrace() {
return 0
}
function part_dev_by_gpt () {
if [ $(uname -s) = Linux ] && hash sgdisk && modprobe nbd; then
conf=$1
devname=$2
rootdir=$3
operation=$4
local nbd_path=/dev/nbd0
local rpc_server=/var/tmp/spdk-gpt-bdevs.sock
if [ ! -e $conf ]; then
return 1
fi
if [ -z "$operation" ]; then
operation="create"
fi
cp $conf ${conf}.gpt
echo "[Gpt]" >> ${conf}.gpt
echo " Disable Yes" >> ${conf}.gpt
$rootdir/test/app/bdev_svc/bdev_svc -r $rpc_server -i 0 -c ${conf}.gpt &
nbd_pid=$!
echo "Process nbd pid: $nbd_pid"
waitforlisten $nbd_pid $rpc_server
# Start bdev as an nbd device
nbd_start_disks "$rpc_server" $devname $nbd_path
waitfornbd ${nbd_path:5}
if [ "$operation" = create ]; then
parted -s $nbd_path mklabel gpt mkpart first '0%' '50%' mkpart second '50%' '100%'
# change the GUID to SPDK GUID value
SPDK_GPT_GUID=$(grep SPDK_GPT_PART_TYPE_GUID $rootdir/module/bdev/gpt/gpt.h \
| awk -F "(" '{ print $2}' | sed 's/)//g' \
| awk -F ", " '{ print $1 "-" $2 "-" $3 "-" $4 "-" $5}' | sed 's/0x//g')
sgdisk -t 1:$SPDK_GPT_GUID $nbd_path
sgdisk -t 2:$SPDK_GPT_GUID $nbd_path
elif [ "$operation" = reset ]; then
# clear the partition table
dd if=/dev/zero of=$nbd_path bs=4096 count=8 oflag=direct
fi
nbd_stop_disks "$rpc_server" $nbd_path
killprocess $nbd_pid
rm -f ${conf}.gpt
fi
return 0
}
function discover_bdevs()
{
local rootdir=$1