Bug 639581 - virConnect instances in python leak file descriptors
Summary: virConnect instances in python leak file descriptors
Keywords:
Status: CLOSED UPSTREAM
Alias: None
Product: Virtualization Tools
Classification: Community
Component: libvirt
Version: unspecified
Hardware: x86_64
OS: Linux
low
high
Target Milestone: ---
Assignee: Daniel Veillard
QA Contact:
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2010-10-02 11:10 UTC by Igor
Modified: 2012-01-29 15:15 UTC (History)
3 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-01-29 15:15:00 UTC
Embargoed:


Attachments (Terms of Use)

Description Igor 2010-10-02 11:10:15 UTC
Description of problem: when opening connections to the xen hypervisor using the python bindings, open files persist even after the connection has been closed.


Version-Release number of selected component (if applicable):
>>> libvirt.getVersion()
8003
cloud1:~# aptitude show libvirt0 | grep Version
Version: 0.8.3-1

How reproducible: always

Steps to Reproduce: here is most of a log of a python session which demonstrates the problem (some lines containing '0' have been omitted)

cloud1:~# python
Python 2.6.6 (r266:84292, Aug 29 2010, 12:36:23) 
[GCC 4.4.5 20100824 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, libvirt
>>> os.system("lsof -p %s | wc -l" % os.getpid())
33
>>> con = libvirt.openReadOnly('xen:///')
>>> os.system("lsof -p %s | wc -l" % os.getpid())
38
>>> con.close()
>>> os.system("lsof -p %s | wc -l" % os.getpid())
37
>>> con = libvirt.openReadOnly('xen:///')
>>> con.close()
>>> os.system("lsof -p %s | wc -l" % os.getpid())
40
>>> con = libvirt.open('xen:///')
>>> con.close()
>>> os.system("lsof -p %s | wc -l" % os.getpid())
43
>>> del con
>>> os.system("lsof -p %s | wc -l" % os.getpid())
43
>>> 

  
Actual results: every time a connection is opened and closed, the number of open files increases by 4 and then decreases by 1. this leaves 3 files open even after the connection has been closed.


Expected results: all the open files that are used by libvirt connection objects should be closed.


Additional info: eventually, this problem has been leading to "Too many open files" errors in my application:
libvirtError: cannot read file /sys/hypervisor/properties/capabilities: Too
many open files

The open files are a socket and two FIFO pipes; for instance:

python  20690 root   10u  unix 0xffff88000030ea00      0t0  201518 socket
python  20690 root   11r  FIFO                0,8      0t0  201520 pipe
python  20690 root   12w  FIFO                0,8      0t0  201520 pipe

Comment 1 Igor 2010-10-06 05:42:37 UTC
this is not just a problem with the debian squeeze package. i have compiled libvirt from source using the .tar.gz packages from the libvirt website. The problem persists with both 8.0.3 and 8.0.4 releases.

i do not have this problem with the 8.0.0 release:
>>> libvirt.getVersion()
8000
>>> os.system("lsof -p %s | wc -l" % os.getpid())
31
0
>>> con = libvirt.openReadOnly('xen:///')
>>> con.close()
0
>>> os.system("lsof -p %s | wc -l" % os.getpid())
31

Comment 2 maciej 2012-01-29 12:48:05 UTC
Did you manage to fix or workaround this problem? Is there any reason why it has not been solved yet?

Comment 3 Cole Robinson 2012-01-29 15:15:00 UTC
I can't reproduce with current upstream using a readonly qemu:///system connection, so closing as UPSTREAM.

If anyone can still reproduce with an upstream version, please try at least xen/qemu and the test:///default unit driver which should help us locate the culprit.

If anyone is still seeing this problem in an older distro version, please file a bug with your distro. This tracker is for upstream issues only.


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