Bug 992001

Summary: get_node_device_scsihost_by_wwn will cause libvirt error.
Product: Red Hat Enterprise Linux 7 Reporter: zhe peng <zpeng>
Component: perl-Sys-VirtAssignee: John Ferlan <jferlan>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: medium Docs Contact:
Priority: medium    
Version: 7.0CC: berrange, dyuan, jsuchane, mzhan, rbalakri, weizhan, zpeng
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: perl-Sys-Virt-1.2.8-1.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-03-05 10:53:50 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1140194    
Bug Blocks:    

Description zhe peng 2013-08-05 03:05:17 UTC
Description of problem:
Use libvirt-tck to testing libvirt api, when testing get_node_device_scsihost_by_wwn will get libvirt error.

Version-Release number of selected component (if applicable):
perl-Sys-Virt-1.1.1-1.el7.x86_64
libvirt-1.1.1-1.el7.x86_64


How reproducible:
always

Steps to Reproduce:
in libvirt tck,testing api:

my $dev = $vmm->get_node_device_scsihost_by_wwn($wwnn, $wwpn, $flags=0)

get error:
libvirt error code: 1, message: An error occurred, but the cause is unknown


Actual results:


Expected results:
return nodedev w/o error

Additional info:
python binding have same problem.

Comment 2 Dave Allan 2013-08-13 19:21:31 UTC
We also need expanded unit tests in this area.

