From: Olaf Hering Subject: [PATCH v3 3/4] docs: add pvscsi.txt Date: Fri, 6 Mar 2015 10:45:55 +0100 Message-ID: <1425635156-2357-4-git-send-email-olaf@aepfle.de> References: <1425635156-2357-1-git-send-email-olaf@aepfle.de> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1425635156-2357-1-git-send-email-olaf@aepfle.de> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel@lists.xen.org Cc: Olaf Hering , Keir Fraser , Ian Campbell , Tim Deegan , Ian Jackson , Jan Beulich List-Id: xen-devel@lists.xenproject.org Signed-off-by: Olaf Hering Cc: Ian Campbell Cc: Ian Jackson Cc: Jan Beulich Cc: Keir Fraser Cc: Tim Deegan --- docs/misc/pvscsi.txt | 188 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+) diff --git a/docs/misc/pvscsi.txt b/docs/misc/pvscsi.txt new file mode 100644 index 0000000..988a12b --- /dev/null +++ b/docs/misc/pvscsi.txt @@ -0,0 +1,188 @@ +. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . +PVSCSI + +== Overview == + +PVSCSI allows to assing a "physical" SCSI device from dom0 to a domU. The device +is not limited to be a native SCSI device. Everything visible as SCSI device in +dom0 can be used. Currently PVSCSI is only available in Linux dom0 and domU. + +== TODO === + +How to do live migration? + - pdev will likely be evaluated again on the target host if it came from + domU.cfg. But what about pdev from 'xl scsi-attach pdev vdev'? Its required + to adjust h:c:t:l on the target host. + +How to handle FIXME in libxl_retrieve_domain_configuration? + - "MERGE(vscsi, vscsis, COMPARE_DEVID, {});", when does this code run? + +Implement libvirt integration. + - Is the API used by xl usable for libvirt? + - How does libvirt assign a raw SCSI device? + Jim said: + > vscsi=[ '/dev/sda,0:1:2:3', '4:3:2:1,1:1:1:1,feature-host' ] + In libvirt-speak, this is SCSI host device assignment + http://libvirt.org/formatdomain.html#elementsHostDev + Here's the SCSI example + + + + +
+ + +
+ + ... + + I suppose 'feature-host' maps to attributes such as 'sgio' and 'rawio'. + The source element describes the SCSI device as seen from the host. + + +== History == + +Support for PVSCSI was added to the classic xenlinux kernel and to xend in +xen-3.3 in 2008. Support for PVSCSI was added to the upstream pvops kernel 3.18 +in 2014. Backends exists just for Linux. A frontend exists for Linux, and maybe +for FreeBSD according to google. + + +== Config Format == + +The domU.cfg syntax is "vscsi=[ 'pdev,vdev[,option]', 'pdev,vdev[,option]' ]". +'pdev' describes the physical device, preferable in a persistant format. +'vdev' is the domU device in vHOST:CHANNEL:TARGET:LUN notation, all integers. +'option' lists additional flags which a backend may recognize. + + +== Configuring xenlinux backend == + +"pdev" is the dom0 device in either /dev/scsidev or pHOST:CHANNEL:TARGET:LUN +notation. Currently only the option value "feature-host" is recognized. SCSI +command emulation in backend driver is bypassed when "feature-host" is +specified. + +Its recommended to use persistant names "/dev/disk/by-*/*" to refer to a "pdev". +The toolstack will translate this internally to "h:c:t:l" notation, which is how +the backend driver will access the device. Using the "h:c:t:l" notation for +"pdev" in domU.cfg is discouraged because this value will change across reboots, +depending on the detection order in the OS. + + +== Configuring pvops backend == + +The backend driver in the pvops kernel is part of the Linux-IO Target framework +(LIO). As such the SCSI devices have to be configured first with the tools +provided by this framework, such as targetcli. The "pdev" in domU.cfg has to +refer to a config item in that framework instead of the raw device. + +The LIO uses a concept of backstore and frontend drivers. LIO backstore drivers +provide access to the actual storage, LIO frontend drivers provide an interface +which is accessed with SCSI commands. Within the LIO the frontend is connected +to a certain backstore. + +For Xen its recommended to use the PSCSI backstore. Other backstores may work as +well, but they are not tested. The xen-scsiback module is the LIO frontend, and +at the same time the backend for the domU. In general the config flow is: +- the LIO backstore refers to physical storage in a persistant way +- the given storage gets a free, unique name within the LIO backstore +- the LIO frontend refers to that free, unique name in the LIO backstore +- the connection to the LIO backstore gets a naa.WWN:LUN in the LIO frontend +- the "pdev" in domU.cfg refers to that naa.WWN:LUN in the LIO frontend + +Example for targetcli and a xen-scsiback aware python-rtslib: + + # modprobe -v xen-scsiback + # DEV=/dev/disk/by-id/ata-TSSTcorp_DVD+_-RW_TS-H653G_R4576GFZ638411 + # NAME="my_dvd" + # NAA=$(printf "naa.%s\n" `od -N 8 -t x8 -A n < /dev/urandom`) + # targetcli "/backstores/pscsi create name=$NAME dev=${DEV}" + # targetcli "/xen-pvscsi create wwn=$NAA" + # targetcli "/xen-pvscsi/$NAA/tpg1/luns create /backstores/pscsi/$NAME" + # echo "vscsi=[ '${NAA}:0,0:0:0:0' ]" + +The last line is the domU.cfg snippet. + + +== Xenstore Format == + +The backend driver uses a single_host:many_devices notation to manage domU +devices. Everything is stored in /local/domain/0/backend/vscsi/. The xenstore +layout looks like this: + + //feature-host = "0" + //frontend = "/local/domain//device/vscsi/0" + //frontend-id = "" + //online = "1" + //state = "4" + //vscsi-devs/dev-0/p-dev = "8:0:2:1" or "naa.wwn:lun" + //vscsi-devs/dev-0/state = "4" + //vscsi-devs/dev-0/v-dev = "0:0:0:0" + //vscsi-devs/dev-1/p-dev = "8:0:2:2" + //vscsi-devs/dev-1/state = "4" + //vscsi-devs/dev-1/v-dev = "0:0:1:0" + +The frontend driver maintains its state in /local/domain//device/vscsi/. + + /backend = "/local/domain/0/backend/vscsi//" + /backend-id = "0" + /event-channel = "20" + /ring-ref = "43" + /state = "4" + /vscsi-devs/dev-0/state = "4" + /vscsi-devs/dev-1/state = "4" + +In addition to the entries for backend and frontend these flags are stored for +the toolstack: + + //vscsi-devs/dev-1/p-devname = "/dev/$device" + + +== Backend - Frontend Protocol == + +To create a vhost along with a device: + //feature-host = "0" + //frontend = "/local/domain//device/vscsi/0" + //frontend-id = "" + //online = "1" + //state = "1" + //vscsi-devs/dev-0/p-dev = "8:0:2:1" + //vscsi-devs/dev-0/state = "1" + //vscsi-devs/dev-0/v-dev = "0:0:0:0" +Wait for //state + //vscsi-devs/dev-0/state become 4 + +To add another device to a vhost: + //state = "7" + //vscsi-devs/dev-1/p-dev = "8:0:2:2" + //vscsi-devs/dev-1/state = "1" + //vscsi-devs/dev-1/v-dev = "0:0:1:0" +Wait for //state + //vscsi-devs/dev-1/state become 4 + +To remove a device from a vhost: + //state = "7" + //vscsi-devs/dev-1/state = "5" +Wait for //state to become 4 +Wait for //vscsi-devs/dev-1/state become 6 +Remove //vscsi-devs/dev-1/{state,p-dev,v-dev,p-devname} +Remove //vscsi-devs/dev-1/ + + +== Interface in xl == + +xl scsi-attach domid [,