From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8ZvS-0008TZ-0D for qemu-devel@nongnu.org; Thu, 12 Nov 2009 08:41:26 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8ZvN-0008NX-Hb for qemu-devel@nongnu.org; Thu, 12 Nov 2009 08:41:25 -0500 Received: from [199.232.76.173] (port=52495 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8ZvM-0008Mt-RU for qemu-devel@nongnu.org; Thu, 12 Nov 2009 08:41:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:63497) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8ZvM-0001xK-8A for qemu-devel@nongnu.org; Thu, 12 Nov 2009 08:41:20 -0500 Date: Thu, 12 Nov 2009 11:41:08 -0200 From: Luiz Capitulino Subject: Re: [Qemu-devel] [RFC 0/8]: QError v2 Message-ID: <20091112114108.4cca3405@doriath> In-Reply-To: <4AFB2A9E.9050309@codemonkey.ws> References: <1257365047-25895-1-git-send-email-lcapitulino@redhat.com> <4AFB2A9E.9050309@codemonkey.ws> 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: Anthony Liguori Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, hollisb@us.ibm.com, kraxel@redhat.com On Wed, 11 Nov 2009 15:20:30 -0600 Anthony Liguori wrote: > Luiz Capitulino wrote: > > Hi, > > > > I can't remember seeing updated versions of a RFC series, but this should > > prevent Anthony's scripts from merging these patches. > > > > This new QError version has two major changes: the static error table has > > been dropped and I'm using symbolic names instead of error codes. > > > > Now, a call to: > > > > monitor_printf(mon, "husb: host usb device %d.%d is already open\n", > > bus_num, addr); > > > > Would become something like: > > > > qemu_error_new('DeviceAlreadyOpen', "{ 'bus_num': %d, 'addr': %d }", > > bus_num, addr); > > > > I mostly like this but this is not what the patches do :-) > > Here's what I would like to see: Thinking about this a little more I see some problems with it. > #define QERR_DEVICE_ALREADY_OPEN "{'class': 'DeviceAlreadyOpen', 'data' > : {'bus_num': %d, 'addr': %d}" > > qemu_error_new(QERR_DEVICE_ALREADY_OPEN, bus_num, addr); What about DeviceAlreadyOpen errors with a different argument list? > That gives us a nice simple interface with full error checking on the > parameters. I've said this is not so simple because people writing those macros would find out that the 'class' or 'data' _keys_ are missing or incorrect only at run-time, when the error is triggered. > For human readable strings, I'd suggest making a table somewhere else > that looked like: > > QErrorStringTable qerror_descriptions[] = { > { QERR_DEVICE_ALREADY_OPEN, "This device at %(bus_num)d.%(addr)d is > already open." }, > ... > }; How do you suggest we lookup the table? Doing a strcmp() on QERR_DEVICE_ALREADY_OPEN? > There are a number of advantages to an approach like this. The table > can be reused by both in the server and by a client. My suggestions on both problems makes me willing go back to my initial series, which had a table indexed by an error number.