On Wed, May 18, 2011 at 1:52 AM, Michael Roth <mdr...@linux.vnet.ibm.com> wrote: > 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 <mdr...@linux.vnet.ibm.com> > --- > qapi/qmp-dispatch.c | 104 > +++++++++++++++++++++++++++++++++++++++++++++++++++ > 1 files changed, 104 insertions(+), 0 deletions(-) > create 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 <glib.h> > +#include "qemu-objects.h" > +#include "qapi/qmp-core.h" > +#include "json-parser.h" > + > +static QObject *qmp_dispatch_err(QmpState *state, QObject *request, Error > **errp) > +{ > + const char *command; > + QDict *args, *dict; > + //QObject *request; > + QmpCommand *cmd; > + QObject *ret = NULL; > + //Error *err = NULL;
Please remove commented out lines, it makes the code noisy. > + case QCT_ASYNC: { > + QmpCommandState *s = qemu_mallocz(sizeof(*s)); > + // FIXME save async commands and do something > + // smart if disconnect occurs before completion > + s->state = state; > + s->tag = NULL; > + if (qdict_haskey(dict, "tag")) { > + s->tag = qdict_get(dict, "tag"); > + qobject_incref(s->tag); > + } > + cmd->afn(args, errp, s); async_fn() would be a clear name. > + ret = NULL; It is already NULL. > + } > + break; > + case QCT_PROXY: { > + QmpCommandState *s = qemu_mallocz(sizeof(*s)); > + // FIXME save async commands and do something > + // smart if disconnect occurs before completion > + s->state = state; > + s->tag = NULL; > + if (qdict_haskey(dict, "tag")) { > + s->tag = qdict_get(dict, "tag"); > + qobject_incref(s->tag); > + } > + cmd->pfn(args, errp, s); > + ret = NULL; Same comments as for async. Stefan