forked from samli008/kvm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
npiv.txt
85 lines (75 loc) · 2.38 KB
/
npiv.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# NPIV is a Fibre Channel (FC) technology to share a single physical Fibre Channel host bus adapter (HBA) as multiple virtual ports
# check HBA support NPIV
[root@c01 ~]# virsh nodedev-list --cap vports
scsi_host0
scsi_host1
[root@c01 ~]# virsh nodedev-dumpxml scsi_host0
<device>
<name>scsi_host0</name>
<path>/sys/devices/pci0000:00/0000:00:07.0/0000:04:00.0/host0</path>
<parent>pci_0000_04_00_0</parent>
<capability type='scsi_host'>
<host>0</host>
<unique_id>0</unique_id>
<capability type='fc_host'>
<wwnn>20000024ff447e66</wwnn>
<wwpn>21000024ff447e66</wwpn>
<fabric_wwn>1000000533df876e</fabric_wwn>
</capability>
<capability type='vport_ops'>
<max_vports>254</max_vports>
<vports>1</vports>
</capability>
</capability>
</device>
# create vHBAs with following XML file
cat > vhba.xml << EOF
<device>
<parent>scsi_host0</parent>
<capability type='scsi_host'>
<capability type='fc_host'>
</capability>
</capability>
</device>
EOF
virsh nodedev-create vhba.xml
# view vHBA
[root@c01 ~]# virsh nodedev-dumpxml scsi_host5
<device>
<name>scsi_host5</name>
<path>/sys/devices/pci0000:00/0000:00:07.0/0000:04:00.0/host0/vport-0:0-0/host5</path>
<parent>scsi_host0</parent>
<capability type='scsi_host'>
<host>5</host>
<unique_id>5</unique_id>
<capability type='fc_host'>
<wwnn>5001a4ad29ceb11d</wwnn>
<wwpn>5001a4af357df7f9</wwpn>
<fabric_wwn>1000000533df876e</fabric_wwn>
</capability>
</capability>
</device>
virsh nodedev-destroy scsi_host6
virsh nodedev-list |grep scsi_host
# use switchshow portshow conmmands on B300 FC-switch and create zone with NPIV
echo "1" > /sys/class/fc_host/host0/issue_lip
# Pool uses WWPN and WWNN of the scsi_host5 vHBA in the following XML file:
pool.xml
<pool type="scsi">
<name>npiv-pool</name>
<target>
<path>/dev/disk/by-path</path>
</target>
<source><adapter type="scsi_host" wwnn="5001a4ad29ceb11d" wwpn="5001a4af357df7f9" /></source>
</pool>
virsh pool-define pool.xml
virsh pool-start npiv-pool
virsh vol-list npiv-pool --details
# Create a volume XML using this LUN and hot/cold attach to a guest.
volume-atch.xml
<disk type='volume' device='disk'>
<driver name='qemu' type='raw'/>
<source pool='npiv-pool' volume='unit:0:1:0'/>
<target dev='sdc' bus='scsi'/>
</disk>
virsh attach-disk <guest-name> volume-atch.xml