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 1113938 - error : virNetServerAddClient:270
Summary: error : virNetServerAddClient:270
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: virt-who
Version: 6.7
Hardware: Unspecified
OS: Unspecified
high
high
Target Milestone: rc
: ---
Assignee: Radek Novacek
QA Contact: gaoshang
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2014-06-27 09:40 UTC by Petr Sklenar
Modified: 2016-12-01 00:32 UTC (History)
6 users (show)

Fixed In Version: virt-who-0.10-3.el6
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-10-14 07:13:18 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2014:1513 0 normal SHIPPED_LIVE virt-who bug fix and enhancement update 2014-10-14 01:22:23 UTC

Description Petr Sklenar 2014-06-27 09:40:10 UTC
Description of problem:
there is error in the /var/log/libvirt/libvirtd.log
virsh list doesn't work


Version-Release number of selected component (if applicable):
libvirt-0.10.2-39.el6.x86_64

How reproducible:
always on my three machine

Steps to Reproduce:
1. there is issue after update from rhel65 > rhel66(nightbuild)
2. /var/log/libvirt/libvirtd.log  is full log errors
3. virsh list shows error too
4. my settings:
cat /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
auth_tcp = "sasl"
tcp_port = "16509"


Actual results:
[root@pes-02 ~]# tail /var/log/libvirt/libvirtd.log -n2
2014-06-27 09:36:14.984+0000: 4434: error : virNetServerAddClient:270 : Too many active clients (20), dropping connection from 127.0.0.1;0
2014-06-27 09:36:14.985+0000: 4434: error : virNetServerAddClient:270 : Too many active clients (20), dropping connection from 127.0.0.1;0



[root@pes-02 ~]# virsh list
error: Failed to reconnect to the hypervisor
error: no valid connection
error: Cannot recv data: Connection reset by peer
### next time it works:
[root@pes-02 ~]# virsh list
 Id    Name                           State
----------------------------------------------------
 107   pes-guest-87                   running
 153   pes-guest-86                   running
 156   pes-guest-83                   running


Expected results:
works as expected

Additional info:

Comment 5 Jiri Denemark 2014-06-27 12:17:59 UTC
This is a bug in virt-who:

In /usr/share/virt-who/virt/libvirtd/libvirtd.py:

class Libvirtd(virt.DirectVirt):
    ...
    def _connect(self):
        monitor = LibvirtMonitor()
        try:
            self.virt = libvirt.openReadOnly('')
        except libvirt.libvirtError, e:
            self.logger.exception("Error in libvirt backend")
            raise virt.VirtError(str(e))

    def listDomains(self):
        """ Get list of all domains. """
        domains = []
        self._connect()

        try:
            # Active domains
            for domainID in self.virt.listDomainsID():
                domain = self.virt.lookupByID(domainID)
                if domain.UUIDString() == "00000000-0000-0000-0000-000000000000":
                    # Don't send Domain-0 on xen (zeroed uuid)
                    continue
                domains.append(virt.Domain(self.virt, domain))
                self.logger.debug("Virtual machine found: %s: %s" % (domain.name(), domain.UUIDString()))

            # Non active domains
            for domainName in self.virt.listDefinedDomains():
                domain = self.virt.lookupByName(domainName)
                domains.append(virt.Domain(self.virt, domain))
                self.logger.debug("Virtual machine found: %s: %s" % (domainName, domain.UUIDString()))
        except libvirt.libvirtError, e:
            raise virt.VirtError(str(e))
        return domains

In other words every call to Libvirtd.listDomains() opens a new connection to
libvirtd and does not close it. So it just waits for the destructor to be
called, which does not happen immediately when virt goes out of scope (AFAIK).

In /usr/share/virt-who/virtwho.py:

    def _readGuests(self, config):
        virt = Virt.fromConfig(self.logger, config)
        if not self.options.oneshot and virt.canMonitor():
            virt.startMonitoring(self.sync_event)
        if config.type not in ["esx", "rhevm", "hyperv"]:
            return virt.listDomains()
        else:
            return virt.getHostGuestMapping()

Here virt is instantiated from Libvirtd and then virt.listDomains() is called,
which opens a new connection. Afterwards the virt object gets out of scope
without ever closing the connection to libvirtd.

And _readGuests is called from _send, send, run:

    def run(self):
        if self.options.background and self.options.virtType == "libvirt":
            self.logger.debug("Starting infinite loop with %d seconds interval and event handling" % self.options.interval)
        else:
            self.logger.debug("Starting infinite loop with %d seconds interval" % self.options.interval)

        while 1:
            # Run in infinite loop and send list of UUIDs every 'options.interval' seconds

            if self.send():
                timeout = self.options.interval
            else:
                timeout = RetryInterval

            self.sync_event.wait(timeout)
            self.sync_event.clear()

In other words after several iterations of this infinite loop, virt-who
consumes all connections allowed for any client of libvirtd.

And even more interesting issue with virt-who is the number of threads running
(and likely trying to connect to libvirtd):

# ps -ef | grep virt-who
root     11805     1 64 Jun26 ?        17:47:03 /usr/bin/python /usr/share/virt-who/virtwho.py
# ls /proc/11805/task/ | wc -l
3191

And the number of threads increases over time.

Comment 7 Radek Novacek 2014-06-30 06:01:20 UTC
Sure, will fix it today or tomorrow.

Comment 11 Radek Novacek 2014-07-03 12:08:30 UTC
Fixed in virt-who-0.10-3.el6.

Comment 14 Radek Novacek 2014-07-11 08:18:13 UTC
Petr,

good to know, thanks for testing.

Comment 15 Liushihui 2014-07-28 06:00:35 UTC
Verified it on virt-who-0.10-3.el6

Steps to verify:
1. Settings libvirt as the following:
cat /etc/libvirt/libvirtd.conf
listen_tls = 0
listen_tcp = 1
auth_tcp = "sasl"
tcp_port = "16509"
2. Restart libvirtd service
# service libvirtd restart
3. tail -f /var/log/libvirt/libvirtd.log ,there isn't any error message as the following:
2014-06-27 09:36:14.984+0000: 4434: error : virNetServerAddClient:270 : Too many active clients (20), dropping connection from 127.0.0.1;0
4. No error message show after run "virsh list"
[root@hp-z220-05 libvirt-test-API]# virsh list 
 Id    Name                           State
----------------------------------------------------
 2     6.5_Server_x86_64              running

[root@hp-z220-05 libvirt-test-API]# virsh list  --all
 Id    Name                           State
----------------------------------------------------
 2     6.5_Server_x86_64              running
 -     5.10_Server_x86_64             shut off
 -     6.4_Server_x86_64              shut off
 -     6.5_Client_i386                shut off
 -     7.0_Server_x86_64              shut off
5. Check virt-who's thread is always 2 
[root@hp-z220-05 libvirt-test-API]# ps -ef | grep virt-who
root      1510     1  1 10:44 ?        00:02:14 /usr/bin/python /usr/share/virt-who/virtwho.py
root      4405 31169  0 13:57 pts/0    00:00:00 grep virt-who
[root@hp-z220-05 libvirt-test-API]# ls /proc/1510/task/ | wc -l
2
[root@hp-z220-05 libvirt-test-API]# ls /proc/1510/task/ | wc -l
2
[root@hp-z220-05 libvirt-test-API]# ls /proc/1510/task/ | wc -l
2

Comment 16 errata-xmlrpc 2014-10-14 07:13:18 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/RHBA-2014-1513.html


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