From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCoRu-0004Ia-Oj for qemu-devel@nongnu.org; Wed, 08 Jul 2015 08:27:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCoRt-0001na-M2 for qemu-devel@nongnu.org; Wed, 08 Jul 2015 08:27:38 -0400 Date: Wed, 8 Jul 2015 13:27:26 +0100 From: "Richard W.M. Jones" Message-ID: <20150708122726.GX29283@redhat.com> References: <1435664924-9377-1-git-send-email-rjones@redhat.com> <1435664924-9377-2-git-send-email-rjones@redhat.com> <87pp498llj.fsf@blackfin.pond.sub.org> <20150708102337.GD4117@noname.redhat.com> <20150708113601.GW29283@redhat.com> <20150708120130.GI4117@noname.redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20150708120130.GI4117@noname.redhat.com> Subject: Re: [Qemu-devel] [PATCH v2] block/curl: Don't lose original error when a connection fails. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf Cc: agraf@suse.de, jcody@redhat.com, Markus Armbruster , qemu-block@nongnu.org, qemu-devel@nongnu.org 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