From: Ian Campbell <ian.campbell@citrix.com>
To: Olaf Hering <olaf@aepfle.de>
Cc: xen-devel@lists.xen.org
Subject: Re: [PATCH v5 5/5] Scripts to create and delete xen-scsiback nodes in Linux target framework
Date: Wed, 13 May 2015 15:18:48 +0100 [thread overview]
Message-ID: <1431526728.8263.291.camel@citrix.com> (raw)
In-Reply-To: <1430918892-20928-6-git-send-email-olaf@aepfle.de>
On Wed, 2015-05-06 at 13:28 +0000, Olaf Hering wrote:
> 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.
I'm not sure what this is all about, but is there anything end-user-ish
which ought to be documented or put on the wiki or something?
>
> A patch is required for python-rtslib:
> http://article.gmane.org/gmane.linux.scsi.target.devel/8146
>
> Signed-off-by: Olaf Hering <olaf@aepfle.de>
> ---
> 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 ccd36af..be101d8 100644
> --- a/tools/misc/Makefile
> +++ b/tools/misc/Makefile
> @@ -32,6 +32,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)
> @@ -42,6 +44,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..96d4c39
> --- /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
> +
> + udevadm settle --timeout=4
> +
> + 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@'`"
> + 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 --timeout=4
> + echo 1,12,S | sfdisk "${f_link}"
> + udevadm settle --timeout=4
> + blockdev --rereadpt "${f_link}"
> + udevadm settle --timeout=4
> + parted -s "${f_link}" unit s print
> +
> + d_link="`readlink \"${f_link}\"`"
> + if test -n "${d_link}"
> + then
> + p_link="${d_link}-part1"
> + ls -l "${p_link}"
> + mkswap -L "swp_${fileio_name}" "${p_link}"
> + udevadm settle --timeout=4
> + blockdev --rereadpt "${f_link}"
> + udevadm settle --timeout=4
> + 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
>
> _______________________________________________
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2015-05-13 14:18 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-06 13:28 [PATCH v5 0/5] libbxl: add support for pvscsi, iteration 5 Olaf Hering
2015-05-06 13:28 ` [PATCH v5 1/5] vscsiif.h: fix WWN notation for p-dev property Olaf Hering
2015-05-13 14:11 ` Ian Campbell
2015-05-06 13:28 ` [PATCH v5 2/5] docs: add vscsi to xenstore-paths.markdown Olaf Hering
2015-05-13 14:12 ` Ian Campbell
2015-05-06 13:28 ` [PATCH v5 3/5] libxl: add support for vscsi Olaf Hering
2015-05-13 14:23 ` Ian Campbell
2015-05-15 6:29 ` Olaf Hering
2015-05-13 14:44 ` Ian Campbell
2015-05-13 15:12 ` Ian Campbell
2015-05-13 17:31 ` Olaf Hering
2015-05-15 4:11 ` Jürgen Groß
2015-05-15 5:58 ` Olaf Hering
2015-05-15 8:47 ` Ian Campbell
2015-05-15 9:35 ` Juergen Gross
2015-05-15 9:46 ` Ian Campbell
2015-05-15 9:48 ` Ian Campbell
2015-05-13 17:56 ` George Dunlap
2015-05-13 15:24 ` Olaf Hering
2015-05-06 13:28 ` [PATCH v5 4/5] vscsiif.h: add some notes about xenstore layout Olaf Hering
2015-05-13 14:14 ` Ian Campbell
2015-05-06 13:28 ` [PATCH v5 5/5] Scripts to create and delete xen-scsiback nodes in Linux target framework Olaf Hering
2015-05-13 14:18 ` Ian Campbell [this message]
2015-05-13 14:37 ` Olaf Hering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431526728.8263.291.camel@citrix.com \
--to=ian.campbell@citrix.com \
--cc=olaf@aepfle.de \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.