pNFS SCSI testing setup for KVM
WIP WARNING
This post is a work in progress..
Here’s a quick rundown on setting up pNFS SCSI virtual machines on KVM. The
steps below are specific for two virtual machines – assuming one client and
one server on the same physical host. We’ll need to do almost all our
configruation work on the physical host on which the VMs run.
This setup also assumes that we don’t have any SPC4-compliant SCSI devices, and because SCSI layouts depend on being able to register keys and perform reservations, this setup is mostly about how to set up a shared SCSI device which supports registrations/reservations. You can read section-2.3 of the nfsv4 scsi layout draft for bit more information on these requirements for pNFS SCSI layouts.
We are going to emulate a compatible device using a Linux-IO backstore and then present it to the VMs using the vhost-scsi target. This is going to give us a very convenient software-defined fabric, but to do it, you’ll need a kernel on your physical host that has been built with CONFIG_VHOST_SCSI in order to have the vhost_scsi.ko module built. Currently, RHEL7 does not ship with the vhost_scsi module, so I recommend using a recent Fedora or upstream kernel on your physical host.
Finally, you might find there’s a bug in the vhost/scsi transport that will corrupt your data! So the next step is to patch your physical host’s kernel with “vhost/scsi: fix reuse of &vq->iov[out] in response”. Until that patch receives some review and lands upstream, we’re stuck with this step.
Without further explanations, here follows the list of steps for basic client-server pNFS SCSI VM setup:
Step 1
Patch/rebuild your physical host’s kernel with “vhost/scsi: fix reuse of &vq->iov[out] in response”.
Step 2
On the physical host, create a backing store for your SCSI lun by entering the interactive targetcli shell:
Step 2
While still in targetcli on the physical host, we’ll create two vhost targets (one for each VM), and add that lun to them both as lun0:
OK, your LIO config should look something like this:
Just a note: as you might deduce from this LIO output, there are many different ways to configure the LIO fabric. You have options for which backing store you use, and if you did have iSCSI or SPC4 compliant devices on this host, you could present them to your VMs with this fabric. You also have the option of presenting the virtual device you just created back to the host using the loopback module.
Step 3
Now, we’ll present the vhost-scsi device to your two VMs. Since libvirt and
virt-manager do not have interfaces for the scsi-vhost devices, we resort to
modifying your VM’s qemu command line. We’ll keep the modification within
the kvm config, however. On the physical host, use virsh edit <VM name>
to add the following xml:
Note that the first line above is not an addition, but rather a modification
to add
xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'
to the existing
root <domain> element. Also note that the value of the wwpn
option is
equal to one of the vhost target port groups you created in step 2. Also
note that the id
option can likely be set to any unique value per VM.
Repeat the above step for your other VM, this time specifying the other target port group name you created in step 2.
Step 4
[Re]boot your VMs! You should now have a scsi_generic device on each VM that is backed by your lun:
At this point, you might want to verify that your setup indeed has/supports identifiers and registrations by querying for page 0x83 of the VPD. Format with XFS, and proceed to export with the pnfs option.
This is the end..
Feedback and corrections are welcome. Email me!