From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41504) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMcad-00051a-Tj for qemu-devel@nongnu.org; Wed, 18 May 2011 04:58:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QMcab-0002Vr-WF for qemu-devel@nongnu.org; Wed, 18 May 2011 04:58:47 -0400 Received: from mail-yx0-f173.google.com ([209.85.213.173]:41867) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QMcab-0002VT-ST for qemu-devel@nongnu.org; Wed, 18 May 2011 04:58:45 -0400 Received: by yxk8 with SMTP id 8so534217yxk.4 for ; Wed, 18 May 2011 01:58:45 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <1305679930-4215-18-git-send-email-mdroth@linux.vnet.ibm.com> References: <1305679930-4215-1-git-send-email-mdroth@linux.vnet.ibm.com> <1305679930-4215-18-git-send-email-mdroth@linux.vnet.ibm.com> Date: Wed, 18 May 2011 09:58:44 +0100 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v1][ 17/23] qapi: add QMP dispatch functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Michael Roth Cc: aliguori@linux.vnet.ibm.com, qemu-devel@nongnu.org, lcapitulino@redhat.com On Wed, May 18, 2011 at 1:52 AM, Michael Roth w= rote: > Given an object recieved via QMP, this code uses the dispatch table > provided by qmp_registry.c to call the corresponding marshalling/dispatch > function and format return values/errors for delivery to the QMP. > Currently only synchronous QMP functions are supported, but this will > also be used for async QMP functions and QMP guest proxy dispatch as > well. > > Signed-off-by: Michael Roth > --- > =A0qapi/qmp-dispatch.c | =A0104 +++++++++++++++++++++++++++++++++++++++++= ++++++++++ > =A01 files changed, 104 insertions(+), 0 deletions(-) > =A0create mode 100644 qapi/qmp-dispatch.c > > diff --git a/qapi/qmp-dispatch.c b/qapi/qmp-dispatch.c > new file mode 100644 > index 0000000..733decf > --- /dev/null > +++ b/qapi/qmp-dispatch.c > @@ -0,0 +1,104 @@ > +#include > +#include "qemu-objects.h" > +#include "qapi/qmp-core.h" > +#include "json-parser.h" > + > +static QObject *qmp_dispatch_err(QmpState *state, QObject *request, Erro= r **errp) > +{ > + =A0 =A0const char *command; > + =A0 =A0QDict *args, *dict; > + =A0 =A0//QObject *request; > + =A0 =A0QmpCommand *cmd; > + =A0 =A0QObject *ret =3D NULL; > + =A0 =A0//Error *err =3D NULL; Please remove commented out lines, it makes the code noisy. > + =A0 =A0case QCT_ASYNC: { > + =A0 =A0 =A0 =A0QmpCommandState *s =3D qemu_mallocz(sizeof(*s)); > + =A0 =A0 =A0 =A0// FIXME save async commands and do something > + =A0 =A0 =A0 =A0// smart if disconnect occurs before completion > + =A0 =A0 =A0 =A0s->state =3D state; > + =A0 =A0 =A0 =A0s->tag =3D NULL; > + =A0 =A0 =A0 =A0if (qdict_haskey(dict, "tag")) { > + =A0 =A0 =A0 =A0 =A0 =A0s->tag =3D qdict_get(dict, "tag"); > + =A0 =A0 =A0 =A0 =A0 =A0qobject_incref(s->tag); > + =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0cmd->afn(args, errp, s); async_fn() would be a clear name. > + =A0 =A0 =A0 =A0ret =3D NULL; It is already NULL. > + =A0 =A0} > + =A0 =A0 =A0 =A0break; > + =A0 =A0case QCT_PROXY: { > + =A0 =A0 =A0 =A0QmpCommandState *s =3D qemu_mallocz(sizeof(*s)); > + =A0 =A0 =A0 =A0// FIXME save async commands and do something > + =A0 =A0 =A0 =A0// smart if disconnect occurs before completion > + =A0 =A0 =A0 =A0s->state =3D state; > + =A0 =A0 =A0 =A0s->tag =3D NULL; > + =A0 =A0 =A0 =A0if (qdict_haskey(dict, "tag")) { > + =A0 =A0 =A0 =A0 =A0 =A0s->tag =3D qdict_get(dict, "tag"); > + =A0 =A0 =A0 =A0 =A0 =A0qobject_incref(s->tag); > + =A0 =A0 =A0 =A0} > + =A0 =A0 =A0 =A0cmd->pfn(args, errp, s); > + =A0 =A0 =A0 =A0ret =3D NULL; Same comments as for async. Stefan