Using NPIV for Storage Access with XEN Virtualization | SUSE Communities

Using NPIV for Storage Access with XEN Virtualization


NPIV provides a way of assigning a fibre channel LUN directly to a XEN guest, without having it assigned to the host that the VM is running on. NPIV effectively bridges through the HBA, using a vport. The SAN should then see the WWN of the VM and allow you to assign LUNs directly to that VM. Of course, you’ll need both SAN and Fiber Channel switch support for NPIV.

Setting up an NPIV block device

To use NPIV, you need to create an identifier for the device that XEN understands. The identifier is formatted as follows:


To obtain these values you’ll need to do a little detective work.


This will be shown in the file /sys/class/fc_host/hostX/fabric_name. You will need to identify the host number that corresponds to your HBA. If you have more than one HBA, pick one and use it for all the steps that follow. You must remove the 0x from the start of the value you read from the file.

wwpn and wwnn (worldwide port/node name)

These are the identifiers that will be presented as the virtual HBA to your SAN. You will use these values to assign storage using your usual method. The values for these are entirely up to you, you can create them form scratch or base them on existing WWN values. There are only two restrictions; they mush be unique, and they must be 16 hex digits long. An example is: wwpn – 9990000000000001 and wwnn – 9990100000000001.


This is possibly the trickiest of all. You will find it buried in the fc_host information. For example:


As with the above, you may have more than one host and more than one remote port according to your SAN layout, especially if you have multipathing enabled.


This is the simplest of all. It is the LUN number as assigned on the SAN when you created the LUN in the storage group. It will usually be 0 if there is only one LUN assigned to the vport.

So, once you have all of the above details, your npiv statement should look something like:


You may need to attempt to add the storage to the VM before you can actually zone it in your SAN as the new WWN will not show up there. If you can add it manually, you may want to do that now.

Adding the storage to a VM

To add the storage to a running VM (the easiest way to test) try the following, substituting xvdb for the disk name that you want the VM to see:

xm block-attach sles11 npiv:100000051e8ccaf2-9990000000000001-9990100000000001-50060e8010458780-0 xvdb w

If this works, then you should see the new disk inside your VM. Check that by using
cat /proc/partitions inside the VM.

If you didn’t set up the SAN zoning manually, the above will fail, but you should now see the new WWN. Set up the zoning and the try the command again.

Once you are happy that the above is working, you can add the LUN to the configuration file for the VM in the same way as you would add any other disk.


Unfortunately there is a bug in the npiv code as shipped with SLES11 (versions 3.3.1_18546_12 to 3.3.1_18546_16). This has been reported to engineering and updated code is currently being tested. It should be fixed in versions greater than the above.

(Visited 1 times, 1 visits today)


  • windl says:

    Trying that with SLES11 SP1 did not work: I never managed to see new port WWNs on the FC-switch. Maybe a concrete example would help.

  • efstahiou_e says:


    we are trying to do this Oracle VM 3.2.2 (XEN 4.1.2, Kernel 3.0.16 => UEK) and are also not succeding.

    So far we have done the following steps:

    1. Create Vports as described here:

    2. Do a zoning on these virtual wwns to avoid the chicken/egg problem.

    3. try to attach the npiv device to a PV domu

    Therefore I would also welcome a more concrete example.



  • Leave a Reply

    Your email address will not be published.