Bugzilla will be upgraded to version 5.0 on a still to be determined date in the near future. The original upgrade date has been delayed.
Bug 591839 - Generate python wrappers module error
Generate python wrappers module error
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: libvirt (Show other bugs)
6.0
All Linux
low Severity medium
: rc
: ---
Assigned To: Chris Lalancette
Virtualization Bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2010-05-13 06:49 EDT by Alex Jia
Modified: 2010-11-11 09:48 EST (History)
6 users (show)

See Also:
Fixed In Version: libvirt-0_8_1-8_el6
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2010-11-11 09:48:48 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Alex Jia 2010-05-13 06:49:34 EDT
Description of problem:
missing virSnapshot class in generator.py from source code of libvirt.

Version-Release number of selected component (if applicable):
[root@dhcp-66-70-62 ajia]# uname -a
Linux dhcp-66-70-62.nay.redhat.com 2.6.32-20.el6.x86_64 #1 SMP Tue Apr 6 13:40:08 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

[root@dhcp-66-70-62 ajia]# cat /etc/redhat-release 
Red Hat Enterprise Linux release 6.0 Beta (Santiago)

[root@dhcp-66-70-62 ajia]# rpm -qa|grep kvm
qemu-kvm-tools-0.12.1.2-2.48.el6.x86_64
qemu-kvm-debuginfo-0.12.1.2-2.48.el6.x86_64
qemu-kvm-0.12.1.2-2.48.el6.x86_64

[root@dhcp-66-70-62 ajia]# rpm -qa|grep libvirt
libvirt-java-devel-0.4.2-2.el6.noarch
libvirt-devel-0.8.1-3.el6.x86_64
libvirt-0.8.1-3.el6.x86_64
libvirt-cim-0.5.8-2.el6.x86_64
libvirt-cim-debuginfo-0.5.8-2.el6.x86_64
libvirt-java-0.4.2-2.el6.noarch
libvirt-python-0.8.1-3.el6.x86_64
libvirt-client-0.8.1-3.el6.x86_64
libvirt-debuginfo-0.8.1-3.el6.x86_64

source code: GIT source repository (Thu May 13)

How reproducible:
always

Steps to Reproduce:
1.start a guest with qcow2 images
2.create the guest snapshot from xml
3.
  
