From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NdPQ4-00045J-CO for qemu-devel@nongnu.org; Fri, 05 Feb 2010 09:44:28 -0500 Received: from [199.232.76.173] (port=50173 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NdPQ3-00044x-W1 for qemu-devel@nongnu.org; Fri, 05 Feb 2010 09:44:28 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NdPQ2-0000xI-2d for qemu-devel@nongnu.org; Fri, 05 Feb 2010 09:44:27 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60771) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NdPQ1-0000x4-J7 for qemu-devel@nongnu.org; Fri, 05 Feb 2010 09:44:25 -0500 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o15EiN0d027355 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 5 Feb 2010 09:44:24 -0500 Date: Fri, 5 Feb 2010 12:44:16 -0200 From: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH 3/4] QError: Don't abort on multiple faults Message-ID: <20100205124416.2790d2b8@doriath> In-Reply-To: References: <1265314396-6583-1-git-send-email-lcapitulino@redhat.com> <1265314396-6583-4-git-send-email-lcapitulino@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Markus Armbruster Cc: qemu-devel@nongnu.org On Fri, 05 Feb 2010 15:21:13 +0100 Markus Armbruster wrote: > Markus Armbruster writes: > > > Luiz Capitulino writes: > > > >> Ideally, Monitor code should report an error only once and > >> return the error information up the call chain. > >> > >> To assure that this happens as expected and that no error is > >> lost, we have an assert() in qemu_error_internal(). > >> > >> However, we still have not fully converted handlers using > >> monitor_printf() to report errors. As there can be multiple > >> monitor_printf() calls on an error, the assertion is easily > >> triggered when debugging is enabled; and we will get a memory > >> leak if it's not. > >> > >> The solution to this problem is to allow multiple faults by only > >> reporting the first one, and to release the additional error objects. > > > > I want this badly. > > > > [...] > > Let me elaborate a bit. While this patch is a much wanted improvement, > what I *really* want is something else. > > Right now, we have 41 uses of qemu_error_new(). We still have >300 uses > of monitor_printf(), many of them errors. Plus some 100 uses of > qemu_error(), which boils down to monitor_printf() when running within a > monitor. Not to mention >1000 uses of stderr. > > To convert a monitor handler to QError, we have to make it report > exactly one error on every unsuccessful path, with qemu_error_new(). > That's not too hard. Then we have to ensure it does not call > monitor_printf() directly (not hard either) or indirectly (ouch). I say > "ouch", because those prints can hide behind long call chains, in code > shared with other users. Cleaning up all those stray prints will take > time. As we have talked, this situation will be improved by making cmd_new return an error code, right? I've started working on it already, patches will be sent soon. > Without this patch, a stray print is fatal, unless it happens to be the > only one *and* there is no real error. > > With this patch, we survive, but the UndefinedError triggered by the > stray print displaces any later real error. > > What I really want is that stray prints do not mess with my real errors. There are two issues here: 1. In command handlers stray prints _usually_ report errors. If we go with shallow conversion, I believe that clients should be informed (in the form of an undefined error) that monitor_printf() has been called 2. We have agreed that multiple faults are not allowed and that reporting only the first one is fine. In shallow conversion (or even in buggy conversions) we can get multiple faults and we have to handle it So, the situation will be improved by my next series as we can use the return code to 'audit' qemu_error_new() usage (which includes monitor_printf() calls).