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 766553 - Expose 'virDomainSnapshotListChildrenNames' API in python binding
Summary: Expose 'virDomainSnapshotListChildrenNames' API in python binding
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt
Version: 6.3
Hardware: x86_64
OS: Linux
medium
medium
Target Milestone: rc
: ---
Assignee: Peter Krempa
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-12-12 10:46 UTC by Alex Jia
Modified: 2012-06-20 06:38 UTC (History)
7 users (show)

Fixed In Version: libvirt-0.9.9-1.el6
Doc Type: Bug Fix
Doc Text:
No Documentation needed
Clone Of:
Environment:
Last Closed: 2012-06-20 06:38:34 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2012:0748 0 normal SHIPPED_LIVE Low: libvirt security, bug fix, and enhancement update 2012-06-19 19:31:38 UTC

Description Alex Jia 2011-12-12 10:46:35 UTC
Description of problem:
Need to expose 'virDomainSnapshotListChildrenNames' API in python binding. 

Version-Release number of selected component (if applicable):
libvirt-python-0.9.8-1.el6.x86_64

How reproducible:
always

Steps to Reproduce:
1. define a guest with qcow2 image
2. create a snapshot for the guest
3. run interact python to try libvirt python API

# qemu-img create -f qcow2 /var/lib/libvirt/images/disk.img 100M
Formatting '/var/lib/libvirt/images/disk.img', fmt=qcow2 size=104857600 encryption=off cluster_size=65536

# cat > /root/demo.xml <<EOF
<domain type='qemu'>
  <name>demo</name>
  <memory>219200</memory>
  <vcpu>1</vcpu>
  <os>
    <type arch='x86_64'>hvm</type>
    <boot dev='hd'/>
  </os>
  <devices>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2'/>
      <source file='/var/lib/libvirt/images/disk.img'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <input type='mouse' bus='ps2'/>
    <graphics type='spice' autoport='yes' listen='0.0.0.0'/>
  </devices>
</domain>
EOF

# virsh define /root/demo.xml
Domain demo defined from /root/demo.xml

# virsh snapshot-list demo
 Name                 Creation Time             State
------------------------------------------------------------

# virsh snapshot-create-as demo
Domain snapshot 1323685119 created

# virsh snapshot-list demo --descendants
 Name                 Creation Time             State
------------------------------------------------------------
 1323685119           2011-12-12 18:18:39 +0800 shutoff

# python
Python 2.6.6 (r266:84292, Sep 12 2011, 14:03:14) 
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open(None)
>>> dom_name = con.listDefinedDomains()[0]
>>> dom = con.lookupByName(dom_name)
>>> snap_name = dom.snapshotListNames(0)[0]
>>> snap = dom.snapshotLookupByName(snap_name, 0)
>>> dir(snap)
['__del__', '__doc__', '__init__', '__module__', '_dom', '_o', 'delete', 'domain', 'getConnect', 'getDomain', 'getName', 'getParent', 'getXMLDesc', 'listChildrenNames', 'numChildren']
>>> snap.getName()
'1323685119'
>>> snap.getDomain().name()
'demo'
>>> snap.listChildrenNames(0)

Actual results:

>>> snap.listChildrenNames(0)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 3733, in listChildrenNames
    ret = libvirtmod.virDomainSnapshotListChildrenNames(self._o, flags)
AttributeError: 'module' object has no attribute 'virDomainSnapshotListChildrenNames'

Expected results:
fix it.

Additional info:

# nm -a -D /usr/lib64/python2.6/site-packages/libvirtmod.so |grep virDomainSnapshotNumChildren
000000000001d720 T libvirt_virDomainSnapshotNumChildren
                 U virDomainSnapshotNumChildren

# nm -a -D /usr/lib64/python2.6/site-packages/libvirtmod.so |grep virDomainSnapshotListChildrenNames

Note: nothing return in here.


In addition, it seems libvirt has exposed this c API, please see this commit:
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=f2013c9dd1ce468b8620ee35c232a93ef7026fb0

Comment 1 Peter Krempa 2011-12-13 22:38:36 UTC
Function export fixed with upstream commit:

commit fbd8d6fc8786cde59e34b39450f3c2c632376f8f
Author: Peter Krempa <pkrempa>
Date:   Tue Dec 13 15:49:59 2011 +0100

    python: Fix export of virDomainSnapshotListChildrenNames
    
    Commit f2013c9dd1ce468b8620ee35c232a93ef7026fb0 added implementation of
    virDomainSnapshotListChildrenNames override export, but registration of
    the newly exported function was not added.


Thanks for finding the commit that added the export, it made finding the error easier.

Comment 3 Wayne Sun 2012-01-10 10:00:03 UTC
Follow the steps in description:

After last virsh command of create snapshot, create a children snapshot

# virsh snapshot-create-as demo
Domain snapshot 1326189262 created
# virsh snapshot-create-as demo
Domain snapshot 1326189264 created
# virsh snapshot-list demo --descendants
 Name                 Creation Time             State
------------------------------------------------------------
 1326189262           2012-01-10 17:54:22 +0800 shutoff
 1326189264           2012-01-10 17:54:24 +0800 shutoff


# python
Python 2.6.6 (r266:84292, Sep 12 2011, 14:03:14) 
[GCC 4.4.5 20110214 (Red Hat 4.4.5-6)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> conn = libvirt.open(None)
>>> dom = conn.lookupByName('demo')
>>> dom.snapshotListNames(0)
['1326189264', '1326189262']
>>> snap_name = dom.snapshotListNames(0)[1]
>>> snap = dom.snapshotLookupByName(snap_name, 0)
>>> dir(snap)
['__del__', '__doc__', '__init__', '__module__', '_dom', '_o', 'delete', 'domain', 'getConnect', 'getDomain', 'getName', 'getParent', 'getXMLDesc', 'listChildrenNames', 'numChildren']
>>> snap.getName()
'1326189262'
>>> snap.getDomain().name()
'demo'
>>> snap.listChildrenNames(0)
['1326189264']
>>> snap.numChildren(0)
1
>>> 

so, this is fixed

Comment 4 Wayne Sun 2012-01-10 10:21:53 UTC
The package is:
# rpm -q libvirt libvirt-python
libvirt-0.9.9-1.el6.x86_64
libvirt-python-0.9.9-1.el6.x86_64

Comment 5 Peter Krempa 2012-05-02 09:49:37 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
No Documentation needed

Comment 7 errata-xmlrpc 2012-06-20 06:38:34 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.

http://rhn.redhat.com/errata/RHSA-2012-0748.html


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