From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MyTvx-0002Fl-E6 for qemu-devel@nongnu.org; Thu, 15 Oct 2009 13:16:13 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MyTvt-0002EK-Se for qemu-devel@nongnu.org; Thu, 15 Oct 2009 13:16:13 -0400 Received: from [199.232.76.173] (port=44303 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MyTvt-0002EC-K0 for qemu-devel@nongnu.org; Thu, 15 Oct 2009 13:16:09 -0400 Received: from e4.ny.us.ibm.com ([32.97.182.144]:57532) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MyTvt-0001oa-BO for qemu-devel@nongnu.org; Thu, 15 Oct 2009 13:16:09 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e4.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id n9FH8UEA031139 for ; Thu, 15 Oct 2009 13:08:30 -0400 Received: from d01av01.pok.ibm.com (d01av01.pok.ibm.com [9.56.224.215]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n9FHG7TL209148 for ; Thu, 15 Oct 2009 13:16:07 -0400 Received: from d01av01.pok.ibm.com (d03av01 [127.0.0.1]) by d01av01.pok.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id n9FHG6lH029265 for ; Thu, 15 Oct 2009 13:16:06 -0400 Subject: Re: [Qemu-devel] [PATCH 6/9] QError: Add qdev not found error From: Hollis Blanchard In-Reply-To: <20091015103405.591e2f3b@doriath> References: <1255453026-18637-1-git-send-email-lcapitulino@redhat.com> <1255453026-18637-7-git-send-email-lcapitulino@redhat.com> <1255561330.29192.2.camel@slab.beaverton.ibm.com> <20091015103405.591e2f3b@doriath> Content-Type: text/plain Date: Thu, 15 Oct 2009 10:16:00 -0700 Message-Id: <1255626960.29192.7.camel@slab.beaverton.ibm.com> Mime-Version: 1.0 Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: aliguori@us.ibm.com, qemu-devel@nongnu.org, kraxel@redhat.com On Thu, 2009-10-15 at 10:34 -0300, Luiz Capitulino wrote: > On Wed, 14 Oct 2009 16:02:10 -0700 > Hollis Blanchard wrote: > > > On Tue, 2009-10-13 at 13:57 -0300, Luiz Capitulino wrote: > > > Signed-off-by: Luiz Capitulino > > > --- > > > qerror.c | 12 ++++++++++++ > > > qerror.h | 1 + > > > 2 files changed, 13 insertions(+), 0 deletions(-) > > > > > > diff --git a/qerror.c b/qerror.c > > > index bbea770..88a8208 100644 > > > --- a/qerror.c > > > +++ b/qerror.c > > > @@ -24,11 +24,23 @@ static const QType qerror_type = { > > > .destroy = qerror_destroy_obj, > > > }; > > > > > > +static void qemu_err_qdev_nodev(const QError *qerror) > > > +{ > > > + QDict *qdict = qobject_to_qdict(qerror->data); > > > + qemu_error("Device \"%s\" not found. Try -device '?' for a list.\n", > > > + qdict_get_str(qdict, "name")); > > > +} > > > + > > > static QErrorTable qerror_table[] = { > > > { > > > .code = QERR_UNKNOWN, > > > .desc = "unknown error", > > > }, > > > + { > > > + .code = QERR_QDEV_NFOUND, > > > + .desc = "device not found", > > > + .user_print = qemu_err_qdev_nodev, > > > + }, > > > }; > > > > > > /** > > > diff --git a/qerror.h b/qerror.h > > > index ed25ef1..820f25e 100644 > > > --- a/qerror.h > > > +++ b/qerror.h > > > @@ -21,6 +21,7 @@ > > > */ > > > typedef enum QErrorCode { > > > QERR_UNKNOWN, > > > + QERR_QDEV_NFOUND, > > > QERR_MAX, > > > } QErrorCode; > > > > I'm not really seeing the point: what is gained by moving the error text > > from the original site into this function-inside-a-structure? > > Compatibility and a way of having pretty printing functions w/o > breaking the machine protocol. Huh? Compatibility with what? I don't understand this "pretty printing" comment either. You could easily have qemu_error(code, "device not found"); throughout the code, and transmit that as { "error": { "code": code, "desc": "device not found" } } -- Hollis Blanchard IBM Linux Technology Center