Actual results:
[root@dhcp-66-70-62 libvirt-test-API]# python
Python 2.6.2 (r262:71600, Jan 25 2010, 23:34:16) 
[GCC 4.4.3 20100121 (Red Hat 4.4.3-1)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import libvirt
>>> con = libvirt.open(None)
>>> dom = con.lookupByName('rhel5u4-qcow2')
>>> dom.snapshotNum(0)
0
>>> dom.snapshotListNames(0)
[]
>>> fp = open("snapshot.xml", "r")
>>> xmldesc = fp.read()
>>> print xmldesc
<domainsnapshot>
  <name>snapshot1</name>
  <description>hello snapshot</description>
</domainsnapshot>

>>> dom.snapshotCreateXML(xmldesc, 0)
libvir: QEMU error : internal error unable to execute QEMU command 'savevm': The command savevm has not been found
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 662, in snapshotCreateXML
    if ret is None:raise libvirtError('virDomainSnapshotCreateXML() failed', dom=self)
libvirt.libvirtError: internal error unable to execute QEMU command 'savevm': The command savevm has not been found

>>> dom.snapshotNum(0)
1
>>> name_list = dom.snapshotListNames(0)
>>> print name_list
['snapshot1']
>>> for name in name_list:
...     print dom.snapshotLookupByName(name, 0)
... 
Exception AttributeError: "virDomainSnapshot instance has no attribute '_o'" in <bound method virDomainSnapshot.__del__ of <libvirt.virDomainSnapshot instance at 0x7f48063c6908>> ignored
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
  File "/usr/lib64/python2.6/site-packages/libvirt.py", line 677, in snapshotLookupByName
    __tmp = virDomainSnapshot(self,_obj=ret)
TypeError: __init__() got multiple values for keyword argument '_obj'

Expected results:
fix it

Additional info:
when doing dom.snapshotCreateXML(xmldesc, 0), some error messages are raised, this is another bug, please as 589076.

the following code line from generator.py is missing virSnapshot class:

1127                 if classname in [ "virDomain", "virNetwork", "virInterface", "virStoragePool",
1128                                   "virStorageVol", "virNodeDevice", "virSecret","virStream",
1129                                   "virNWFilter" ]:
1130                     classes.write("    def __init__(self, conn, _obj=None):\n")
1131                 else:
1132                     classes.write("    def __init__(self, _obj=None):\n")

it lead to virSnapshot class uses 1132 line to construct,at the result,
virDomainSnapshot class misses 'conn' argument, the following error 
code line occurs in libvirt.py:

2446 class virDomainSnapshot:
2447     def __init__(self,  _obj=None):
2448         if _obj != None:self._o = _obj;return
2449         self._o = None
Comment 2 RHEL Product and Program Management 2010-05-13 08:48:18 EDT
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux major release.  Product Management has requested further
review of this request by Red Hat Engineering, for potential inclusion in a Red
Hat Enterprise Linux Major release.  This request is not yet committed for
inclusion.
Comment 3 Chris Lalancette 2010-05-20 17:06:16 EDT
I've put a test package with a fix for this problem at:

http://people.redhat.com/clalance/bz589864-bz591839/

Can you download it, install it, and try your test-case again?

Thanks,
Chris Lalancette
Comment 4 Alex Jia 2010-05-21 01:57:57 EDT
(In reply to comment #3)
Hi Chris,
I retested it with your given packages, but I met a error:
error: server closed connection: 
error: failed to connect to the hypervisor
Although I restart libvirtd service again, and I can correctly run 'virsh uri',
it still is failed when I define a domain from xml, I can see the above error information, which should be a "VIR_ERR_SYSTEM_ERROR". it seems that socket builds connection failed when running 'virsh' command again.Need I some privilege to connect the hypervisor for your given packages?

Steps to Reproduce:
[root@dhcp-66-70-62 ajia]# service libvirtd restart
Stopping libvirtd daemon:                                  [FAILED]
Starting libvirtd daemon:                                  [  OK  ]
[root@dhcp-66-70-62 ajia]# service libvirtd restart
Stopping libvirtd daemon:                                  [  OK  ]
Starting libvirtd daemon:                                  [  OK  ]
[root@dhcp-66-70-62 ajia]# virsh uri
qemu:///system

[root@dhcp-66-70-62 ajia]# virsh define rhel5u4-qcow2.xml 
error: server closed connection: 
error: failed to connect to the hypervisor

BTW, I can successfully define a domain from the rhel5u4-qcow2.xml with release packages of libvirt.
Comment 5 Chris Lalancette 2010-05-24 15:58:20 EDT
(In reply to comment #4)
> (In reply to comment #3)
> Hi Chris,
> I retested it with your given packages, but I met a error:
> error: server closed connection: 
> error: failed to connect to the hypervisor
> Although I restart libvirtd service again, and I can correctly run 'virsh uri',
> it still is failed when I define a domain from xml, I can see the above error
> information, which should be a "VIR_ERR_SYSTEM_ERROR". it seems that socket
> builds connection failed when running 'virsh' command again.Need I some
> privilege to connect the hypervisor for your given packages?

Yeah, there is some bug in the package I built for you, but I just can't figure out what it is at the moment.  Can you collect a corefile from the crashing libvirtd and upload it somewhere so I can take a look at it?  Alternatively if you give me access to your machine, I can log in and see what is going on myself (I'll need the IP address and password for the machine in that case).

Thanks,
Chris Lalancette
Comment 6 Chris Lalancette 2010-05-25 09:30:30 EDT
Hi Alex,
     I know you said you are busy for the rest of the week, so I'll just leave this comment and you can get back to it when you have time.  The problem with the original package I uploaded had to do with the way I built it.  I've now fixed the package and installed it onto your machine.  You can also download the fixed packages from:

http://people.redhat.com/clalance/bz589864-bz591839/

With that in place, I was able to successfully run the example you gave in your initial comment on a *shut-off* machine.  Doing a snapshot on a running machine won't work in RHEL-6 because the QMP support for savevm is missing, but that is a qemu bug and not a libvirt bug.

That being said, I would like for you to re-test this package again just to have independent verification.  Just let me know when you've had time to take a look again.

Thanks,
Chris Lalancette
Comment 7 Alex Jia 2010-05-26 04:19:01 EDT
(In reply to comment #6)
Chris,
I re-test this package using previous steps and can get snapshot object:
>>> snap = dom.snapshotLookupByName("snapshot1", 0)
>>> dir(snap)
['__del__', '__doc__', '__init__', '__module__', '_dom', '_o', 'delete', 'domain', 'getXMLDesc']
>>> snap.getXMLDesc(0)
'<domainsnapshot>\n  <name>snapshot1</name>\n  <description>hello snapshot</description>\n  <state>shutoff</state>\n  <creationTime>1274794486</creationTime>\n  <domain>\n    <uuid>daab6033-e29f-53a4-99e8-45c1a4df8881</uuid>\n  </domain>\n</domainsnapshot>\n'
>>> snap.domain().name()
'rhel5u4-qcow2'
>>> snap.delete(0)
0
>>> dom.snapshotListNames(0)
[]

so the issue has been fixed with libvirt-0.8.1-6bz589864bz591839.el6.x86_64
on REHL6.0-Beta.
Comment 8 Chris Lalancette 2010-05-26 08:47:13 EDT
(In reply to comment #7)
> (In reply to comment #6)
> Chris,
> I re-test this package using previous steps and can get snapshot object:
> >>> snap = dom.snapshotLookupByName("snapshot1", 0)
> >>> dir(snap)
> ['__del__', '__doc__', '__init__', '__module__', '_dom', '_o', 'delete',
> 'domain', 'getXMLDesc']
> >>> snap.getXMLDesc(0)
> '<domainsnapshot>\n  <name>snapshot1</name>\n  <description>hello
> snapshot</description>\n  <state>shutoff</state>\n 
> <creationTime>1274794486</creationTime>\n  <domain>\n   
> <uuid>daab6033-e29f-53a4-99e8-45c1a4df8881</uuid>\n 
> </domain>\n</domainsnapshot>\n'
> >>> snap.domain().name()
> 'rhel5u4-qcow2'
> >>> snap.delete(0)
> 0
> >>> dom.snapshotListNames(0)
> []
> 
> so the issue has been fixed with libvirt-0.8.1-6bz589864bz591839.el6.x86_64
> on REHL6.0-Beta.    

Great, thanks for the testing!  I'll get this patch posted.

Chris Lalancette
Comment 9 Dave Allan 2010-06-10 17:32:57 EDT
libvirt-0_8_1-8_el6 has been built in RHEL-6-candidate with the fix.

Dave
Comment 10 LiZhang Li 2010-06-13 05:23:37 EDT
Verified.The python interface works fine in snapshot create and delete.

>>> for name in name_list:
...     print dom.snapshotLookupByName(name,0)
... 
<libvirt.virDomainSnapshot instance at 0x7fe2e99005a8>
Comment 11 releng-rhel@redhat.com 2010-11-11 09:48:48 EST
Red Hat Enterprise Linux 6.0 is now available and should resolve
the problem described in this bug report. This report is therefore being closed
with a resolution of CURRENTRELEASE. You may reopen this bug report if the
solution does not work for you.

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