Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Red Hat Enterprise Linux 9 Essentials Book now available.

Purchase a copy of Red Hat Enterprise Linux 9 (RHEL 9) Essentials

Red Hat Enterprise Linux 9 Essentials Print and eBook (PDF) editions contain 34 chapters and 298 pages

Preview Book

Chapter 29. N_Port ID Virtualization (NPIV)

N_Port ID Virtualization (NPIV) is a function available with some Fibre Channel devices. NPIV shares a single physical N_Port as multiple N_Port IDs. NPIV provides similar functionality for Host Bus Adaptors (HBAs) that SR-IOV provides for network interfaces. With NPIV, virtualized guests can be provided with a virtual Fibre Channel initiator to Storage Area Networks (SANs).
N_Ports are addressed with a 24 bit N_Port ID, which is assigned by the Fibre Channel switch.
Why use NPIV
  • Without NPIV virtualized guests must share an HBA's WWN on the SAN. With NPIV, it is possible to use LUN masking and zoning for virtualized guest.
  • With NPIV migration with zones and LUN masking is possible.
  • Physical HBAs are expensive and use an expansion slot. With NPIV, more guests can access SAN resources and guest density can be increased.
Each N_Port has a unique identity (port WWN and node WWN) on the SAN and can be used for zoning and LUN masking. Soft zoning, which you can use to group ports together by port WWN, is the preferred method of zoning.

29.1. Enabling NPIV on the switch

Enabling the NPIV on a Fibre Channel port on a switch
admin> portcfgshow 0
......
NPIV capability                    ON
......
Usage
portCfgNPIVPort <PortNumber> <Mode>
Mode      Meaning
0             Disable the NPIV capability on the port
1             Enable the NPIV capability on the port
Example:
admin> portCfgNPIVPort 0 1

29.1.1. Identifying HBAs in a Host System

To determine the types of HBAs in the system, enter the following command:
# ls /proc/scsi
QLogic HBAs are listed as qla2xxx. Emulex HBAs are listed as lpfc.
QLogic Example
# ls /proc/scsi/qla2xxx
Emulex Example
# ls /proc/scsi/lpfc

29.1.2. Verify NPIV is used on the HBA

Output the data from the kernel on the port nodes of the HBA.
Example 29.1. QLogic controller example
# cat /proc/scsi/qla2xxx/7
FC Port Information for Virtual Ports:
Virtual Port index = 1
Virtual Port 1:VP State = <ACTIVE>, Vp Flags = 0x0
scsi­qla2­port­3=500601609020fd54:500601601020fd54:a00000:1000: 1;
scsi­qla2­port­4=500601609020fd54:500601681020fd54:a10000:1000: 1;
Virtual Port 1 SCSI LUN Information:
( 0:10): Total reqs 10, Pending reqs 0, flags 0x0, 2:0:1000,

Example 29.2. Emulex controller example
# cat /proc/scsi/lpfc/3
SLI Rev: 3
NPIV Supported: VPIs max 127 VPIs used 1
RPIs max 512 RPIs used 13
Vports list on this physical port:
Vport DID 0x2f0901, vpi 1, state 0x20
Portname: 48:19:00:0c:29:00:00:0d Nodename: 48:19:00:0c:29:00:00:0b

29.1.2.1. Create and destroy a virtual HBA with NPIV

Issue an NPIV create call. Confirm that the host has started a new virtual HBA and that any storage zones are usable.
To create virtual HBAs using libvirt, you require a NPIV capable HBA and switch.
Confirm that you have those by manually creating a new HBA by printing the contents of the /sys/class/fc_host/hostN directory where class is the type of adaptor and fc_host is the host number.
Note that the WWN used below are for demonstrative purposes only. Use WWN customized for your SAN environment.
Add a new virtual HBA with the following command where '1111222233334444:5555666677778888' is WWPN:WWNN and host5 is the physical HBA which the virtual HBA is a client of.
# echo '1111222233334444:5555666677778888' > /sys/class/fc_host/host5/vport_create
If the creation is successful, a new HBA in the system with the next available host number.

Note

The virtual HBAs can be destroyed with the following command:
# echo '1111222233334444:5555666677778888' > /sys/class/fc_host/host5/vport_delete
Adding the virtual HBA with virsh
This procedure covers creating virtual HBA devices on a host with virsh. This procedure requires a compatible HBA device.
  1. List available HBAs

    Find the node device name of the HBA with the virtual adapters. List of all the HBAs on the host with the following command:
    # virsh nodedev-list -TODO-cap=scsi_host
    pci_10df_fe00_0_scsi_host
    pci_10df_fe00_0_scsi_host_0
    pci_10df_fe00_scsi_host
    pci_10df_fe00_scsi_host_0
    pci_10df_fe00_scsi_host_0_scsi_host
    pci_10df_fe00_scsi_host_0_scsi_host_0
    
  2. Gather parent HBA device data

    Output the XML definition for each required HBA. This example uses the HBA, pci_10df_fe00_scsi_host.
    # virsh nodedev-dumpxml pci_10df_fe00_scsi_host
    <device>
      <name>pci_10df_fe00_scsi_host</name>
      <parent>pci_10df_fe00</parent>
      <capability type='scsi_host'>
        <host>5</host>
        <capability type='fc_host'>
          <wwnn>20000000c9848140</wwnn>
          <wwpn>10000000c9848140</wwpn>
        </capability>
        <capability type='vport_ops' />
      </capability>
    </device>
    
    HBAs capable of creating virtual HBAs have a capability type='vport_ops' in the XML definition.
  3. Create the XML definition for the virtual HBA

    With information gathered in the previous step, create an XML definition for the virtual HBA. This example uses a file named newHBA.xml.
    <device>
      <parent>pci_10df_fe00_0_scsi_host</parent>
      <capability type='scsi_host'>
        <capability type='fc_host'>
          <wwpn>1111222233334444</wwpn>
          <wwnn>5555666677778888</wwnn>
        </capability>
      </capability>
    </device>
    
    The <parent> element is the name of the parent HBA listed by the virsh nodedev-list command. The <wwpn> and <wwnn> elements are the WWNN and WWPN for the virtual HBA.

    WWNN and WWPN validation

    Libvirt does not validate the WWPN or WWNN values, invalid WWNs are rejected by the kernel and libvirt reports the failure. The error reported by the kernel is similar to the following:
    # virsh nodedev-create badwwn.xml
    error: Failed to create node device from badwwn.xml
    error: Write of '1111222233334444:5555666677778888' to '/sys/class/fc_host/host6/vport_create' during vport create/delete failed: No such file or directory
    
  4. Create the virtual HBA

    Create the virtual HBA with the virsh nodedev-create command using the file from the previous step.
    # virsh nodedev-create newHBA.xml
    Node device pci_10df_fe00_0_scsi_host_0_scsi_host created from newHBA.xml
    
    The new virtual HBA should be detected and available to the host. The create command output gives you the node device name of the newly created device.

Destroying a virtual HBA with virsh

To destroy the device, use virsh nodedev-destroy:
# virsh nodedev-destroy pci_10df_fe00_0_scsi_host_0_scsi_host
Destroyed node device 'pci_10df_fe00_0_scsi_host_0_scsi_host'

 
 
  Published under the terms of the Creative Commons License Design by Interspire