Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1786980

Summary: listAllPorts() cann't list all network ports
Product: Red Hat Enterprise Linux Advanced Virtualization Reporter: lcheng
Component: libvirt-pythonAssignee: Daniel Berrangé <berrange>
Status: CLOSED ERRATA QA Contact: lcheng
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: berrange, dyuan, jdenemar, lmen, xuzhang
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-python-6.0.0-1.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-05-05 09:52:22 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:

Description lcheng 2019-12-30 06:06:30 UTC
Description of problem:
listAllPorts() cann't list all network ports.

Version-Release number of selected component (if applicable):
python3-libvirt-5.10.0-1.module+el8.2.0+5145+c579b816.x86_64
libvirt-5.10.0-1.module+el8.2.0+5135+ed3b2489.x86_64

How reproducible:
100%

Steps to Reproduce:
# python
Python 3.6.8 (default, Dec  5 2019, 15:45:45) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open()
>>> net = conn.networkLookupByName("default")
>>> port_list = net.listAllPorts()
>>> port_list
[<libvirt.virNetwork object at 0x7f978e547550>, <libvirt.virNetwork object at 0x7f978e547ac8>]
>>> port_list[0].XMLDesc()
libvirt: Network Driver error : invalid network pointer in virNetworkGetXMLDesc
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 3063, in XMLDesc
    if ret is None: raise libvirtError ('virNetworkGetXMLDesc() failed', net=self)
libvirt.libvirtError: invalid network pointer in virNetworkGetXMLDesc


Actual results:
listAllPorts() get a libvirt.virNetwork object list.

Expected results:
listAllPorts() get a libvirt.virNetworkPort object list.

Additional info:
Repeat listAllPorts() will get following error.

>>> port_list = net.listAllPorts()
libvirt: Network Driver error : invalid network pointer in virNetworkFree
>>> port_list = net.listAllPorts()
libvirt: Network Driver error : invalid network pointer in virNetworkFree
libvirt: Network Driver error : invalid network pointer in virNetworkFree
>>> port_list = net.listAllPorts()
libvirt: Network Driver error : invalid network pointer in virNetworkFree
libvirt: Network Driver error : invalid network pointer in virNetworkFree

Comment 1 Daniel Berrangé 2020-01-02 15:52:21 UTC
Fix proposed https://www.redhat.com/archives/libvir-list/2020-January/msg00062.html

Comment 2 Daniel Berrangé 2020-01-06 15:42:28 UTC
Merged upstream for forthcoming 6.0.0

Comment 4 lcheng 2020-01-16 08:58:57 UTC
Verified on python3-libvirt-6.0.0-1.module+el8.2.0+5453+31b2b136.x86_64.

# python
Python 3.6.8 (default, Dec  5 2019, 15:45:45) 
[GCC 8.3.1 20191121 (Red Hat 8.3.1-5)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open()
>>> net = conn.networkLookupByName('default')
>>> net.listAllPorts()
[<libvirt.virNetworkPort object at 0x7f4eb14429e8>, <libvirt.virNetworkPort object at 0x7f4eb1442978>]
>>> net.listAllPorts()[0].UUIDString()
'43d3260d-0fcb-44aa-9571-d2efc53fad08'
>>> net.listAllPorts()[1].UUIDString()
'43d3260d-0fcb-44aa-9571-d2efc53fad07'
>>> net.listAllPorts()[0].XMLDesc()
"<networkport>\n  <uuid>43d3260d-0fcb-44aa-9571-d2efc53fad08</uuid>\n  <owner>\n    <name>rhel</name>\n    <uuid>6fc9e4e3-980c-43df-8d62-673cd69b00e3</uuid>\n  </owner>\n  <mac address='52:54:00:e6:e8:32'/>\n  <bandwidth classID='1'>\n    <inbound average='600' peak='500' burst='400'/>\n    <outbound average='700' peak='800' burst='600'/>\n  </bandwidth>\n  <plug type='network' bridge='virbr0'/>\n</networkport>\n"
>>> net.listAllPorts()[0].UUID()
b'C\xd3&\r\x0f\xcbD\xaa\x95q\xd2\xef\xc5?\xad\x08'


Move to VERIFIED.

Comment 6 errata-xmlrpc 2020-05-05 09:52:22 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://access.redhat.com/errata/RHBA-2020:2017