Bug 1377071

Summary: guestVcpus fail with wrong argument number.
Product: Red Hat Enterprise Linux 7 Reporter: lcheng
Component: libvirt-pythonAssignee: Peter Krempa <pkrempa>
Status: CLOSED ERRATA QA Contact: lcheng
Severity: medium Docs Contact:
Priority: medium    
Version: 7.3CC: jdenemar, pkrempa, xuzhang
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: libvirt-python-2.5.0-1.el7 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-08-01 15:01:57 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 2016-09-18 08:04:50 UTC
Description of problem:
guestVcpus fail with wrong argument number. 

Version-Release number of selected component (if applicable):
libvirt-python-2.0.0-2.el7.x86_64

How reproducible:
100%

Steps to Reproduce:

# python
Python 2.7.5 (default, Aug  2 2016, 04:20:16) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> import os
>>> conn = libvirt.open()
>>> dom = conn.lookupByName("r73")
>>> dom.guestVcpus()
>>> vcpu = {}
>>> num = 0
>>> dom.guestVcpus(vcpu, num)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/site-packages/libvirt.py", line 1268, in guestVcpus
    ret = libvirtmod.virDomainGetGuestVcpus(self._o, params, nparams, flags)
TypeError: virDomainGetGuestVcpus() takes exactly 2 arguments (4 given)


Actual results:
As above.

Expected results:
Get guest vcpus information.

Comment 2 Peter Krempa 2016-09-19 15:20:09 UTC
Fixed upstream:

commit 0061566872ed3fdf7b0ec101c20d3ddb78093a06
Author: Peter Krempa <pkrempa>
Date:   Mon Sep 19 13:54:37 2016 +0200

    override: Properly override wrapper for virDomainGetGuestVcpus
    
    Without the change to libvirt-override-api.xml generator.py would
    generate the following function header:
    
        def guestVcpus(self, params, nparams, flags=0):
    
    Since @params and @nparams are output-only in C and the python C
    implementation actualy creates a dict from them we should not need to
    pass them. Add the API definition to drop the two unnecessary args:
    
        def guestVcpus(self, flags=0):
    
    The code did not work at all until this change as the C impl expects
    only two arguments but the python required use of four.

Comment 4 lcheng 2016-12-09 07:30:39 UTC
Verified on libvirt-python-2.5.0-1.el7.x86_64. 

# python
Python 2.7.5 (default, Aug  2 2016, 04:20:16) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> import os
>>> conn = libvirt.open()
>>> dom = conn.lookupByName('test')
>>> dom.guestVcpus()
{'vcpus': '0-5', 'offlinable': '0-5', 'online': '0-5'}
>>> dom.setGuestVcpus('1,3', 0)
0
>>> dom.guestVcpus()
{'vcpus': '0-5', 'offlinable': '0-5', 'online': '0,2,4-5'}

Comment 5 errata-xmlrpc 2017-08-01 15:01:57 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/RHEA-2017:1847