Bug 743297

Summary: org.libvirt.LibvirtException: cannot recv data: : Connection reset by peer
Product: [Community] Virtualization Tools Reporter: Preethi Ramesh <iampreethiramesh>
Component: libvirtAssignee: Libvirt Maintainers <libvirt-maint>
Status: CLOSED NOTABUG QA Contact:
Severity: urgent Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: crobinso, dallan, eblake, 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: 2011-10-04 15:49:20 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Preethi Ramesh 2011-10-04 14:30:54 UTC
Description of problem:
I'm using Libvirt's Java API and connecting to the hypervisor using the same. My program is such that periodic discovery of active VMs is done using Libvirt's functions.

Version-Release number of selected component (if applicable):
I'm using QEMU emulator version 0.14.0 (qemu-kvm-0.14.0) and Libvirt version 0.4.7 on Ubuntu 11.04.


How reproducible:
Easy

Steps to Reproduce:
1. Use Libvirt's Java API and perform Connect c1=new Connect("qemu:///system",false); 
2. Timer t=new Timer();
   t.scheduleAtFixedRate(new ackDiscovery(), delay, period);
 Where ackDiscovery() has Step 1 In its run().
  
Actual results:
After 20 successful executions, I get this error:

libvir: Remote error : cannot recv data: : Connection reset by peer
4 Oct, 2011 7:40:57 PM Others.ackDiscovery run
SEVERE: null
org.libvirt.LibvirtException: cannot recv data: : Connection reset by peer
        at org.libvirt.ErrorHandler.processError(ErrorHandler.java:33)
        at org.libvirt.Connect.processError(Connect.java:1322)
        at org.libvirt.Connect.<init>(Connect.java:194)
        at Others.ackDiscovery.ackInfo(ackDiscovery.java:50)
        at Others.ackDiscovery.run(ackDiscovery.java:102)
        at java.util.TimerThread.mainLoop(Timer.java:534)
        at java.util.TimerThread.run(Timer.java:484)


Additional info:

Also, during the 5-6 iteration,  when I try to perform any VM related operations while the Java code connecting to Qemu is running such as shutdown, start VM using virsh, I end up with :
'libvir: Remote error : cannot recv data: : Connection reset by peer' on my Java IDE and 'error: cannot recv data: : Connection reset by peer error: failed to connect to the hypervisor' on the terminal running virsh.

Comment 1 Dave Allan 2011-10-04 14:51:00 UTC
Can you confirm what libvirt version you're using?  It's not really 0.4.7 on Ubuntu 11.04 is it?

Comment 2 Preethi Ramesh 2011-10-04 15:20:14 UTC
I'm using Libvirt version 0.8.8 and Libvirt's java API 0.4.7 on Ubuntu 11.04. Thanks!

Comment 3 Dave Allan 2011-10-04 15:36:11 UTC
Heh, I ought to have read the whole description before I asked my question--the answer was right there: you're running libvirt out of connections.  You only need to open one connection, not one connection for every API call you want to make.  The default max connections is 20, which is why it fails after that.

Comment 4 Preethi Ramesh 2011-10-04 15:51:36 UTC
Hey,
Changing the max_clients from 20 to 100 or 5 doesn't seem to make a difference as I still get the error after 20 runs.

Comment 5 Eric Blake 2011-10-04 15:56:09 UTC
Did you restart (or at least SIGHUP) libvirtd after changing the conf file?