[libvirt] libvirt will wait 20 minutes or hang when the network interface down

Benjamin Wang (gendwang) gendwang at cisco.com
Sat Dec 22 08:59:58 UTC 2012


Hi,
  I find that when the network interface is down. In most scenarios, the libvirt will wait 20 minutes and report the exception. In seldom scenarios, the polling
thread will hang even if the network is recovered.
The following is the formal description from libcurl website:
http://curl.haxx.se/docs/faq.html  (Section "4.19 Why doesn't cURL return an error when the network cable is unplugged?")
The following is the similar case about thread hand:
http://curl.haxx.se/mail/lib-2010-07/0108.html

For "wait 20 minutes", although this is the TCP normal mechanism, but if a server manages tons of thousands of devices by libvirt. When 1000 devices are down,
This could cause thread leak for a long period.
For thread hang, this could cause thread leak forever.

I tried to add the following codes in esx_vi.c. It seems that these code can avoid the above issues. Would you give your comments?

    if (curl->headers == NULL) {
        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                       _("Could not build CURL header list"));
        return -1;
    }

+    curl_easy_setopt(curl->handle, CURLOPT_LOW_SPEED_LIMIT, 10);
+    curl_easy_setopt(curl->handle, CURLOPT_LOW_SPEED_TIME, 120);

    curl_easy_setopt(curl->handle, CURLOPT_USERAGENT, "libvirt-esx");
    curl_easy_setopt(curl->handle, CURLOPT_HEADER, 0);
    curl_easy_setopt(curl->handle, CURLOPT_FOLLOWLOCATION, 0);
curl_easy_setopt(curl->handle, CURLOPT_SSL_VERIFYPEER,


B.R.
Benjamin Wang
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20121222/b9039b35/attachment-0001.htm>


More information about the libvir-list mailing list