RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 1077572 - Python setInterfaceParameters function is broken
Summary: Python setInterfaceParameters function is broken
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: libvirt
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Michal Privoznik
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-03-18 09:24 UTC by Michal Privoznik
Modified: 2015-03-05 07:32 UTC (History)
6 users (show)

Fixed In Version: libvirt-1.2.7-1.el7
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-03-05 07:32:48 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2015:0323 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2015-03-05 12:10:54 UTC

Description Michal Privoznik 2014-03-18 09:24:06 UTC
Description of problem:
When using setInterfaceParamters from python binding, all that one can get is an error. No useful work is done.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
1. Run:

import libvirt

conn = libvirt.open(None)
if conn == None:
        print 'Failed to connect';
        sys.exit(1)

for id in conn.listDomainsID():
        dom = conn.lookupByID(id)
        if dom == None:
                continue

        params = dom.interfaceParameters('vnet0', 0)
        print params
        dom.setInterfaceParameters('vnet0', params, 0)



2. Observe error:

libvirt.libvirtError: argument unsupported: parameter '' not supported 

Actual results:


Expected results:


Additional info:

Comment 1 Michal Privoznik 2014-03-18 13:44:29 UTC
Pushed upstream (into separate libvirt-python.git):

commit 69c4600d61fa74c4977d2471a29fb73f0fe5edb0
Author:     Michal Privoznik <mprivozn>
AuthorDate: Tue Mar 18 09:20:00 2014 +0100
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Mar 18 14:43:10 2014 +0100

    setPyVirTypedParameter: free whole return variable on error
    
    The @ret value is built in a loop. However, if in one iteration
    there's an error, we should free all the fields built so far. For
    instance, if there's an error and the previous item was
    type of VIR_TYPED_PARAM_STRING we definitely must free it.
    
    Signed-off-by: Michal Privoznik <mprivozn>

commit 412c93a7b9111ad15c543e286f23bb5891749c42
Author:     Michal Privoznik <mprivozn>
AuthorDate: Tue Mar 18 09:12:24 2014 +0100
Commit:     Michal Privoznik <mprivozn>
CommitDate: Tue Mar 18 14:43:00 2014 +0100

    setPyVirTypedParameter: Copy full field name
    
    In the setPyVirTypedParameter we try to produce virTypedParameter
    array from a python dictionary. However, when copying field name into
    item in returned array, we use strncpy() as the field name is fixed
    length array. To determine its size we use sizeof() but mistakenly
    dereference it resulting in sizeof(char) which equals to 1 byte.
    Moreover, there's no need for using sizeof() when we have a global
    macro to tell us the length of the field name:
    VIR_TYPED_PARAM_FIELD_LENGTH.
    
    And since array is allocated using VIR_ALLOC() we are sure the memory
    is initially filled with zeros. Hence, there's no need to terminate
    string we've just copied into field name with '\0' character. It's
    there for sure too as we copy up to field length - 1.
    
    Signed-off-by: Michal Privoznik <mprivozn>


v1.2.2-3-g69c4600

Comment 3 hongming 2014-11-24 07:20:47 UTC
Verify it as follows. The result is expected. Move its status to VERIFIED.


# rpm -q libvirt libvirt-python
libvirt-1.2.8-8.el7.x86_64
libvirt-python-1.2.8-5.el7.x86_64


# virsh start r7
Domain r7 started


# virsh dumpxml r7|grep interface -A11
    <interface type='network'>
      <mac address='52:54:00:b1:ab:72'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='1000' peak='5000' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:c9:8d:7f'/>
      <source network='default'/>
      <target dev='vnet1'/>
      <model type='rtl8139'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>



# cat test.py 
import libvirt

conn = libvirt.open(None)
if conn == None:
        print 'Failed to connect';
        sys.exit(1)

for id in conn.listDomainsID():
        dom = conn.lookupByName('r7')
        if dom == None:
                continue

        params_vnet0 = dom.interfaceParameters('vnet0', 0)
        print 'The params of vnet0 is %s' % params_vnet0

        params_vnet1 = dom.interfaceParameters('vnet1', 0)
        print 'The params of vnet1 is %s' % params_vnet1

        dom.setInterfaceParameters('vnet0', params_vnet1, 0)
        params_vnet0_new = dom.interfaceParameters('vnet0', 0)
        print 'The new params of vnet0 is %s' % params_vnet0_new
     
        dom.setInterfaceParameters('vnet1', params_vnet0, 0)
        params_vnet1_new = dom.interfaceParameters('vnet1', 0)
        print 'The new params of vnet1 is %s' % params_vnet1_new


# python test.py
The params of vnet0 is {'outbound.peak': 256, 'inbound.peak': 5000, 'inbound.burst': 1024, 'inbound.average': 1000, 'outbound.average': 128, 'outbound.burst': 256}
The params of vnet1 is {'outbound.peak': 0, 'inbound.peak': 0, 'inbound.burst': 0, 'inbound.average': 0, 'outbound.average': 0, 'outbound.burst': 0}
The new params of vnet0 is {'outbound.peak': 0, 'inbound.peak': 0, 'inbound.burst': 0, 'inbound.average': 0, 'outbound.average': 0, 'outbound.burst': 0}
The new params of vnet1 is {'outbound.peak': 256, 'inbound.peak': 5000, 'inbound.burst': 1024, 'inbound.average': 1000, 'outbound.average': 128, 'outbound.burst': 256}


# virsh dumpxml r7|grep interface -A11
    <interface type='network'>
      <mac address='52:54:00:b1:ab:72'/>
      <source network='default'/>
      <target dev='vnet0'/>
      <model type='rtl8139'/>
      <alias name='net0'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
    </interface>
    <interface type='network'>
      <mac address='52:54:00:c9:8d:7f'/>
      <source network='default'/>
      <bandwidth>
        <inbound average='1000' peak='5000' burst='1024'/>
        <outbound average='128' peak='256' burst='256'/>
      </bandwidth>
      <target dev='vnet1'/>
      <model type='rtl8139'/>
      <alias name='net1'/>
      <address type='pci' domain='0x0000' bus='0x00' slot='0x03' function='0x0'/>
    </interface>

Comment 5 errata-xmlrpc 2015-03-05 07:32:48 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/RHSA-2015-0323.html


Note You need to log in before you can comment on or make changes to this bug.