Bug 639581

Summary: virConnect instances in python leak file descriptors
Product: [Community] Virtualization Tools Reporter: Igor <igor47>
Component: libvirtAssignee: Daniel Veillard <veillard>
Status: CLOSED UPSTREAM QA Contact:
Severity: high Docs Contact:
Priority: low    
Version: unspecifiedCC: crobinso, maciej, xen-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-01-29 15:15:00 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.