From patchwork Wed Apr 13 08:57:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olaf Hering X-Patchwork-Id: 8819661 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0D1AFC0553 for ; Wed, 13 Apr 2016 08:59:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id ADD7420270 for ; Wed, 13 Apr 2016 08:59:33 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94EF7201FE for ; Wed, 13 Apr 2016 08:59:32 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqGbs-0004e0-OA; Wed, 13 Apr 2016 08:57:16 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aqGbs-0004dk-6H for xen-devel@lists.xen.org; Wed, 13 Apr 2016 08:57:16 +0000 Received: from [193.109.254.147] by server-7.bemta-14.messagelabs.com id C1/2F-03757-BE90E075; Wed, 13 Apr 2016 08:57:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsUSuHLSAt1XnHz hBk96NCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1ox/d+eyFHzTrZg+/xVjA+MM9S5GLg4WgcXM EleOfmDtYuTkkBDIldi5uIWxi5EDyBaRePI/DaRGSOA0k8SrjgusIHEhgXSJeUcDQcrZBJQk9 h48zghiiwhIS1z7fBnMZhZQkHjxfCsTiC0skCTxZPMiFhCbRUBVYuOBA2BxXgE7iWeHXrNDrJ WTuDz9ARuIzSlgL9HwtAksLgRUc+/bLVaIekGJkzOfsEDMl5do3jqbeQKjwCwkqVlIUgsYmVY xqhenFpWlFuka6yUVZaZnlOQmZuboGhqa6OWmFhcnpqfmJCYV6yXn525iBIYgAxDsYLzb53yI UZKDSUmUd8ov3nAhvqT8lMqMxOKM+KLSnNTiQ4wyHBxKErz3OfjChQSLUtNTK9Iyc4DRAJOW4 OBREuF9BJLmLS5IzC3OTIdInWLU5diy4MZaJiGWvPy8VClx3laQIgGQoozSPLgRsMi8xCgrJc zLCHSUEE9BalFuZgmq/CtGcQ5GJWHeFSBTeDLzSuA2vQI6ggnoiLJ3vCBHlCQipKQaGIV5mLJ 64p6YOul0BN/P1t13/JORU9oroUe7TATKor+Vftr2UeDJWru7bE/vvC99tPPyTJYY/p1/QlRf djM3P/W3KzTyW/K4KaxQ5KotN7tRuF5SdMiu2+E78857bL4pvFd+wXu9x1wmAtf4O7YsathXs 6/yy0XLm3PviLz5sdGz7sADXWfpc0osxRmJhlrMRcWJAMBrO67HAgAA X-Env-Sender: olaf@aepfle.de X-Msg-Ref: server-15.tower-27.messagelabs.com!1460537834!35287371!1 X-Originating-IP: [81.169.146.160] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: QmFkIElQOiA4MS4xNjkuMTQ2LjE2MCA9PiA1NTc3MTg=\n,sa_preprocessor: QmFkIElQOiA4MS4xNjkuMTQ2LjE2MCA9PiA1NTc3MTg=\n X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 50677 invoked from network); 13 Apr 2016 08:57:14 -0000 Received: from mo4-p00-ob.smtp.rzone.de (HELO mo4-p00-ob.smtp.rzone.de) (81.169.146.160) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 13 Apr 2016 08:57:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1460537834; l=5960; s=domk; d=aepfle.de; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Date: Subject:Cc:To:From; bh=QxMoOLX5EGZCHTzy9jar6tzyPtn9fd3MeJrsVAxP7s8=; b=EfNb6VhOVI5W5X0JeswVZTXms6+cbBQzU1/b934yS5Hnwged/pY4B+C0n9yrrS9eyk8 y+6rDBMf+2sNamFWGCP0yfvPe4hUdG3M8LPE5gyzsOkl8K+OhPitirpuAe2ajh2e7OqKB rynG2komDpSb3bh5JKDToGFUrBJuM0s/heI= X-RZG-AUTH: :P2EQZWCpfu+qG7CngxMFH1J+yackYocTD1iAi8x+OWi/zfN1cLnDYUgpTlWBkNW9Bx8xXwfuBtpmvNujsrm6sfmqf16ArQ== X-RZG-CLASS-ID: mo00 Received: from probook ([2001:a62:1211:7eff:9897:cf60:7e77:7275]) by smtp.strato.de (RZmta 37.23 AUTH) with ESMTPSA id L07326s3D8vDBLl (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (curve secp521r1 with 521 ECDH bits, eq. 15360 bits RSA)) (Client did not present a certificate); Wed, 13 Apr 2016 10:57:13 +0200 (CEST) Received: by probook (Postfix, from userid 1000) id A80775093F; Wed, 13 Apr 2016 10:57:13 +0200 (CEST) From: Olaf Hering To: xen-devel@lists.xen.org Date: Wed, 13 Apr 2016 08:57:00 +0000 Message-Id: <1460537820-15398-3-git-send-email-olaf@aepfle.de> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1460537820-15398-1-git-send-email-olaf@aepfle.de> References: <1460537820-15398-1-git-send-email-olaf@aepfle.de> MIME-Version: 1.0 Cc: Olaf Hering Subject: [Xen-devel] [PATCH v12 2/2] Scripts to create and delete xen-scsiback nodes in Linux target framework X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Just to make them public, not meant for merging: The scripts used during development to create a bunch of SCSI devices in dom0 using the Linux target framework. targetcli3 and rtslib3 is used. A patch is required for python-rtslib: http://article.gmane.org/gmane.linux.scsi.target.devel/8146 These scripts are not use by libxl. These scripts are meant for testing vscsi= in libxl Signed-off-by: Olaf Hering --- tools/misc/Makefile | 4 + tools/misc/target-create-xen-scsiback.sh | 135 +++++++++++++++++++++++++++++++ tools/misc/target-delete-xen-scsiback.sh | 41 ++++++++++ 3 files changed, 180 insertions(+) diff --git a/tools/misc/Makefile b/tools/misc/Makefile index a94dad9..035b585 100644 --- a/tools/misc/Makefile +++ b/tools/misc/Makefile @@ -36,6 +36,8 @@ INSTALL_SBIN += $(INSTALL_SBIN-y) # Everything to be installed in a private bin/ INSTALL_PRIVBIN += xenpvnetboot +INSTALL_PRIVBIN += target-create-xen-scsiback.sh +INSTALL_PRIVBIN += target-delete-xen-scsiback.sh # Everything to be installed TARGETS_ALL := $(INSTALL_BIN) $(INSTALL_SBIN) $(INSTALL_PRIVBIN) @@ -46,6 +48,8 @@ TARGETS_COPY += xen-ringwatch TARGETS_COPY += xencons TARGETS_COPY += xencov_split TARGETS_COPY += xenpvnetboot +TARGETS_COPY += target-create-xen-scsiback.sh +TARGETS_COPY += target-delete-xen-scsiback.sh # Everything which needs to be built TARGETS_BUILD := $(filter-out $(TARGETS_COPY),$(TARGETS_ALL)) diff --git a/tools/misc/target-create-xen-scsiback.sh b/tools/misc/target-create-xen-scsiback.sh new file mode 100755 index 0000000..d014a0a --- /dev/null +++ b/tools/misc/target-create-xen-scsiback.sh @@ -0,0 +1,135 @@ +#!/usr/bin/env bash +unset LANG +unset ${!LC_*} +set -x +set -e + +modprobe --version +targetcli --version +udevadm --version +blockdev --version +parted --version +sfdisk --version +mkswap --version + +configfs=/sys/kernel/config +target_path=$configfs/target + +num_luns=4 +num_hosts=4 + +case "$1" in + -p) + backend="pvops" + ;; + -x) + backend="xenlinux" + ;; + *) + : "usage: $0 [-p|-x]" + if grep -qw xenfs$ /proc/filesystems + then + backend="pvops" + else + backend="xenlinux" + fi + ;; +esac + +get_wwn() { + sed ' + s@-@@g + s@^\(.\{16\}\)\(.*\)@\1@ + ' /proc/sys/kernel/random/uuid +} + +if test ! -d "${target_path}" +then + modprobe -v configfs + mount -vt configfs configfs $configfs + modprobe -v target_core_mod +fi +if test "${backend}" = "pvops" +then + modprobe -v xen-scsiback +fi + +host=0 +while test $host -lt $num_hosts +do + host=$(( $host + 1 )) + lun=0 + loopback_wwn="naa.`get_wwn`" + pvscsi_wwn="naa.`get_wwn`" + targetcli /loopback create ${loopback_wwn} + if test "${backend}" = "pvops" + then + targetcli /xen-pvscsi create ${pvscsi_wwn} + fi + while test $lun -lt $num_luns + do + : h $host l $lun + f_file=/dev/shm/Fileio.${host}.${lun}.file + f_uuid=/dev/shm/Fileio.${host}.${lun}.uuid + f_link=/dev/shm/Fileio.${host}.${lun}.link + fileio_name="fio_${host}.${lun}" + pscsi_name="ps_${host}.${lun}" + + targetcli /backstores/fileio create name=${fileio_name} "file_or_dev=${f_file}" size=$((1024*1024 * 8 )) sparse=true + targetcli /loopback/${loopback_wwn}/luns create /backstores/fileio/${fileio_name} $lun + + vpd_uuid="`sed -n '/^T10 VPD Unit Serial Number:/s@^[^:]\+:[[:blank:]]\+@@p' /sys/kernel/config/target/core/fileio_*/${fileio_name}/wwn/vpd_unit_serial`" + if test -z "${vpd_uuid}" + then + exit 1 + fi + echo "${vpd_uuid}" > "${f_uuid}" + by_id="`echo ${vpd_uuid} | sed 's@-@@g;s@^\(.\{25\}\)\(.*\)@scsi-36001405\1@'`" + udevadm settle --exit-if-exists="/dev/disk/by-id/${by_id}" + ln -sfvbn "/dev/disk/by-id/${by_id}" "${f_link}" + + f_major=$((`stat --dereference --format=0x%t "${f_link}"`)) + f_minor=$((`stat --dereference --format=0x%T "${f_link}"`)) + if test -z "${f_major}" || test -z "${f_minor}" + then + exit 1 + fi + f_alias=`ls -d /sys/dev/block/${f_major}:${f_minor}/device/scsi_device/*:*:*:*` + if test -z "${f_alias}" + then + exit 1 + fi + f_alias=${f_alias##*/} + + blockdev --rereadpt "${f_link}" + udevadm settle + echo 1,96,S | sfdisk "${f_link}" + udevadm settle + blockdev --rereadpt "${f_link}" + udevadm settle + parted -s "${f_link}" unit s print + + d_link="`readlink \"${f_link}\"`" + if test -n "${d_link}" + then + p_link="${d_link}-part1" + udevadm settle --exit-if-exists="${p_link}" + ls -l "${p_link}" + mkswap -L "swp_${fileio_name}" "${p_link}" + udevadm settle + blockdev --rereadpt "${f_link}" + udevadm settle + parted -s "${f_link}" unit s print + fi + + targetcli /backstores/pscsi create "dev=${f_link}" "${pscsi_name}" + if test "${backend}" = "pvops" + then + targetcli /xen-pvscsi/${pvscsi_wwn}/tpg1/luns create "/backstores/pscsi/${pscsi_name}" $lun + targetcli /xen-pvscsi/${pvscsi_wwn}/tpg1 set parameter alias=${f_alias%:*} + fi + + lun=$(( $lun + 1 )) + done +done + diff --git a/tools/misc/target-delete-xen-scsiback.sh b/tools/misc/target-delete-xen-scsiback.sh new file mode 100755 index 0000000..5b6dc54 --- /dev/null +++ b/tools/misc/target-delete-xen-scsiback.sh @@ -0,0 +1,41 @@ +#!/usr/bin/env bash +unset LANG +unset ${!LC_*} +set -x +set -e + +targetcli --version + +configfs=/sys/kernel/config +target_path=$configfs/target + +cd "${target_path}" +if cd xen-pvscsi +then + for wwn in `ls -d naa.*` + do + targetcli /xen-pvscsi delete $wwn + done +fi +cd "${target_path}" +cd core +for name in `ls -d pscsi_*/*/wwn` +do + name=${name%/wwn} + name=${name##*/} + targetcli /backstores/pscsi delete $name +done +cd "${target_path}" +cd loopback +for wwn in `ls -d naa.*` +do + targetcli /loopback delete $wwn +done +cd "${target_path}" +cd core +for name in `ls -d fileio_*/*/wwn` +do + name=${name%/wwn} + name=${name##*/} + targetcli /backstores/fileio delete $name +done