Citrix XenServer 4.1, 5.0, 5.5 (beta)
Making a tape-device located in the XenServer host available to a guest Virtual Machine.
This article has been taken from WLUG.org.nz/XenNotes, I just want to keep a copy here for my own convenience. A BIG thanks to the guys at WLUG for figuring this out and making it easy to understand for mere mortals like me.
This is specifically for Citrix XenServer, although the principles will of course work in other Xen implementations.
I recently had a scenario where I was replacing two Windows servers with XenServer guests. This was fine, but we needed a way to backup to the existing SCSI DDS4 DAT drive. After failing to make PCI passthrough work, I settled on the much nicer method of providing the tape drive via an iSCSI target on the XenServer Host (Dom0). Here is how I achieved this.
Note 1: This is totally unsupported by Citrix.
Note 2: I’ve used the XenServer terminology “host” instead of Dom0, as this applies to the Citrix commercial implementation of Xen. It will probably work fine on OSS Xen, but you can just install the normal kernel dev packages and ignore the DDK stuff.
Note 3: This is for XenServer 4.1.0, but the principles are the same for previous versions. Just ensure you understand each step rather than following blindly.
Note 4: You’ll need to enable yum repositories. Do this by editing /etc/yum.repos.d/CentOS-Base.repo, and set “enabled=1” for the Base, Updates and Addons repositories. You should also do this on the DDK VM.
- Download the Xen 4.1 DDK (Driver Development Kit) from citrix.com
- The DDK is an ISO containing a VM with a development environment. Import it to your Xen host, and start it.
- Download iscsitarget 0.4.14 (you MUST use this version, as the patch for rawio support will not cleanly apply to 0.4.15) from http://optusnet.dl.sourceforge.net/sourceforge/iscsitarget/iscsitarget-0.4.14.tar.gz into your DDK VM.
- Download the patch for rawio support from http://email@example.com&counter=1 into your DDK VM (assuming you’re saving it in /tmp)
- Now do the following:
yum install kernel-devel bison flex
tar -zxvf iscsitarget-0.4.14.tar.gz
patch -p0 < /tmp/raw.p
- scp the entire iscsitarget-0.4.14 directory to your destination Xen host, and on that host (after enabling the base repo in /etc/yum.repos.d/CentOS-Base.repo, as noted in Note 4) do:
yum install make gcc
mkdir /lib/modules/`uname -r`/kernel/iscsi
cp kernel/iscsi_trgt.ko /lib/modules/`uname -r`/kernel/iscsi
The last three steps are required because make install will not copy the kernel module correctly outside the target environment.
- Now edit your /etc/ietd.conf and configure the tape as per the following example snippet (cat /proc/scsi/scsi for the correct HCIL values for your SCSI tape drive, this is an example only):
Lun 0 H=1,C=0,I=6,L=0,Type=rawio
- Save and do /etc/init.d/iscsi-target start
- Modify /etc/sysconfig/iptables to allow port 3260 tcp from the IP addresses running the initiator.
- Attach to the target using the initiator of your choice.
Alternative download locations (from this site):
I have been using RocketDivisions “StarPort iSCSI Initiator” on the guest VM, in conjunction with Backup Exec 12.5, with success, the free version is enough.
This has been working in test-environments using Backup Exec 12.5 running on Windows Server 2003 (32-bit/64-bit) and Windows Server 2008 (32-bit/64-bit). With one note: Everytime I tried installing Symantecs tape-device drivers, the VM would BSOD. So just stick with the auto-detected Windows drivers and you should be good.
For some controllers, the XenServer host likes to assign the tapedevice a new HCIL -ID on each boot… I haven’t found anyway around this yet, so if you do, please let me know. I’m thinking maybe some wiz can make a script that will cat /proc/scsi/scsi at boot, enter this into /etc/ietd.conf and the restart then iSCSItarget service?