Comment 4 Osier Yang 2013-11-20 14:39:39 UTC
(In reply to zhe peng from comment #0)
> Description of problem:
> Use libvirt-tck to testing libvirt api, when testing
> get_node_device_scsihost_by_wwn will get libvirt error.
> 
> Version-Release number of selected component (if applicable):
> perl-Sys-Virt-1.1.1-1.el7.x86_64
> libvirt-1.1.1-1.el7.x86_64
> 
> 
> How reproducible:
> always
> 
> Steps to Reproduce:
> in libvirt tck,testing api:
> 
> my $dev = $vmm->get_node_device_scsihost_by_wwn($wwnn, $wwpn, $flags=0)
> 
> get error:
> libvirt error code: 1, message: An error occurred, but the cause is unknown
> 

Is the scsi host with the sepcified $wwnn/$wwpn existing on host?

Comment 5 zhe peng 2013-11-21 08:42:18 UTC
yes
# virsh nodedev-dumpxml scsi_host4
<device>
  <name>scsi_host4</name>
  <path>/sys/devices/pci0000:00/0000:00:09.0/0000:18:00.1/host4</path>
  <parent>pci_0000_18_00_1</parent>
  <capability type='scsi_host'>
    <host>4</host>
    <capability type='fc_host'>
      <wwnn>20000024ff370479</wwnn>
      <wwpn>21000024ff370479</wwpn>
      <fabric_wwn>ffffffffffffffff</fabric_wwn>
    </capability>
    <capability type='vport_ops'>
      <max_vports>254</max_vports>
      <vports>0</vports>
    </capability>
  </capability>
</device>

Comment 6 Osier Yang 2013-11-21 12:58:00 UTC
(In reply to zhe peng from comment #5)
> yes
> # virsh nodedev-dumpxml scsi_host4
> <device>
>   <name>scsi_host4</name>
>   <path>/sys/devices/pci0000:00/0000:00:09.0/0000:18:00.1/host4</path>
>   <parent>pci_0000_18_00_1</parent>
>   <capability type='scsi_host'>
>     <host>4</host>
>     <capability type='fc_host'>
>       <wwnn>20000024ff370479</wwnn>
>       <wwpn>21000024ff370479</wwpn>
>       <fabric_wwn>ffffffffffffffff</fabric_wwn>
>     </capability>
>     <capability type='vport_ops'>
>       <max_vports>254</max_vports>
>       <vports>0</vports>
>     </capability>
>   </capability>
> </device>

I don't have a NPIV box in hand to do the testing. But per the testing by timesu in BZ 

<quote>
> Test commands nodedev-destroy and nodedev-dumpxml can work with the
> wwnn,wwpn paremeter
> 
> nodedev-dumpxml:
> 
> #virsh nodedev-dumpxml --device 2000001b3289da4e,2100001b3289da4e
> <device>
> <name>scsi_host4</name>
> <path>/sys/devices/pci0000:00/0000:00:0d.0/0000:04:00.0/host4</path>
> <parent>pci_0000_04_00_0</parent>
> <capability type='scsi_host'>
> <host>4</host>
> <capability type='fc_host'>
> <wwnn>2000001b3289da4e</wwnn>
> <wwpn>2100001b3289da4e</wwpn>
> <fabric_wwn>2001000dec987841</fabric_wwn>
> </capability>
> <capability type='vport_ops'>
> <max_vports>127</max_vports>
> <vports>0</vports>
> </capability>
> </capability>
> </device>
</quote>

Note that if you specify the device for "nodedev-dumpxml" by "wwnn,wwpn", it uses virNodeDeviceLookupSCSIHostByWWN.

Comment 7 Osier Yang 2013-11-21 13:04:15 UTC
(In reply to Osier Yang from comment #6)
> (In reply to zhe peng from comment #5)
> > yes
> > # virsh nodedev-dumpxml scsi_host4
> > <device>
> >   <name>scsi_host4</name>
> >   <path>/sys/devices/pci0000:00/0000:00:09.0/0000:18:00.1/host4</path>
> >   <parent>pci_0000_18_00_1</parent>
> >   <capability type='scsi_host'>
> >     <host>4</host>
> >     <capability type='fc_host'>
> >       <wwnn>20000024ff370479</wwnn>
> >       <wwpn>21000024ff370479</wwpn>
> >       <fabric_wwn>ffffffffffffffff</fabric_wwn>
> >     </capability>
> >     <capability type='vport_ops'>
> >       <max_vports>254</max_vports>
> >       <vports>0</vports>
> >     </capability>
> >   </capability>
> > </device>
> 
> I don't have a NPIV box in hand to do the testing. But per the testing by
> timesu in BZ 
> 
> <quote>
> > Test commands nodedev-destroy and nodedev-dumpxml can work with the
> > wwnn,wwpn paremeter
> > 
> > nodedev-dumpxml:
> > 
> > #virsh nodedev-dumpxml --device 2000001b3289da4e,2100001b3289da4e
> > <device>
> > <name>scsi_host4</name>
> > <path>/sys/devices/pci0000:00/0000:00:0d.0/0000:04:00.0/host4</path>
> > <parent>pci_0000_04_00_0</parent>
> > <capability type='scsi_host'>
> > <host>4</host>
> > <capability type='fc_host'>
> > <wwnn>2000001b3289da4e</wwnn>
> > <wwpn>2100001b3289da4e</wwpn>
> > <fabric_wwn>2001000dec987841</fabric_wwn>
> > </capability>
> > <capability type='vport_ops'>
> > <max_vports>127</max_vports>
> > <vports>0</vports>
> > </capability>
> > </capability>
> > </device>
> </quote>
> 
> Note that if you specify the device for "nodedev-dumpxml" by "wwnn,wwpn", it
> uses virNodeDeviceLookupSCSIHostByWWN.

Thanks for timesu left me a mail for the NPIV box. With my testing, it just works. 

>>> node = conn.nodeDeviceLookupSCSIHostByWWN("2001001b32a9da4e", "2101001b32a9da4e", 0)
>>> print node
<libvirt.virNodeDevice object at 0x7f1a1d997690>

That's why I asked if the device with $wwnn/$wwpn is existing. I admit that there is a problem that it should report error if the device doesn't exist. But it's not that important than failing to find the device if it's existing.

Comment 8 zhe peng 2013-11-22 05:52:35 UTC
I re-test it, found only perl binding have this issue, python binding and libvirt worked well, so it's a perl-Sys-virt problem.
#virsh nodedev-dumpxml --device $wwnn,$wwpn
<device>
  <name>scsi_host4</name>
  <path>/sys/devices/pci0000:00/0000:00:09.0/0000:18:00.1/host4</path>
  <parent>pci_0000_18_00_1</parent>
  <capability type='scsi_host'>
    <host>4</host>
    <capability type='fc_host'>
      <wwnn>20000024ff370479</wwnn>
      <wwpn>21000024ff370479</wwpn>
      <fabric_wwn>ffffffffffffffff</fabric_wwn>
    </capability>
    <capability type='vport_ops'>
      <max_vports>254</max_vports>
      <vports>0</vports>
    </capability>
  </capability>
</device>

Comment 9 Osier Yang 2013-11-22 06:19:35 UTC
(In reply to zhe peng from comment #8)
> I re-test it, found only perl binding have this issue, python binding and
> libvirt worked well, so it's a perl-Sys-virt problem.

Move to perl-Sys-Virt.

Comment 10 Osier Yang 2013-11-28 07:56:50 UTC
Patch pushed in upstream:

commit a7f5eb3ae71cd8b8846f1581e9d21da4f7880cf1
Author: Osier Yang <jyang>
Date:   Wed Nov 27 15:00:27 2013 +0800

    libvirt-perl: Fix the wrong binding of virNodeDeviceLookupSCSIHostByWWN
    
    The second parameter for virNodeDeviceLookupSCSIHostByWWN is "wwnn"
    instead of "wwpn", and the API supports "flags".

Comment 12 John Ferlan 2014-09-10 14:25:21 UTC
Once bz 1140194 is resolved with the upstream libvirt-perl 1.2.8 bindings rebased into perl-Sys-Virt, this bug will be resolved.

Comment 14 zhe peng 2014-11-04 06:47:59 UTC
veriy with build:
perl-Sys-Virt-1.2.8-2.el7.x86_64
libvirt-1.2.8-5.el7.x86_64

no error occured, issue is fixed.
my $dev = $conn->get_node_device_scsihost_by_wwn("2000001b3289da4e","2100001b3289da4e");
my $xml =  $dev->get_xml_description();
can find right nodedev and print nodedev's xml
<device>
#   <name>scsi_host4</name>
#   <path>/sys/devices/pci0000:00/0000:00:0d.0/0000:04:00.0/host4</path>
#   <parent>pci_0000_04_00_0</parent>
#   <capability type='scsi_host'>
#     <host>4</host>
#     <unique_id>4</unique_id>
#     <capability type='fc_host'>
#       <wwnn>2000001b3289da4e</wwnn>
#       <wwpn>2100001b3289da4e</wwpn>
#       <fabric_wwn>2001000dec987841</fabric_wwn>
#     </capability>
#     <capability type='vport_ops'>
#       <max_vports>127</max_vports>
#       <vports>0</vports>
#     </capability>
#   </capability>
# </device>

move to verified.

Comment 16 errata-xmlrpc 2015-03-05 10:53:50 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2015-0470.html