qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2] block/curl: Don't lose original error when a


From: Richard W.M. Jones
Subject: Re: [Qemu-devel] [PATCH v2] block/curl: Don't lose original error when a connection fails.
Date: Wed, 8 Jul 2015 13:27:26 +0100
User-agent: Mutt/1.5.20 (2009-12-10)

On Wed, Jul 08, 2015 at 02:01:30PM +0200, Kevin Wolf wrote:
> The guest can't cause it, but once the connection is down, I expect
> every request to fail. You don't have to have a malicious guest for
> filling up the log file, it just needs to be careless enough to continue
> trying new requests instead of offlining the device.

How about something along these lines?

[I'm not clear if atomic is necessary here, nor if there is already
some mechanism for suppressing log messages - a cursory grep of the
qemu source didn't find anything.]

diff --git a/block/curl.c b/block/curl.c
index 2fd7c06..33c14d8 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -299,11 +299,20 @@ static void curl_multi_check_completion(BDRVCURLState *s)
             /* ACBs for successful messages get completed in curl_read_cb */
             if (msg->data.result != CURLE_OK) {
                 int i;
+                static int errcount = 100;
+                int current_errcount;
 
                 /* Don't lose the original error message from curl, since
                  * it contains extra data.
                  */
-                error_report("curl: %s", state->errmsg);
+                current_errcount = atomic_fetch_add(&errcount, 0);
+                if (current_errcount > 0) {
+                    error_report("curl: %s", state->errmsg);
+                    if (current_errcount == 1) {
+                        error_report("curl: further errors suppressed");
+                    }
+                    atomic_dec(&errcount);
+                }
 
                 for (i = 0; i < CURL_NUM_ACB; i++) {
                     CURLAIOCB *acb = state->acb[i];

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
libguestfs lets you edit virtual machines.  Supports shell scripting,
bindings from many languages.  http://libguestfs.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]