From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mtmvg-00012w-J4 for qemu-devel@nongnu.org; Fri, 02 Oct 2009 14:32:32 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mtmva-0000yH-Tp for qemu-devel@nongnu.org; Fri, 02 Oct 2009 14:32:32 -0400 Received: from [199.232.76.173] (port=60234 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mtmva-0000y6-3r for qemu-devel@nongnu.org; Fri, 02 Oct 2009 14:32:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52060) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MtmvZ-0000PF-Hu for qemu-devel@nongnu.org; Fri, 02 Oct 2009 14:32:25 -0400 Date: Fri, 2 Oct 2009 15:32:16 -0300 From: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH v1 00/14]: Initial QObject conversion Message-ID: <20091002153216.43d24536@doriath> In-Reply-To: <4AC61DED.5030702@redhat.com> References: <1254412245-10452-1-git-send-email-lcapitulino@redhat.com> <4AC5F646.9040800@redhat.com> <20091002104729.510d67de@doriath> <4AC60B7F.5040809@redhat.com> <20091002115509.0085b7e3@doriath> <4AC61DED.5030702@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: Gerd Hoffmann Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, avi@redhat.com On Fri, 02 Oct 2009 17:36:13 +0200 Gerd Hoffmann wrote: > Hi, > > > >> So maybe they shouldn't be named MonitorError in the first place? > > > > What do you suggest? > > > > Hm.. This could be QError, meaning that it's also a QObject, > > so that we can put it in dicts, lists, etc. > > Makes sense to me. > > Attaching the pretty-print callback to the error struct not to the > monitor command is a good move too. Makes it easier to reuse these > functions. > > Hmm, maybe it would be even better to link the pretty-print functions to > error codes? Yes, I'll try that. > >> Why user_error is needed in the first place btw? To maintain > >> backward-compatible error message formating? > > > > Yes and to do pretty printing too. > > > > For example: > > > > qemu_error("Device \"%s\" not found. Try -device '?' for a list.\n", > > driver); > > > > Makes sense for humans, but for QMP it would probably look like: > > > > { "error": { "code": 1234, > > "desc": "device not found", > > "data": { "name": "foobar-device" } } } > > You could have a generic function which makes a message like this: > > 'device not found: name=foobar-device' > > out of the QError. Not too bad. You'll loose the '-device ?' hint though. > > I think it is reasonable to make the pretty-print callback optional and > use the generic function in case it isn't present. So you have > something working by default and can override it of the message isn't > userfriendly or backward-compatible enougth. Yeah, it's a good idea. > > So, when QMP is disabled that function will be called to print the error > > for humans. When QMP is enabled this is never called and the protocol > > emission code will use QError to emit something like the { "error" } > > dict above. > > Thanks for the explanation. Thanks for the feedback!