From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N8KcK-0003vJ-K0 for qemu-devel@nongnu.org; Wed, 11 Nov 2009 16:20:40 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N8KcG-0003ld-M6 for qemu-devel@nongnu.org; Wed, 11 Nov 2009 16:20:40 -0500 Received: from [199.232.76.173] (port=52433 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N8KcG-0003lP-3B for qemu-devel@nongnu.org; Wed, 11 Nov 2009 16:20:36 -0500 Received: from qw-out-1920.google.com ([74.125.92.150]:64629) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N8KcF-0006Jz-NQ for qemu-devel@nongnu.org; Wed, 11 Nov 2009 16:20:35 -0500 Received: by qw-out-1920.google.com with SMTP id 5so282398qwc.4 for ; Wed, 11 Nov 2009 13:20:35 -0800 (PST) Message-ID: <4AFB2A9E.9050309@codemonkey.ws> Date: Wed, 11 Nov 2009 15:20:30 -0600 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [RFC 0/8]: QError v2 References: <1257365047-25895-1-git-send-email-lcapitulino@redhat.com> In-Reply-To: <1257365047-25895-1-git-send-email-lcapitulino@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: pbonzini@redhat.com, aliguori@us.ibm.com, qemu-devel@nongnu.org, hollisb@us.ibm.com, kraxel@redhat.com 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: #define QERR_DEVICE_ALREADY_OPEN "{'class': 'DeviceAlreadyOpen', 'data' : {'bus_num': %d, 'addr': %d}" qemu_error_new(QERR_DEVICE_ALREADY_OPEN, bus_num, addr); That gives us a nice simple interface with full error checking on the parameters. 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." }, ... }; 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. Regards, Anthony Liguori