From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1My5CG-0000sp-Nr for qemu-devel@nongnu.org; Wed, 14 Oct 2009 10:51:25 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1My5CB-0000pa-25 for qemu-devel@nongnu.org; Wed, 14 Oct 2009 10:51:23 -0400 Received: from [199.232.76.173] (port=39044 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1My5C9-0000pL-MK for qemu-devel@nongnu.org; Wed, 14 Oct 2009 10:51:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33132) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1My5C8-00064n-It for qemu-devel@nongnu.org; Wed, 14 Oct 2009 10:51:17 -0400 Date: Wed, 14 Oct 2009 11:51:07 -0300 From: Luiz Capitulino Subject: Re: [Qemu-devel] [PATCH 7/9] qdev: Use QError for not found error Message-ID: <20091014115107.381fb26c@doriath> In-Reply-To: <877huy6hzm.fsf@pike.pond.sub.org> References: <1255453026-18637-1-git-send-email-lcapitulino@redhat.com> <1255453026-18637-8-git-send-email-lcapitulino@redhat.com> <877huy6hzm.fsf@pike.pond.sub.org> 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: aliguori@us.ibm.com, qemu-devel@nongnu.org, kraxel@redhat.com On Wed, 14 Oct 2009 00:34:21 +0200 Markus Armbruster wrote: > Luiz Capitulino writes: > > > Signed-off-by: Luiz Capitulino > > --- > > hw/qdev.c | 4 ++-- > > 1 files changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/hw/qdev.c b/hw/qdev.c > > index 906e897..3ce48f7 100644 > > --- a/hw/qdev.c > > +++ b/hw/qdev.c > > @@ -28,6 +28,7 @@ > > #include "net.h" > > #include "qdev.h" > > #include "sysemu.h" > > +#include "qerror.h" > > #include "monitor.h" > > > > static int qdev_hotplug = 0; > > @@ -176,8 +177,7 @@ DeviceState *qdev_device_add(QemuOpts *opts) > > /* find driver */ > > info = qdev_find_info(NULL, driver); > > if (!info) { > > - qemu_error("Device \"%s\" not found. Try -device '?' for a list.\n", > > - driver); > > + qemu_error_structed(QERR_QDEV_NFOUND, "{ s: s }", "name", driver); > > return NULL; > > } > > if (info->no_user) { > > And here we pay the price for structured error objects: reporting an > error becomes more difficult. The harder you make reporting errors, the > fewer errors get caught and reported. Also, the result is harder to > read. > > If we need the structure, then it's just a price we have to pay. Do we > need it? Yes, if we want clients to able to determine error causes. Of course that we can decide to provide less information, but this structure has three users (monitor protocol, command-line and monitor), so adding information for one of them means adding for them all.