Bug 1786968

Summary: Cann't get network port uuid by UUID() or UUIDString()
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.1CC: berrange, jdenemar, lmen
Target Milestone: rc   
Target Release: 8.2   
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 02:24:25 UTC
Description of problem:
Cann't get network port uuid by UUID() or UUIDString()

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:
1. Network port uuid is '43d3260d-0fcb-44aa-9571-d2efc53fad07'. Get network port uuid by UUIDString().
# 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 = net.portLookupByUUIDString('43d3260d-0fcb-44aa-9571-d2efc53fad07')
>>> port
<libvirt.virNetworkPort object at 0x7f41b43b45c0>
>>> buf = ''
>>> port.UUIDString(buf)
0
>>> buf
''
>>> port.UUIDString(buf)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 3220, in UUIDString
    ret = libvirtmod.virNetworkPortGetUUIDString(self._o, buf)
ValueError: embedded null character


2. Network port uuid is '43d3260d-0fcb-44aa-9571-d2efc53fad07'. Get network port uuid by UUID().

# 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 = net.portLookupByUUIDString('43d3260d-0fcb-44aa-9571-d2efc53fad07')
>>> uuid = ''
>>> port.UUID(uuid)
0
>>> uuid
''
>>> port.UUID(uuid)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.6/site-packages/libvirt.py", line 3213, in UUID
    ret = libvirtmod.virNetworkPortGetUUID(self._o, uuid)
ValueError: embedded null character


Actual results:
Cann't get network port uuid.

Expected results:
Can get network port uuid.

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

Note that in addition to what's reported in the description, the 'net.portLookupByUUID()' method was also broken.

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

Comment 4 lcheng 2020-01-16 08:49:43 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')
>>> port = net.portLookupByUUIDString('43d3260d-0fcb-44aa-9571-d2efc53fad07')
>>> port
<libvirt.virNetworkPort object at 0x7f4eb159dc88>
>>> port.UUIDString()
'43d3260d-0fcb-44aa-9571-d2efc53fad07'
>>> uuid = port.UUID()
>>> uuid
b'C\xd3&\r\x0f\xcbD\xaa\x95q\xd2\xef\xc5?\xad\x07'
>>> import binascii
>>> binascii.hexlify(uuid).decode()
'43d3260d0fcb44aa9571d2efc53fad07'


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